Class RB
- java.lang.Object
-
- org.apache.axis2.i18n.RB
-
public class RB extends Object
CURRENTLY NOT USED KEEPING FOR REFERENCE 9/19/2002Wrapper class for resource bundles. Property files are used to store resource strings, which are the only types of resources available. Property files can inherit properties from other files so that a base property file can be used and a small number of properties can be over-ridden by another property file. For example you may create an english version of a resource file named "resource.properties". You then decide that the British English version of all of the properties except one are the same, so there is no need to redefine all of the properties in "resource_en_GB", just the one that is different.
The property file lookup searches for classes with various suffixes on the basis if the desired local and the current default local (as returned by Local.getDefault()). As property files are found the property values are merged so that inheritance is preserved.
The order of searching is:
basename + "_" + langage + "_" + country + "_" + variant basename + "_" + langage + "_" + country basename + "_" + langage basename + "_" + defaultLanguage + "_" + defaultCountry + "_" + defaultVariant basename + "_" + defaultLanguage + "_" + defaultCountry basename + "_" + defaultLanguage basename The basename is the name of the property file without the ".properties" extension.
Properties will be cached for performance.
Property values stored in the property files can also contain dynamic variables. Any dynamic variable defined in PropertiesUtil.getVariableValue() can be used (such as {date}), as well as arguments in the form {0}, {1}, etc. Argument values are specified in the various overloaded getString() methods.
-
-
Field Summary
Fields Modifier and Type Field Description static String
BASE_NAME
protected String
basePropertyFileName
static String
PROPERTY_EXT
protected Properties
resourceProperties
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
clearCache()
Clears the internal cache.static String
getMessage(Object caller, String basename, Locale locale, String key, Object[] args)
Properties
getProperties()
Get the underlying propertiesstatic String
getString(Object caller, String key)
Get a message from resource.properties from the package of the given object.static String
getString(Object caller, String key, Object arg0)
Get a message from resource.properties from the package of the given object.static String
getString(Object caller, String key, Object[] args)
Get a message from resource.properties from the package of the given object.static String
getString(Object caller, String key, Object arg0, Object arg1)
Get a message from resource.properties from the package of the given object.static String
getString(Object caller, String key, Object arg0, Object arg1, Object arg2)
Get a message from resource.properties from the package of the given object.static String
getString(Object caller, String key, Object arg0, Object arg1, Object arg2, Object arg3)
Get a message from resource.properties from the package of the given object.static String
getString(Object caller, String key, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4)
Get a message from resource.properties from the package of the given object.static String
getString(Object caller, Locale locale, String key)
Get a message from resource.properties from the package of the given object.static String
getString(Object caller, Locale locale, String key, Object arg0)
Get a message from resource.properties from the package of the given object.static String
getString(Object caller, Locale locale, String key, Object[] args)
Get a message from resource.properties from the package of the given object.static String
getString(Object caller, Locale locale, String key, Object arg0, Object arg1)
Get a message from resource.properties from the package of the given object.static String
getString(Object caller, Locale locale, String key, Object arg0, Object arg1, Object arg2)
Get a message from resource.properties from the package of the given object.static String
getString(Object caller, Locale locale, String key, Object arg0, Object arg1, Object arg2, Object arg3)
Get a message from resource.properties from the package of the given object.static String
getString(Object caller, Locale locale, String key, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4)
Get a message from resource.properties from the package of the given object.String
getString(String key)
Gets a string message from the resource bundle for the given keyString
getString(String key, Object arg0)
Gets a string message from the resource bundle for the given key.String
getString(String key, Object[] array)
Gets a string message from the resource bundle for the given key.String
getString(String key, Object arg0, Object arg1)
Gets a string message from the resource bundle for the given key.String
getString(String key, Object arg0, Object arg1, Object arg2)
Gets a string message from the resource bundle for the given key.protected Properties
loadProperties(String resname, ClassLoader loader)
protected void
loadProperties(String basename, ClassLoader loader, Locale locale, Locale defaultLocale)
protected Properties
loadProperties(String basename, ClassLoader loader, Locale locale, Properties props)
protected Properties
merge(Properties p1, Properties p2)
Merge two Properties objects
-
-
-
Field Detail
-
BASE_NAME
public static final String BASE_NAME
- See Also:
- Constant Field Values
-
PROPERTY_EXT
public static final String PROPERTY_EXT
- See Also:
- Constant Field Values
-
basePropertyFileName
protected String basePropertyFileName
-
resourceProperties
protected Properties resourceProperties
-
-
Constructor Detail
-
RB
public RB(String name) throws MissingResourceException
Construct a new RB- Parameters:
name
- The name of the property file without the ".properties" extension- Throws:
MissingResourceException
-
RB
public RB(Object caller, String name) throws MissingResourceException
Construct a new RB- Parameters:
caller
- The calling object. This is used to get the package name to further construct the basename as well as to get the proper ClassLoadername
- The name of the property file without the ".properties" extension- Throws:
MissingResourceException
-
RB
public RB(Object caller, String name, Locale locale) throws MissingResourceException
Construct a new RB- Parameters:
caller
- The calling object. This is used to get the package name to further construct the basename as well as to get the proper ClassLoadername
- The name of the property file without the ".properties" extensionlocale
- The locale- Throws:
MissingResourceException
-
-
Method Detail
-
getString
public String getString(String key) throws MissingResourceException
Gets a string message from the resource bundle for the given key- Parameters:
key
- The resource key- Returns:
- The message
- Throws:
MissingResourceException
-
getString
public String getString(String key, Object arg0) throws MissingResourceException
Gets a string message from the resource bundle for the given key. The message may contain variables that will be substituted with the given arguments. Variables have the format:
This message has two variables: {0} and {1} - Parameters:
key
- The resource keyarg0
- The argument to place in variable {0}- Returns:
- The message
- Throws:
MissingResourceException
-
getString
public String getString(String key, Object arg0, Object arg1) throws MissingResourceException
Gets a string message from the resource bundle for the given key. The message may contain variables that will be substituted with the given arguments. Variables have the format:
This message has two variables: {0} and {1} - Parameters:
key
- The resource keyarg0
- The argument to place in variable {0}arg1
- The argument to place in variable {1}- Returns:
- The message
- Throws:
MissingResourceException
-
getString
public String getString(String key, Object arg0, Object arg1, Object arg2) throws MissingResourceException
Gets a string message from the resource bundle for the given key. The message may contain variables that will be substituted with the given arguments. Variables have the format:
This message has two variables: {0} and {1} - Parameters:
key
- The resource keyarg0
- The argument to place in variable {0}arg1
- The argument to place in variable {1}arg2
- The argument to place in variable {1}- Returns:
- The message
- Throws:
MissingResourceException
-
getString
public String getString(String key, Object[] array) throws MissingResourceException
Gets a string message from the resource bundle for the given key. The message may contain variables that will be substituted with the given arguments. Variables have the format:
This message has two variables: {0} and {1} - Parameters:
key
- The resource keyarray
- An array of objects to place in corresponding variables- Returns:
- The message
- Throws:
MissingResourceException
-
loadProperties
protected void loadProperties(String basename, ClassLoader loader, Locale locale, Locale defaultLocale) throws MissingResourceException
- Throws:
MissingResourceException
-
loadProperties
protected Properties loadProperties(String basename, ClassLoader loader, Locale locale, Properties props)
-
loadProperties
protected Properties loadProperties(String resname, ClassLoader loader)
-
merge
protected Properties merge(Properties p1, Properties p2)
Merge two Properties objects
-
getProperties
public Properties getProperties()
Get the underlying properties
-
getString
public static String getString(Object caller, String key) throws MissingResourceException
Get a message from resource.properties from the package of the given object.- Parameters:
caller
- The calling object, used to get the package name and class loaderkey
- The resource key- Returns:
- The formatted message
- Throws:
MissingResourceException
-
getString
public static String getString(Object caller, String key, Object arg0) throws MissingResourceException
Get a message from resource.properties from the package of the given object.- Parameters:
caller
- The calling object, used to get the package name and class loaderkey
- The resource keyarg0
- The argument to place in variable {0}- Returns:
- The formatted message
- Throws:
MissingResourceException
-
getString
public static String getString(Object caller, String key, Object arg0, Object arg1) throws MissingResourceException
Get a message from resource.properties from the package of the given object.- Parameters:
caller
- The calling object, used to get the package name and class loaderkey
- The resource keyarg0
- The argument to place in variable {0}arg1
- The argument to place in variable {1}- Returns:
- The formatted message
- Throws:
MissingResourceException
-
getString
public static String getString(Object caller, String key, Object arg0, Object arg1, Object arg2) throws MissingResourceException
Get a message from resource.properties from the package of the given object.- Parameters:
caller
- The calling object, used to get the package name and class loaderkey
- The resource keyarg0
- The argument to place in variable {0}arg1
- The argument to place in variable {1}arg2
- The argument to place in variable {2}- Returns:
- The formatted message
- Throws:
MissingResourceException
-
getString
public static String getString(Object caller, String key, Object arg0, Object arg1, Object arg2, Object arg3) throws MissingResourceException
Get a message from resource.properties from the package of the given object.- Parameters:
caller
- The calling object, used to get the package name and class loaderkey
- The resource keyarg0
- The argument to place in variable {0}arg1
- The argument to place in variable {1}arg2
- The argument to place in variable {2}arg3
- The argument to place in variable {3}- Returns:
- The formatted message
- Throws:
MissingResourceException
-
getString
public static String getString(Object caller, String key, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4) throws MissingResourceException
Get a message from resource.properties from the package of the given object.- Parameters:
caller
- The calling object, used to get the package name and class loaderkey
- The resource keyarg0
- The argument to place in variable {0}arg1
- The argument to place in variable {1}arg2
- The argument to place in variable {2}arg3
- The argument to place in variable {3}arg4
- The argument to place in variable {4}- Returns:
- Returns the formatted message.
- Throws:
MissingResourceException
-
getString
public static String getString(Object caller, String key, Object[] args) throws MissingResourceException
Get a message from resource.properties from the package of the given object.- Parameters:
caller
- The calling object, used to get the package name and class loaderkey
- The resource keyargs
- An array of objects to place in corresponding variables- Returns:
- Returns the formatted message.
- Throws:
MissingResourceException
-
getString
public static String getString(Object caller, Locale locale, String key) throws MissingResourceException
Get a message from resource.properties from the package of the given object.- Parameters:
caller
- The calling object, used to get the package name and class loaderlocale
- The localekey
- The resource key- Returns:
- The formatted message
- Throws:
MissingResourceException
-
getString
public static String getString(Object caller, Locale locale, String key, Object arg0) throws MissingResourceException
Get a message from resource.properties from the package of the given object.- Parameters:
caller
- The calling object, used to get the package name and class loaderlocale
- The localekey
- The resource keyarg0
- The argument to place in variable {0}- Returns:
- The formatted message
- Throws:
MissingResourceException
-
getString
public static String getString(Object caller, Locale locale, String key, Object arg0, Object arg1) throws MissingResourceException
Get a message from resource.properties from the package of the given object.- Parameters:
caller
- The calling object, used to get the package name and class loaderlocale
- The localekey
- The resource keyarg0
- The argument to place in variable {0}arg1
- The argument to place in variable {1}- Returns:
- The formatted message
- Throws:
MissingResourceException
-
getString
public static String getString(Object caller, Locale locale, String key, Object arg0, Object arg1, Object arg2) throws MissingResourceException
Get a message from resource.properties from the package of the given object.- Parameters:
caller
- The calling object, used to get the package name and class loaderlocale
- The localekey
- The resource keyarg0
- The argument to place in variable {0}arg1
- The argument to place in variable {1}arg2
- The argument to place in variable {2}- Returns:
- The formatted message
- Throws:
MissingResourceException
-
getString
public static String getString(Object caller, Locale locale, String key, Object arg0, Object arg1, Object arg2, Object arg3) throws MissingResourceException
Get a message from resource.properties from the package of the given object.- Parameters:
caller
- The calling object, used to get the package name and class loaderlocale
- The localekey
- The resource keyarg0
- The argument to place in variable {0}arg1
- The argument to place in variable {1}arg2
- The argument to place in variable {2}arg3
- The argument to place in variable {3}- Returns:
- The formatted message
- Throws:
MissingResourceException
-
getString
public static String getString(Object caller, Locale locale, String key, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4) throws MissingResourceException
Get a message from resource.properties from the package of the given object.- Parameters:
caller
- The calling object, used to get the package name and class loaderlocale
- The localekey
- The resource keyarg0
- The argument to place in variable {0}arg1
- The argument to place in variable {1}arg2
- The argument to place in variable {2}arg3
- The argument to place in variable {3}- Returns:
- Returns the formatted message.
- Throws:
MissingResourceException
-
getString
public static String getString(Object caller, Locale locale, String key, Object[] args) throws MissingResourceException
Get a message from resource.properties from the package of the given object.- Parameters:
caller
- The calling object, used to get the package name and class loaderlocale
- The localekey
- The resource keyargs
- An array of objects to place in corresponding variables- Returns:
- Returns the formatted message.
- Throws:
MissingResourceException
-
getMessage
public static String getMessage(Object caller, String basename, Locale locale, String key, Object[] args) throws MissingResourceException
- Throws:
MissingResourceException
-
clearCache
public static void clearCache()
Clears the internal cache.
-
-