public class I18nItem extends Object
The basic internationalized message storage and formatting class in the hierarchy; not intended to be used or subclassed by applications directly.
See package info for a usage example.
Modifier and Type | Field and Description |
---|---|
protected LinkedHashMap<String,String> |
messages
The main storage of presentations of the same message for different
locales.
|
Constructor and Description |
---|
I18nItem(LocalizedMessage... data)
The public constructor.
|
Modifier and Type | Method and Description |
---|---|
String |
getBestLanguage()
Similar to
getBestLocaleTag() , but returns just the language
field for the locale found. |
protected LocalizedMessage |
getBestLocaleAndMessage()
A utility method to find both the best locale suitable for given user for
given
I18nItem instance, and the appropriate message, all
represented as a LocalizedMessage instance. |
String |
getBestLocaleTag()
Find the best match, exact or approximate, among locales available for
this item, for current user.
|
protected MessageFormat |
obtainMessageFormat()
The method to obtain a localized
MessageFormat instance to be
used by subclasses that take message formatting arguments. |
protected LinkedHashMap<String,String> messages
MessageFormat
style.public I18nItem(LocalizedMessage... data)
data
- a varargs array of translations for a message to various
localespublic String getBestLocaleTag() throws NoSuchElementException
locale language tag
NoSuchElementException
- should this instance happen to be emptypublic String getBestLanguage() throws NoSuchElementException
getBestLocaleTag()
, but returns just the language
field for the locale found. The method is not used internally and is
exposed as public for cases when an application needs just information
about best appropriate language.NoSuchElementException
- should this instance happen to be emptyprotected LocalizedMessage getBestLocaleAndMessage()
I18nItem
instance, and the appropriate message, all
represented as a LocalizedMessage
instance.LocalizedMessage
instance for the best locale guessprotected MessageFormat obtainMessageFormat()
MessageFormat
instance to be
used by subclasses that take message formatting arguments.MessageFormat
instance