|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.buck.commons.i18n.ResourceBundle
public final class ResourceBundle
Class to hide details of getting a resource bundle, properly; the class also provides facilities to format resource bundle messages.
The general form to format resource bundle messages is:
try {
// ...
} catch (Exception e) {
Object[] fmtargs = {yourValue};
String message = ResourceBundle.formatResourceBundleMessage(
YourLexicallyEnclosingClassName.class,
"YOUR_RESOURCE_BUNDLE_MESSAGE_MNEMONIC", fmtargs);
throw new Exception(message, e);
}
In the package containing YourLexicallyEnclosingClassName.class you
would add a file named resource.properties, which may have the
following content, where CAFEBABE is a Hex error code:
YOUR_RESOURCE_BUNDLE_MESSAGE_MNEMONIC=(ERROR:CAFEBABE) An error occurred
processing ({0}).
| Constructor Summary | |
|---|---|
ResourceBundle()
|
|
| Method Summary | |
|---|---|
static String |
formatResourceBundleMessage(Class c,
String mnemonic,
Object[] arguments)
A helper function to format a message using a resource identified by its mnemonic, located in a resource bundle located in the package of the given class. |
static ResourceBundle |
getResourceBundle(Class c)
Get the resource bundle in the package of the specified class. |
static ResourceBundle |
getResourceBundle(String baseName)
Get a resource bundle using the context class loader and default locale. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ResourceBundle()
| Method Detail |
|---|
public static ResourceBundle getResourceBundle(String baseName)
baseName - the name of the resource bundle
public static ResourceBundle getResourceBundle(Class c)
c - the class in whose package a resource.properties file exists.
public static String formatResourceBundleMessage(Class c,
String mnemonic,
Object[] arguments)
c - the class in whose package we will load a resource
bundlemnemonic - the message mnemonic to load from the bundlearguments - formatting arguments
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||