| java.lang.Object net.sf.clirr.core.MessageTranslator
MessageTranslator | final public class MessageTranslator (Code) | | Class which is capable of translating a Message object into a localised
string.
|
Field Summary | |
final public static String | DFLT_RESOURCE_NAME The default base name of the resource bundle from which message
descriptions are read. |
Constructor Summary | |
public | MessageTranslator() This is a singleton class; to get an instance of this class, use
the getInstance method. |
Method Summary | |
public void | checkComplete(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. | public 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. | public void | setLocale(Locale locale) Define the local language etc. | public void | setResourceName(String resourceName) Define the base name of the properties file that message
translations are to be read from. |
DFLT_RESOURCE_NAME | final public static String DFLT_RESOURCE_NAME(Code) | | The default base name of the resource bundle from which message
descriptions are read.
|
MessageTranslator | public MessageTranslator()(Code) | | This is a singleton class; to get an instance of this class, use
the getInstance method.
|
checkComplete | public void checkComplete(Collection messages)(Code) | | Verify that the resource bundle for the currently set locale has
a translation string available for every message object in the provided
collection. This method is expected to be called from the unit tests,
so that if a developer adds a new message the unit tests will fail until
translations are also available for that new message.
throws: java.util.MissingResourceException - if there is a registeredmessage for which no description is present in the current locale'sresources. |
getDesc | public String getDesc(Message msg)(Code) | | 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.
Message ids in the properties file should be prefixed with an 'm',
eg "m1000", "m5003".
throws: java.util.MissingResourceException - if there is no entry in themessage translation resource bundle for the specified message. |
setLocale | public void setLocale(Locale locale)(Code) | | Define the local language etc. Future calls to the getDesc method
will attempt to use a properties file which is appropriate to that
locale to look the message descriptions up in.
Parameters: locale - may be a valid Locale object, or null to indicatethat the default locale is to be used. |
setResourceName | public void setResourceName(String resourceName)(Code) | | Define the base name of the properties file that message
translations are to be read from.
|
|
|