Package com.sun.enterprise.util.i18n
Class StringManagerBase
java.lang.Object
com.sun.enterprise.util.i18n.StringManagerBase
- Direct Known Subclasses:
StringManager
Implementation of a local string manager. Provides access to i18n messages
for classes that need them.
Example:
[LocalStrings.properties]
test=At {1,time} on {1,date}, there was {2} on planet {0,number,integer}
StringManagerBase sm = StringManagerBase.getStringManager("LocalStrings.properties");
.....
try {
....
} catch (Exception e) {
String localizedMsg = sm.getString("test",
new Integer(7), new java.util.Date(System.currentTimeMillis()),
"a disturbance in the Force");
throw new MyException(localizedMsg, e);
}
Localized message:
At 2:27:41 PM on Jul 8, 2002, there was a disturbance in the Force
on planet 7
One StringManagerBase per resource bundle name can be created and accessed by the getManager method call.
- Since:
- JDK1.4
- Author:
- Nazrul Islam
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedStringManagerBase(String resourceBundleName, ClassLoader classLoader) Initializes the resource bundle. -
Method Summary
Modifier and TypeMethodDescriptionReturns a localized string.Returns a local string for the caller and format the arguments accordingly.Returns a local string for the caller and format the arguments accordingly.Returns a local string for the caller and format the arguments accordingly.Returns a local string for the caller and format the arguments accordingly.Returns a local string for the caller and format the arguments accordingly.static StringManagerBasegetStringManager(String resourceBundleName, ClassLoader classLoader) Returns a local string manager for the given resourceBundle name.getStringWithDefault(String key, String defaultValue) Returns a localized string.getStringWithDefault(String key, String defaultFormat, Object[] arguments) Returns a local string for the caller and format the arguments accordingly.
-
Constructor Details
-
StringManagerBase
Initializes the resource bundle.- Parameters:
resourceBundleName- name of the resource bundle
-
-
Method Details
-
getStringManager
public static StringManagerBase getStringManager(String resourceBundleName, ClassLoader classLoader) Returns a local string manager for the given resourceBundle name.- Parameters:
resourceBundleName- name of the resource bundle- Returns:
- a local string manager for the given package name
-
getString
Returns a localized string.- Parameters:
key- the name of the resource to fetch- Returns:
- the localized string
-
getStringWithDefault
Returns a localized string. If the key is not found, it will return the default given value.- Parameters:
key- the name of the resource to fetchdefaultValue- the default return value if not found- Returns:
- the localized string
-
getStringWithDefault
Returns a local string for the caller and format the arguments accordingly. If the key is not found, it will use the given default format.- Parameters:
key- the key to the local format stringdefaultFormat- the default format if not found in the resourcesarguments- the set of arguments to provide to the formatter- Returns:
- a formatted localized string
-
getString
Returns a local string for the caller and format the arguments accordingly.- Parameters:
key- the key to the local format stringarg1- the one argument to be provided to the formatter- Returns:
- a formatted localized string
-
getString
Returns a local string for the caller and format the arguments accordingly.- Parameters:
key- the key to the local format stringarg1- first argument to be provided to the formatterarg2- second argument to be provided to the formatter- Returns:
- a formatted localized string
-
getString
Returns a local string for the caller and format the arguments accordingly.- Parameters:
key- the key to the local format stringarg1- first argument to be provided to the formatterarg2- second argument to be provided to the formatterarg3- third argument to be provided to the formatter- Returns:
- a formatted localized string
-
getString
Returns a local string for the caller and format the arguments accordingly.- Parameters:
key- the key to the local format stringarg1- first argument to be provided to the formatterarg2- second argument to be provided to the formatterarg3- third argument to be provided to the formatterarg4- fourth argument to be provided to the formatter- Returns:
- a formatted localized string
-
getString
Returns a local string for the caller and format the arguments accordingly.- Parameters:
key- the key to the local format stringargs- the array of arguments to be provided to the formatter- Returns:
- a formatted localized string
-