LocalStringsManagerpublic class LocalStringsManager extends Object
Fields Summary |
---|
private final String | packageName | private final String | propertyFile | private final Vector | resourceBundles | public static final String | DEFAULT_STRING_VALUE |
Constructors Summary |
---|
public LocalStringsManager(String packageNameIn, String propertyFileIn)Creates a new instance of LocalStringsManager
this.packageName = packageNameIn;
this.propertyFile = propertyFileIn;
ResourceBundle resourceBundle =
ResourceBundle.getBundle(packageNameIn + "." + propertyFile);
resourceBundles.add(resourceBundle);
| public LocalStringsManager(Vector localizePropertiesList)Creates a new instance of LocalStringsManager from the
properties Vector
this.packageName = null;
this.propertyFile = null;
for (int i = 0; i < localizePropertiesList.size(); i++)
{
Properties properties = localizePropertiesList.get(i);
String packageNameStr = (String) properties.get("base-package");
String propertyFileStr = (String) properties.get("property-file-name");
ResourceBundle resourceBundle =
ResourceBundle.getBundle(packageNameStr + "." + propertyFileStr);
resourceBundles.add(resourceBundle);
}
| public LocalStringsManager(Vector localizeStringList, Locale locale)Creates a new instance of LocalStringsManager from the
properties Vector of Strings and locale
this.packageName = null;
this.propertyFile = null;
for (int i = 0; i < localizeStringList.size(); i++)
{
ResourceBundle resourceBundle =
ResourceBundle.getBundle(localizeStringList.get(i),
locale);
resourceBundles.add(resourceBundle);
}
|
Methods Summary |
---|
public java.lang.String | getPackageName()
return packageName;
| public java.lang.String | getPropertiesFile()
return propertyFile;
| public java.util.Vector | getResourceBundles()
return resourceBundles;
| public java.lang.String | getString(java.lang.String key)
Iterator resourcesIter = resourceBundles.iterator();
String value = DEFAULT_STRING_VALUE + " (" + key + ")";
while (resourcesIter.hasNext())
{
ResourceBundle resourceBundle = (ResourceBundle)resourcesIter.next();
try
{
value = resourceBundle.getString(key);
break;
}
catch (MissingResourceException mre)
{
// if not found, try next resource bundle in the iterator
}
}
return value;
| public java.lang.String | getString(java.lang.String key, java.lang.Object[] toInsert)
String fmtStr = null;
try
{
MessageFormat msgFormat =
new MessageFormat(getString(key));
fmtStr = msgFormat.format(toInsert);
}
catch(Exception e)
{
throw new CommandValidationException(e);
}
return fmtStr;
|
|