Package com.sun.enterprise.util.i18n
Class StringManagerBase
- java.lang.Object
-
- com.sun.enterprise.util.i18n.StringManagerBase
-
- Direct Known Subclasses:
StringManager
public class StringManagerBase extends Object
Implementation of a local string manager. Provides access to i18n messages for classes that need them.One StringManagerBase per resource bundle name can be created and accessed by the getManager method call.
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 - Since:
- JDK1.4
- Author:
- Nazrul Islam
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedStringManagerBase(String resourceBundleName, ClassLoader classLoader)Initializes the resource bundle.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetString(String key)Returns a localized string.StringgetString(String key, Object arg1)Returns a local string for the caller and format the arguments accordingly.StringgetString(String key, Object[] args)Returns a local string for the caller and format the arguments accordingly.StringgetString(String key, Object arg1, Object arg2)Returns a local string for the caller and format the arguments accordingly.StringgetString(String key, Object arg1, Object arg2, Object arg3)Returns a local string for the caller and format the arguments accordingly.StringgetString(String key, Object arg1, Object arg2, Object arg3, Object arg4)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.StringgetStringWithDefault(String key, String defaultValue)Returns a localized string.StringgetStringWithDefault(String key, String defaultFormat, Object[] arguments)Returns a local string for the caller and format the arguments accordingly.
-
-
-
Constructor Detail
-
StringManagerBase
protected StringManagerBase(String resourceBundleName, ClassLoader classLoader)
Initializes the resource bundle.- Parameters:
resourceBundleName- name of the resource bundle
-
-
Method Detail
-
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
public String getString(String key)
Returns a localized string.- Parameters:
key- the name of the resource to fetch- Returns:
- the localized string
-
getStringWithDefault
public String getStringWithDefault(String key, String defaultValue)
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
public String getStringWithDefault(String key, String defaultFormat, Object[] arguments)
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
public String getString(String key, Object arg1)
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
public String getString(String key, Object arg1, Object arg2)
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
public String getString(String key, Object arg1, Object arg2, Object arg3)
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
public String getString(String key, Object arg1, Object arg2, Object arg3, Object arg4)
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
-
-