public class I18NMessageProvider extends Object implements Serializable
I18NMessage onto text. The locale used for the translation is
either one supplied at the time of translation, or the active
locale per ActiveLocale; if the chosen locale does not
provide a message, the default JVM locale and root locale (in that
order) are used as fallbacks.
Message providers can be serialized. However, upon deserialization, they are not guaranteed to have the same classloader as during serialization, and hence may be unable to access the same message files as were available during serialization. If this happens, deserialization will fail.
| Modifier and Type | Field and Description |
|---|---|
static String |
MESSAGE_FILE_EXTENSION
The string added to the end of the provider ID to obtain the
stream resource (file) containing the message mappings.
|
| Constructor and Description |
|---|
I18NMessageProvider(String providerId)
Creates a new message provider with the given ID.
|
I18NMessageProvider(String providerId,
ClassLoader classLoader)
Creates a new message provider with the given ID.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object other) |
String |
getProviderId()
Returns the receiver's provider ID.
|
String |
getText(I18NMessage message,
Object... params)
Returns the text of the given message in the active locale per
ActiveLocale. |
String |
getText(Locale locale,
I18NMessage message,
Object... params)
Returns the text of the given message in the given locale,
using the receiver's map.
|
int |
hashCode() |
public static final String MESSAGE_FILE_EXTENSION
public I18NMessageProvider(String providerId, ClassLoader classLoader)
MESSAGE_FILE_EXTENSION
to form the name of a mapping file. The file should be
retrievable as a resource via the given class loader, and its
format should be that used by Apache Commons i18n.providerId - The provider ID.classLoader - The class loader used to load the mapping
file. It may be null to use the default classloader.public I18NMessageProvider(String providerId)
MESSAGE_FILE_EXTENSION
to form the name of a mapping file. The file should be
retrievable as a resource via the default class loader, and its
format should be that used by Apache Commons i18n.providerId - The provider ID.public String getProviderId()
public String getText(Locale locale, I18NMessage message, Object... params)
locale - The locale.message - The message.params - The message parameters.public String getText(I18NMessage message, Object... params)
ActiveLocale. The given parameters are used to
instantiate parameterized messages.message - The message.params - The message parameters.Copyright © 2015. All Rights Reserved.