IntegratedResourceBundlepublic class IntegratedResourceBundle extends ListResourceBundle
Fields Summary |
---|
private Locale | locale | private Object[] | contents |
Constructors Summary |
---|
public IntegratedResourceBundle(ResourceBundle main, Map localizationPaths)
this(main, localizationPaths, null);
| public IntegratedResourceBundle(ResourceBundle main, Map localizationPaths, Collection resource_bundles)
locale = main.getLocale();
Hashtable messages = new Hashtable();
addResourceMessages(main, messages);
for (Iterator iter = localizationPaths.keySet().iterator(); iter.hasNext();) {
String localizationPath = (String) iter.next();
ClassLoader classLoader = (ClassLoader) localizationPaths.get(localizationPath);
ResourceBundle newResourceBundle = null;
try {
if(classLoader != null)
newResourceBundle = ResourceBundle.getBundle(localizationPath, locale ,classLoader);
else
newResourceBundle = ResourceBundle.getBundle(localizationPath, locale,IntegratedResourceBundle.class.getClassLoader());
} catch (Exception e) {
// System.out.println(localizationPath+": no resource bundle for " +
// main.getLocale());
try {
if(classLoader != null)
newResourceBundle = ResourceBundle.getBundle(localizationPath, MessageText.LOCALE_DEFAULT,classLoader);
else
newResourceBundle = ResourceBundle.getBundle(localizationPath, MessageText.LOCALE_DEFAULT,IntegratedResourceBundle.class.getClassLoader());
} catch (Exception e2) {
System.out.println(localizationPath + ": no default resource bundle");
continue;
}
}
addResourceMessages(newResourceBundle, messages);
}
if (resource_bundles != null) {
for (Iterator itr = resource_bundles.iterator(); itr.hasNext();) {
addResourceMessages((ResourceBundle)itr.next(), messages);
}
}
contents = new Object[messages.size()][2];
int i = 0;
for (Enumeration enumeration = messages.keys(); enumeration.hasMoreElements();) {
String key = (String) enumeration.nextElement();
contents[i][0] = key;
contents[i++][1] = messages.get(key);
}
|
Methods Summary |
---|
private void | addResourceMessages(java.util.ResourceBundle bundle, java.util.Hashtable messages)
if (bundle != null) {
for (Enumeration enumeration = bundle.getKeys(); enumeration.hasMoreElements();) {
String key = (String) enumeration.nextElement();
messages.put(key, bundle.getObject(key));
}
}
| public java.lang.Object[][] | getContents()
return contents;
| public java.util.Locale | getLocale()
return locale;
|
|