|
ehsbe CommonsTM Version 1.1.0rc3 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ehsbe.commons.util.Message
public class Message
Utility to format i18n messages. It is just a wrapper around MessageFormat.
| Constructor Summary | |
|---|---|
Message()
|
|
| Method Summary | |
|---|---|
static String |
format(Locale locale,
String msg,
Object... args)
Actually the same as MessageFormat.format(String, Object[]),
however, arguments are first checked to be not null and
format exceptions are caught and logged as an error message prefixed
with the string 'Software bug: '. |
static String |
format(ResourceBundle bundle,
String key,
Object... args)
Lookup the specified key in the specified resource bundle and if a string value was found, format this string with the given arguments. |
static String |
format(String msg,
Object... args)
Actually the same as MessageFormat.format(String, Object[]),
however, arguments are first checked to be not null and
format exceptions are caught and logged as an error message prefixed
with the string 'Software bug: '. |
static String |
formatSilent(ResourceBundle bundle,
String key,
Object... args)
Same as format(ResourceBundle, String, Object[]), however, if
the property with the given key could not be found, no warning occurs
and null is returned immediately. |
static char |
getMnemonic(ResourceBundle bundle,
String key)
Get the mnemonic character for the given |
static String |
getValue(ResourceBundle bundle,
String key)
Get a certain (unformatted) message for the specified key from the specified resource bundle. |
static String |
getValue(ResourceBundle bundle,
String key,
String defaultValue)
Get a certain (unformatted) message for the specified key from the specified resource bundle. |
static String |
getValueSilent(ResourceBundle bundle,
String key)
Get a unformatted message for the specified key from the specified resource bundle. |
static String |
getValueSilent(ResourceBundle bundle,
String key,
String defaultValue)
Get a unformatted message for the specified key from the specified resource bundle. |
static ResourceBundle |
loadResBundle(Object o,
String file,
Locale locale)
Load a language specific resource bundle wrt. to the given object. |
static ResourceBundle |
loadResBundle(Object o,
String file,
String language)
Load a language specific resource bundle wrt. to the given object. |
static ResourceBundle |
loadResBundle(String path,
Locale locale)
load a language specific resource bundle. |
static ResourceBundle |
loadResBundle(String path,
String language)
load a language specific resource bundle. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Message()
| Method Detail |
|---|
public static char getMnemonic(ResourceBundle bundle,
String key)
bundle - bundle to use for lookupkey - key to use. _MN will be append before the lookup starts.
0 if not found, the mnemonic character otherwise.
public static String getValue(ResourceBundle bundle,
String key)
bundle - the lookup sourcekey - the key to lookup
null or could not be found in the specified
bundle or if the object found for the given key is not
a string (in this case an error message with the prefix
'Software bug;' is logged), the unformatted message string
otherwise.
public static String getValue(ResourceBundle bundle,
String key,
String defaultValue)
bundle - the lookup sourcekey - the key to lookupdefaultValue - the value to return, if the lookup fails.
null or could not be found in the specified
bundle or if the object found for the given key is not
a string (in this case an error message with the prefix
'Software bug;' is logged), the unformatted message string
otherwise.
public static String getValueSilent(ResourceBundle bundle,
String key)
null, this fact is silently ignored and null
will be returned.
bundle - the lookup sourcekey - the key to lookup
null if the key was not found, the value for the
given key otherwise.
public static String getValueSilent(ResourceBundle bundle,
String key,
String defaultValue)
null, this fact is silently ignored and the defaultValue
will be returned.
bundle - the lookup sourcekey - the key to lookupdefaultValue - the value to return, if the lookup fails.
public static String format(ResourceBundle bundle,
String key,
Object... args)
If no arguments are given, the unformatted value is returned.
bundle - source for the key lookupkey - the key to lookupargs - arguments to use for formatting the found value for key
null if the bundle does not contain a
key with a propper value or if an error ocurred when
formatting the found value, the formatted message otherwise.getValue(ResourceBundle, String),
format(String, Object[])
public static String formatSilent(ResourceBundle bundle,
String key,
Object... args)
format(ResourceBundle, String, Object[]), however, if
the property with the given key could not be found, no warning occurs
and null is returned immediately.
bundle - bundle to use for lookupkey - key to use for lookupargs - values to pass to format the key value
null if the bundle is null or a pair with the given
key could not be found, the formatted key otherwise.
public static String format(String msg,
Object... args)
MessageFormat.format(String, Object[]),
however, arguments are first checked to be not null and
format exceptions are caught and logged as an error message prefixed
with the string 'Software bug: '.
msg - the unformatted messageargs - arguments to be used for message formatting
null, if msg or args is
null or an error occurred during message formatting,
the formatted message otherwise.MessageFormat.format(String, Object[])
public static String format(Locale locale,
String msg,
Object... args)
MessageFormat.format(String, Object[]),
however, arguments are first checked to be not null and
format exceptions are caught and logged as an error message prefixed
with the string 'Software bug: '.
locale - locale to use for formatmsg - the unformatted messageargs - arguments to be used for message formatting
null, if msg or args is
null or an error occurred during message formatting,
the formatted message otherwise.MessageFormat.format(String, Object[])
public static ResourceBundle loadResBundle(String path,
Locale locale)
path - resource path to th bundle (e.g. com/ims/misc/laber
tries to load com/ims/misc/laber.properties)locale - locale to use. If null or
empty, en locale is used as fallback.
true if a new, other than the current used Locale
was set, false otherwise
MissingResourceException - if the resource can not be found
public static ResourceBundle loadResBundle(String path,
String language)
path - resource path to th bundle (e.g. com/ims/misc/laber
tries to load com/ims/misc/laber.properties)language - the ISO 639 language code. if null or
empty, en is used as fallback.
true if a new, other than the current used Locale
was set, false otherwise
MissingResourceException - if the resource can not be found
public static ResourceBundle loadResBundle(Object o,
String file,
String language)
loadResBundle(String, String)
gets called.
o - object to use for package name determinationfile - a resource file name (without the language and
properties extension)language - language of the bundle to get
public static ResourceBundle loadResBundle(Object o,
String file,
Locale locale)
loadResBundle(String, String)
gets called.
o - object to use for package name determinationfile - a resource file name (without the language and
properties extension)locale - locale of the bundle to get
|
ehsbe CommonsTM Version 1.1.0rc3 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||