kiwi.util
Class LocaleData
java.lang.Object
|
+--java.util.ResourceBundle
|
+--java.util.PropertyResourceBundle
|
+--kiwi.util.LocaleData
- public class LocaleData
- extends java.util.PropertyResourceBundle
A specialization of PropertyResourceBundle
that adds some
convenience methods.
- Author:
- Mark Lindner, PING Software Group
Fields inherited from class java.util.PropertyResourceBundle |
lookup |
Fields inherited from class java.util.ResourceBundle |
CACHE_LOAD_FACTOR, cacheKey, cacheList, DEFAULT_NOT_FOUND, INITIAL_CACHE_SIZE, locale, MAX_BUNDLES_SEARCHED, parent, underConstruction |
Constructor Summary |
LocaleData(java.io.InputStream instream)
Construct a new LocaleData object from the given input
stream. |
Method Summary |
java.lang.String |
getMessage(java.lang.String key)
Get a message for the specified key. |
java.lang.String |
getMessage(java.lang.String key,
java.lang.Object arg)
Get a message for the specified key, and format the message, substituting
the specified argument for the message's first placeholder. |
java.lang.String |
getMessage(java.lang.String key,
java.lang.Object[] args)
Get a message for the specified key, and format the message, substituting
the specified arguments for the message's placeholders. |
java.lang.String[] |
getMessageList(java.lang.String key)
Get a message list for the specified key. |
java.lang.String[] |
getMessageList(java.lang.String key,
java.lang.String delimiter)
Get a message list for the specified key. |
boolean |
isMessageDefined(java.lang.String key)
Determine if a message is defined for the specified key. |
Methods inherited from class java.util.PropertyResourceBundle |
getKeys, handleGetObject |
Methods inherited from class java.util.ResourceBundle |
, calculateBundleNames, cleanUpConstructionList, findBundle, findBundleInCache, getBundle, getBundle, getBundle, getBundleImpl, getClassContext, getLoader, getLocale, getObject, getString, getStringArray, loadBundle, propagate, putBundleInCache, setLocale, setParent, throwMissingResourceException |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait |
DEFAULT_DELIMITER
public static final java.lang.String DEFAULT_DELIMITER
- The default message list delimiter.
unitArray
private final java.lang.Object[] unitArray
LocaleData
public LocaleData(java.io.InputStream instream)
throws java.io.IOException
- Construct a new
LocaleData
object from the given input
stream.
- Parameters:
instream
- The stream to read the data from.- Throws:
java.io.IOException
- If an error occurred while reading from
the stream.
getMessage
public java.lang.String getMessage(java.lang.String key)
throws java.util.MissingResourceException
- Get a message for the specified key.
- Parameters:
key
- The key.- Returns:
- A message for the specified key.
- Throws:
java.util.MissingResourceException
- If the specified key was not
found.
getMessage
public java.lang.String getMessage(java.lang.String key,
java.lang.Object[] args)
- Get a message for the specified key, and format the message, substituting
the specified arguments for the message's placeholders. Messages may have
placeholders of the form {n}, where n is a non-negative integer. For
example, the message "My name is {0}, and I am {1} years old."
and argument list
{ "Joe", new Integer(12) }
would be
formatted as My name is Joe, and I am 12 years old.
- Parameters:
key
- The key.args
- An array of arguments for the message.- Returns:
- A fromatted message for the specified key.
- Throws:
java.util.MissingResourceException
- If the specified key was not
found.
getMessage
public java.lang.String getMessage(java.lang.String key,
java.lang.Object arg)
- Get a message for the specified key, and format the message, substituting
the specified argument for the message's first placeholder. Messages may
have* placeholders of the form {n}, where n is a non-negative integer. For
example, the message "My name is {0}" and argument
"Joe"
would be formatted as My name is Joe.
- Parameters:
key
- The key.args
- An array of arguments for the message.- Returns:
- A fromatted message for the specified key.
- Throws:
java.util.MissingResourceException
- If the specified key was not
found.
getMessageList
public java.lang.String[] getMessageList(java.lang.String key)
throws java.util.MissingResourceException
- Get a message list for the specified key. Retrieves a message for the
specified key, and breaks the message on the default delimiter (",")
constructing an array in the process.
- Parameters:
key
- The key.- Returns:
- An array of messages for the specified key.
- Throws:
java.util.MissingResourceException
- If the specified key was not
found.
getMessageList
public java.lang.String[] getMessageList(java.lang.String key,
java.lang.String delimiter)
throws java.util.MissingResourceException
- Get a message list for the specified key. Retrieves a message for the
specified key, and breaks the message on the specified delimiter
constructing an array in the process.
- Parameters:
key
- The key.delimiter
- The delimiter to use.- Returns:
- An array of messages for the specified key.
- Throws:
java.util.MissingResourceException
- If the specified key was not
found.
isMessageDefined
public boolean isMessageDefined(java.lang.String key)
- Determine if a message is defined for the specified key.
- Parameters:
key
- The key.- Returns:
- true if the key exists, and false otherwise.