public final class XmlMessages
extends java.lang.Object
ResourceBundle
called
StringResource
in a given class' package.
ie, If the class is my.package.foo.Bar
, the
methods will look for the ResourceBundle
my.package.foo.StringResource
. (The actual file can be
a subclass of ResourceBundle or a properties file.)
The ResourceBundle keys are assumed to be prefixed with the class name.
ie, if the class is my.package.foo.Bar
and the key is
msg
, the methods will then
look for the key Bar.msg
.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
MESSAGE_NOT_FOUND
The error warning message in case we don't find a message.
|
static java.lang.String |
PRODUCT_NAME_MACRO |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
format(java.lang.Class clazz,
java.util.Locale locale,
java.lang.String key,
java.lang.Object... args)
Method to format a string from the resource bundle.
|
java.lang.String |
format(java.lang.Class clazz,
java.util.Locale locale,
java.lang.String key,
java.lang.String arg1)
Convenience method to format a string from the resource bundle, which
takes a single argument.
|
java.lang.String |
format(java.lang.Class clazz,
java.util.Locale locale,
java.lang.String key,
java.lang.String arg1,
java.lang.String arg2)
Convenience method to format a string from the resource bundle, which
takes two arguments.
|
java.lang.String |
format(java.lang.Class clazz,
java.util.Locale locale,
java.lang.String key,
java.lang.String arg1,
java.lang.String arg2,
java.lang.String arg3)
Convenience method to format a string from the resource bundle, which
takes three arguments.
|
protected java.util.ResourceBundle |
getBundle(java.lang.String bundleName,
java.util.Locale locale)
Gets the resource bundle, first checking our internal cache
|
static XmlMessages |
getInstance()
Get the instance of the singleton class
|
java.util.Enumeration |
getKeys(java.lang.Class clazz,
java.util.Locale locale)
Gets the keys of all the strings in the specified class and locale's
resource bundle.
|
java.lang.String |
getMessage(java.lang.Class clazz,
java.util.Locale locale,
java.lang.String key)
Obtain a string from the resource file that doesn't require formatting.
|
void |
resetBundleCache()
Reload the XML Messages off the disk.
|
public static final java.lang.String MESSAGE_NOT_FOUND
public static final java.lang.String PRODUCT_NAME_MACRO
public static XmlMessages getInstance()
public void resetBundleCache()
protected java.util.ResourceBundle getBundle(java.lang.String bundleName, java.util.Locale locale)
bundleName
- name of the resource bundlelocale
- locale used to retrieve the resource bundlepublic java.lang.String getMessage(java.lang.Class clazz, java.util.Locale locale, java.lang.String key)
clazz
- the class to which the string belongslocale
- the locale used to find the resource bundlekey
- the key for the string to be obtained from the resource bundlepublic java.lang.String format(java.lang.Class clazz, java.util.Locale locale, java.lang.String key, java.lang.String arg1)
clazz
- the class to which the string belongslocale
- the locale used to find the resource bundlekey
- the key for the string to be obtained from the resource bundlearg1
- the first argument to use in the formatted textpublic java.lang.String format(java.lang.Class clazz, java.util.Locale locale, java.lang.String key, java.lang.String arg1, java.lang.String arg2)
clazz
- the class to which the string belongslocale
- the locale used to find the resource bundlekey
- the key for the string to be obtained from the resource bundlearg1
- the first argument to use in the formatted textarg2
- the second argument to use in the formatted textpublic java.lang.String format(java.lang.Class clazz, java.util.Locale locale, java.lang.String key, java.lang.String arg1, java.lang.String arg2, java.lang.String arg3)
clazz
- the class to which the string belongslocale
- the locale used to find the resource bundlekey
- the key for the string to be obtained from the resource bundlearg1
- the first argument to use in the formatted textarg2
- the second argument to use in the formatted textarg3
- the third argument to use in the formatted textpublic java.lang.String format(java.lang.Class clazz, java.util.Locale locale, java.lang.String key, java.lang.Object... args)
clazz
- the class to which the string belongslocale
- the locale used to find the resource bundlekey
- the key for the string to be obtained from the resource bundleargs
- the arguments that should be applied to the string obtained
from the resource bundle. Can be null, to represent no argumentspublic java.util.Enumeration getKeys(java.lang.Class clazz, java.util.Locale locale)
clazz
- Class of the resource bundlelocale
- locale used to retrieve the resource bundle