public final class MessageTranslator
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DFLT_RESOURCE_NAME
The default base name of the resource bundle from which message
descriptions are read.
|
Constructor and Description |
---|
MessageTranslator()
This is a singleton class; to get an instance of this class, use
the getInstance method.
|
Modifier and Type | Method and Description |
---|---|
void |
checkComplete(java.util.Collection messages)
Verify that the resource bundle for the currently set locale has
a translation string available for every message object in the provided
collection.
|
java.lang.String |
getDesc(Message msg)
Given a Message object (containing a unique message id), look up
that id in the appropriate resource bundle (properties file) for
the set locale and return the text string associated with that
message id.
|
void |
setLocale(java.util.Locale locale)
Define the local language etc.
|
void |
setResourceName(java.lang.String resourceName)
Define the base name of the properties file that message
translations are to be read from.
|
public static final java.lang.String DFLT_RESOURCE_NAME
public MessageTranslator()
public void setLocale(java.util.Locale locale)
locale
- may be a valid Locale object, or null to indicate
that the default locale is to be used.public void setResourceName(java.lang.String resourceName)
public void checkComplete(java.util.Collection messages)
java.util.MissingResourceException
- if there is a registered
message for which no description is present in the current locale's
resources.public java.lang.String getDesc(Message msg)
Message ids in the properties file should be prefixed with an 'm', eg "m1000", "m5003".
java.util.MissingResourceException
- if there is no entry in the
message translation resource bundle for the specified message.Copyright © 2003-2012 Lars K??hne. All Rights Reserved.