@ThreadSafe public class IndexedResourceBundle extends ResourceBundle implements Localized
ResourceBundle
implementation accepting integers instead of strings for resource keys.
Using integers allow implementations to avoid adding large string constants into their
.class
files and runtime images. Developers still have meaningful labels in their
code (e.g. DimensionMismatch
) through a set of constants defined in Keys
inner classes, with the side-effect of compile-time safety. Because integer constants are
inlined right into class files at compile time, the declarative classes is never loaded at
run time.
This class also provides facilities for string formatting using MessageFormat
.
Defined in the sis-utility module
ResourceBundle.Control
parent
Modifier | Constructor and Description |
---|---|
protected |
IndexedResourceBundle(URL resources)
Constructs a new resource bundle loading data from the given UTF file.
|
Modifier and Type | Method and Description |
---|---|
protected static <T extends IndexedResourceBundle> |
getBundle(Class<T> base,
Locale locale)
Returns a resource bundle of the specified class.
|
Enumeration<String> |
getKeys()
Returns an enumeration of the keys.
|
String |
getLabel(int key)
Gets a string for the given key and appends ": " to it.
|
LogRecord |
getLogRecord(Level level,
int key)
Gets a localized log record.
|
LogRecord |
getLogRecord(Level level,
int key,
Object arg0)
Gets a localized log record.
|
LogRecord |
getLogRecord(Level level,
int key,
Object arg0,
Object arg1)
Gets a localized log record.
|
LogRecord |
getLogRecord(Level level,
int key,
Object arg0,
Object arg1,
Object arg2)
Gets a localized log record.
|
LogRecord |
getLogRecord(Level level,
int key,
Object arg0,
Object arg1,
Object arg2,
Object arg3)
Gets a localized log record.
|
String |
getMenuLabel(int key)
Gets a string for the given key and appends "…" to it.
|
String |
getString(int key)
Gets a string for the given key from this resource bundle or one of its parents.
|
String |
getString(int key,
Object arg0)
Gets a string for the given key and formats it with the specified argument.
|
String |
getString(int key,
Object arg0,
Object arg1)
Gets a string for the given key and replaces all occurrences of "{0}",
"{1}", with values of
arg0 , arg1 , etc. |
String |
getString(int key,
Object arg0,
Object arg1,
Object arg2)
Gets a string for the given key and replaces all occurrences of "{0}",
"{1}", with values of
arg0 , arg1 , etc. |
String |
getString(int key,
Object arg0,
Object arg1,
Object arg2,
Object arg3)
Gets a string for the given key and replaces all occurrences of "{0}",
"{1}", with values of
arg0 , arg1 , etc. |
String |
getString(int key,
Object arg0,
Object arg1,
Object arg2,
Object arg3,
Object arg4)
Gets a string for the given key and replaces all occurrences of "{0}",
"{1}", with values of
arg0 , arg1 , etc. |
protected Object |
handleGetObject(String key)
Gets an object for the given key from this resource bundle.
|
void |
list(Appendable out)
Lists resources to the specified stream.
|
String |
toString()
Returns a string representation of this object.
|
clearCache, clearCache, containsKey, getBundle, getBundle, getBundle, getBundle, getBundle, getBundle, getLocale, getObject, getString, getStringArray, handleKeySet, keySet, setParent
protected IndexedResourceBundle(URL resources)
resources
- The path of the binary file containing resources, or null
if
there is no resources. The resources may be a file or an entry in a JAR file.protected static <T extends IndexedResourceBundle> T getBundle(Class<T> base, Locale locale) throws MissingResourceException
T
- The resource bundle class.base
- The resource bundle class.locale
- The locale, or null
for the default locale.MissingResourceException
- if resources can't be found.Vocabulary.getResources(Locale)
,
Errors.getResources(Locale)
public final Enumeration<String> getKeys()
getKeys
in class ResourceBundle
@Debug public final void list(Appendable out) throws IOException
out
- The destination stream.IOException
- if an output operation failed.protected final Object handleGetObject(String key)
handleGetObject
in class ResourceBundle
key
- the key for the desired objectNullPointerException
- if key
is null
public final String getMenuLabel(int key) throws MissingResourceException
key
- The key for the desired string.MissingResourceException
- If no object for the given key can be found.public final String getLabel(int key) throws MissingResourceException
key
- The key for the desired string.MissingResourceException
- If no object for the given key can be found.public final String getString(int key) throws MissingResourceException
key
- The key for the desired string.MissingResourceException
- If no object for the given key can be found.public final String getString(int key, Object arg0) throws MissingResourceException
MessageFormat
. Calling this method is approximately equivalent to
calling:
IfString pattern = getString(key); Format f = new MessageFormat(pattern); return f.format(arg0);
arg0
is not already an array, it will be placed into an array of length 1. Using
MessageFormat
, all occurrences of "{0}", "{1}", "{2}" in the resource string will be
replaced by arg0[0]
, arg0[1]
, arg0[2]
, etc.key
- The key for the desired string.arg0
- A single object or an array of objects to be formatted and substituted.MissingResourceException
- If no object for the given key can be found.ResourceBundle.getString(String)
,
getString(int,Object,Object)
,
getString(int,Object,Object,Object)
,
MessageFormat
public final String getString(int key, Object arg0, Object arg1) throws MissingResourceException
arg0
, arg1
, etc.key
- The key for the desired string.arg0
- Value to substitute for "{0}".arg1
- Value to substitute for "{1}".MissingResourceException
- If no object for the given key can be found.public final String getString(int key, Object arg0, Object arg1, Object arg2) throws MissingResourceException
arg0
, arg1
, etc.key
- The key for the desired string.arg0
- Value to substitute for "{0}".arg1
- Value to substitute for "{1}".arg2
- Value to substitute for "{2}".MissingResourceException
- If no object for the given key can be found.public final String getString(int key, Object arg0, Object arg1, Object arg2, Object arg3) throws MissingResourceException
arg0
, arg1
, etc.key
- The key for the desired string.arg0
- Value to substitute for "{0}".arg1
- Value to substitute for "{1}".arg2
- Value to substitute for "{2}".arg3
- Value to substitute for "{3}".MissingResourceException
- If no object for the given key can be found.public final String getString(int key, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4) throws MissingResourceException
arg0
, arg1
, etc.key
- The key for the desired string.arg0
- Value to substitute for "{0}".arg1
- Value to substitute for "{1}".arg2
- Value to substitute for "{2}".arg3
- Value to substitute for "{3}".arg4
- Value to substitute for "{4}".MissingResourceException
- If no object for the given key can be found.public final LogRecord getLogRecord(Level level, int key)
level
- The log record level.key
- The resource key.public final LogRecord getLogRecord(Level level, int key, Object arg0)
level
- The log record level.key
- The resource key.arg0
- The parameter for the log message, which may be an array.public final LogRecord getLogRecord(Level level, int key, Object arg0, Object arg1)
level
- The log record level.key
- The resource key.arg0
- The first parameter.arg1
- The second parameter.public final LogRecord getLogRecord(Level level, int key, Object arg0, Object arg1, Object arg2)
level
- The log record level.key
- The resource key.arg0
- The first parameter.arg1
- The second parameter.arg2
- The third parameter.public final LogRecord getLogRecord(Level level, int key, Object arg0, Object arg1, Object arg2, Object arg3)
level
- The log record level.key
- The resource key.arg0
- The first parameter.arg1
- The second parameter.arg2
- The third parameter.arg3
- The fourth parameter.Copyright © 2010–2013 The Apache Software Foundation. All rights reserved.