public interface Messages
Interface for i18n message retrieval through a ResourceBundle
and abbreviated formatting using String.format(java.util.Locale, String, Object...)
.
Additionally, this interface supports mapping to plural forms
using a given PluralRule
.
Modifier and Type | Method and Description |
---|---|
String |
formatPluralString(double n,
String key,
Object... args)
Format the given localized message with possible plural forms
with a set of arguments.
|
String |
formatString(String key,
Object... args)
Format the given localized message with a set of arguments.
|
Enumeration<String> |
getKeys() |
Locale |
getLocale() |
PluralRule |
getPluralRule() |
String |
getPluralString(double n,
String key)
Find a localized message with possible plural forms.
|
String |
getString(String key) |
Locale getLocale()
Enumeration<String> getKeys()
PluralRule getPluralRule()
String getString(String key)
key
- The key to search for in the message catalog.NullPointerException
- if key
is null
MissingResourceException
- if no object for the given key can be foundClassCastException
- if the object found for the given key is not a stringString formatString(String key, Object... args)
String.format(i18n.getLocale(),i18n.getString(key),args)
key
- The key to search for in the message catalog.args
- The argument to the format string.NullPointerException
- if key
is null
MissingResourceException
- if no object for the given key can be foundClassCastException
- if the object found for the given key is not a stringString getPluralString(double n, String key)
<key>.<tag>
, if the associated PluralRule
return a non-null plural tag like one
or zero
.
If a message for these special keys is not found or
the plural rule return NullPointerException
, the unmodified key
is used to fetch the message.n
- The plural denominator.key
- The key to search for in the message catalog.NullPointerException
- if key
is null
MissingResourceException
- if no object for the given key can be foundClassCastException
- if the object found for the given key is not a stringString formatPluralString(double n, String key, Object... args)
String.format(i18n.getLocale(),i18n.getPluralString(n,key),args)
n
- The plural denominator.key
- The key to search for in the message catalog.args
- The argument to the format string.NullPointerException
- if key
is null
MissingResourceException
- if no object for the given key can be foundClassCastException
- if the object found for the given key is not a stringCopyright © 2016 Clazzes.org. All rights reserved.