|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.basedb.util.resources.ResourceBundleWrapper
public class ResourceBundleWrapper
A wrapper around ResourceBundle
objects. We use the wrapper because we don't
want to throw exceptions if a key is missing. Instead, we return the key as the value
and log a message to system log. There are also some other useful variants for retreiving
values.
Field Summary | |
---|---|
private static Logger |
log
|
private String |
name
|
private ResourceBundle |
parent
|
private boolean |
returnKeys
|
Constructor Summary | |
---|---|
ResourceBundleWrapper(String name,
ResourceBundle parent)
The wrapper is created by ResourceBundleFactory . |
Method Summary | |
---|---|
Locale |
getLocale()
Get the actual locale used by the bundle, which may be a different locale from the one that was used to load it. |
String |
getName()
Get the base name of the resource bundle. |
ResourceBundle |
getResourceBundle()
Get access to the underlying resource bundle. |
String |
getString(String key,
boolean variant,
String... replacements)
Utility method for returning the value for the key given by key.0 (variant=false) or key.1
(variant=true) depending on the value of the variant parameter. |
String |
getString(String key,
int index,
String... replacements)
Utility method for returning the value for the key given by: key.index . |
String |
getString(String key,
String... replacements)
Get a string value from the bundle. |
void |
setReturnKeys(boolean returnKeys)
Set a flag indicating that the various getString() methods
should always return the key instead of trying to find a value for it. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final Logger log
private final String name
private final ResourceBundle parent
private boolean returnKeys
Constructor Detail |
---|
public ResourceBundleWrapper(String name, ResourceBundle parent)
ResourceBundleFactory
.
name
- The base name of the bundleparent
- The underlying ResourceBundle
Method Detail |
---|
public String getName()
public Locale getLocale()
public void setReturnKeys(boolean returnKeys)
getString()
methods
should always return the key instead of trying to find a value for it.
returnKeys
- TRUE to always return the key, FALSE to try to find valuespublic ResourceBundle getResourceBundle()
public String getString(String key, boolean variant, String... replacements)
key.0
(variant=false) or key.1
(variant=true) depending on the value of the variant parameter.
getString(String, String...)
public String getString(String key, int index, String... replacements)
key.index
.
getString(String, String...)
public String getString(String key, String... replacements)
{index}
which will be replaced by the
corresponding value from the replacements array. Index values
that are outside the range of the array are not replaced.
If no value is found for the key or if the setReturnKeys(boolean)
has been enabled the key is returned.
key
- The key for the valuereplacements
- An optional array with string replacments
public String toString()
toString
in class Object
|
2.17.2: 2011-06-17 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |