public class I18NHelper extends Object
I18NHelper msg = I18NHelper.getInstance("javax.jdo.Bundle");
This call uses the class loader that loaded the I18NHelper class to find
the specified Bundle. The class provides two overloaded getInstance
methods allowing to specify a different class loader:
getInstance(Class cls)
looks for a bundle
called "Bundle.properties" located in the package of the specified class
object and getInstance(String bundleName,ClassLoader loader)
uses the specified class loader to find the bundle.
Subsequently, instance methods can be used to format message strings using the text from the bundle, as in
throw new JDOFatalInternalException (msg.msg("ERR_NoMetadata",
cls.getName()));
Modifier and Type | Method and Description |
---|---|
static I18NHelper |
getInstance(Class cls)
An instance bound to a bundle.
|
static I18NHelper |
getInstance(String bundleName)
An instance bound to a bundle.
|
static I18NHelper |
getInstance(String bundleName,
ClassLoader loader)
An instance bound to a bundle.
|
ResourceBundle |
getResourceBundle()
Returns the resource bundle used by this I18NHelper.
|
String |
msg(String messageKey)
Message formatter
|
String |
msg(String messageKey,
boolean arg)
Message formatter
|
String |
msg(String messageKey,
int arg)
Message formatter
|
String |
msg(String messageKey,
Object arg1)
Message formatter
|
String |
msg(String messageKey,
Object[] args)
Message formatter
|
String |
msg(String messageKey,
Object arg1,
Object arg2)
Message formatter
|
String |
msg(String messageKey,
Object arg1,
Object arg2,
Object arg3)
Message formatter
|
public static I18NHelper getInstance(String bundleName)
bundleName
- the name of the bundlepublic static I18NHelper getInstance(Class cls)
null
.cls
- the class object from which to load the resource bundlepublic static I18NHelper getInstance(String bundleName, ClassLoader loader)
null
.bundleName
- the name of the bundleloader
- the class loader from which to load the resource
bundlepublic String msg(String messageKey)
messageKey
- the message keypublic String msg(String messageKey, Object arg1)
messageKey
- the message keyarg1
- the first argumentpublic String msg(String messageKey, Object arg1, Object arg2)
messageKey
- the message keyarg1
- the first argumentarg2
- the second argumentpublic String msg(String messageKey, Object arg1, Object arg2, Object arg3)
messageKey
- the message keyarg1
- the first argumentarg2
- the second argumentarg3
- the third argumentpublic String msg(String messageKey, Object[] args)
messageKey
- the message keyargs
- the array of argumentspublic String msg(String messageKey, int arg)
messageKey
- the message keyarg
- the argumentpublic String msg(String messageKey, boolean arg)
messageKey
- the message keyarg
- the argumentpublic ResourceBundle getResourceBundle()
Copyright © 2005–1970 Apache Software Foundation. All rights reserved.