01: /**
02: * Copyright 2005 Sun Microsystems, Inc. All
03: * rights reserved. Use of this product is subject
04: * to license terms. Federal Acquisitions:
05: * Commercial Software -- Government Users
06: * Subject to Standard License Terms and
07: * Conditions.
08: *
09: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
10: * are trademarks or registered trademarks of Sun Microsystems,
11: * Inc. in the United States and other countries.
12: */package com.sun.portal.admin.console.ubt.data;
13:
14: import com.sun.portal.admin.console.logging.data.*;
15:
16: import javax.faces.context.FacesContext;
17: import java.io.InputStream;
18: import java.io.IOException;
19: import java.util.Properties;
20: import java.util.ResourceBundle;
21: import java.util.Locale;
22: import java.util.logging.Logger;
23:
24: /**
25: *
26: */
27: public class UBTResourceBundle {
28: private static final String UBT_RESOURCE = "ubt";
29: private static final String UBT_REPORT_RESOURCE = "com.sun.portal.ubt.report.resource.ReportsResourceBundle";
30: private static ResourceBundle ubtResource = ResourceBundle
31: .getBundle(UBT_RESOURCE);
32: private static ResourceBundle ubtReportResource = ResourceBundle
33: .getBundle(UBT_REPORT_RESOURCE);
34:
35: public static String getProperty(String key) {
36: ubtResource = loadResource(ubtResource, UBT_RESOURCE);
37: String val = null;
38: try {
39: val = ubtResource.getString(key);
40: } catch (Exception e) {
41: //drop through
42: //missing resource or null key
43: }
44: if (val == null)
45: return key;
46: else
47: return val;
48: }
49:
50: private static ResourceBundle loadResource(ResourceBundle rb,
51: String rbName) {
52: FacesContext fc = FacesContext.getCurrentInstance();
53: Locale locale = fc.getViewRoot().getLocale();
54: return ResourceBundle.getBundle(rbName, locale);
55: }
56:
57: public static String getReportProperty(String key) {
58: ubtReportResource = loadResource(ubtReportResource,
59: UBT_REPORT_RESOURCE);
60: String val = null;
61: try {
62: val = ubtReportResource.getString(key);
63:
64: } catch (Exception e) {
65: //drop through
66: //missing resource or null key
67: }
68: if (val == null)
69: return key;
70: else
71: return val;
72: }
73: }
|