KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > xml > fastinfoset > CommonResourceBundle


1
2 package com.sun.xml.fastinfoset;
3
4 import java.text.MessageFormat JavaDoc;
5 import java.util.Enumeration JavaDoc;
6 import java.util.Locale JavaDoc;
7 import java.util.ResourceBundle JavaDoc;
8
9
10 public class CommonResourceBundle extends AbstractResourceBundle {
11
12     public static final String JavaDoc BASE_NAME = "com.sun.xml.fastinfoset.resources.ResourceBundle";
13     private static CommonResourceBundle instance = null;
14     private static Locale JavaDoc locale = null;
15     private ResourceBundle JavaDoc bundle = null;
16     
17     protected CommonResourceBundle() {
18         // Load the resource bundle of default locale
19
bundle = ResourceBundle.getBundle(BASE_NAME);
20     }
21
22     protected CommonResourceBundle(Locale JavaDoc locale) {
23         // Load the resource bundle of specified locale
24
bundle = ResourceBundle.getBundle(BASE_NAME, locale);
25     }
26
27     public static CommonResourceBundle getInstance() {
28         if (instance == null) {
29             synchronized (CommonResourceBundle.class) {
30                 if (instance == null) {
31                     instance = new CommonResourceBundle();
32                     //**need to know where to get the locale
33
//String localeString = CommonProperties.getInstance()
34
// .getProperty("omar.common.locale");
35
String JavaDoc localeString = null;
36                     locale = parseLocale(localeString);
37                 }
38             }
39         }
40
41         return instance;
42     }
43     
44     public static CommonResourceBundle getInstance(Locale JavaDoc locale) {
45         if (instance == null) {
46             synchronized (CommonResourceBundle.class) {
47                 if (instance == null) {
48                     instance = new CommonResourceBundle(locale);
49                 }
50             }
51         } else {
52             synchronized (CommonResourceBundle.class) {
53                 if (CommonResourceBundle.locale != locale) {
54                     instance = new CommonResourceBundle(locale);
55                 }
56             }
57     }
58         return instance;
59     }
60
61
62     public ResourceBundle JavaDoc getBundle() {
63         return bundle;
64     }
65     public ResourceBundle JavaDoc getBundle(Locale JavaDoc locale) {
66         return ResourceBundle.getBundle(BASE_NAME, locale);
67     }
68     
69 }
70
Popular Tags