1 2 package com.sun.xml.fastinfoset; 3 4 import java.text.MessageFormat ; 5 import java.util.Enumeration ; 6 import java.util.Locale ; 7 import java.util.ResourceBundle ; 8 9 10 public class CommonResourceBundle extends AbstractResourceBundle { 11 12 public static final String BASE_NAME = "com.sun.xml.fastinfoset.resources.ResourceBundle"; 13 private static CommonResourceBundle instance = null; 14 private static Locale locale = null; 15 private ResourceBundle bundle = null; 16 17 protected CommonResourceBundle() { 18 bundle = ResourceBundle.getBundle(BASE_NAME); 20 } 21 22 protected CommonResourceBundle(Locale locale) { 23 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 String localeString = null; 36 locale = parseLocale(localeString); 37 } 38 } 39 } 40 41 return instance; 42 } 43 44 public static CommonResourceBundle getInstance(Locale 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 getBundle() { 63 return bundle; 64 } 65 public ResourceBundle getBundle(Locale locale) { 66 return ResourceBundle.getBundle(BASE_NAME, locale); 67 } 68 69 } 70 | Popular Tags |