Retrieves messages from a message {@link java.util.ResourceBundle} and formats them as appropriate using{@link java.text.MessageFormat}. Instances of this object are mostly read-only - the only thing you can change is the locale. Changing the locale will attempt to convert the message to that new locale's format.
I18N Msg
objects are serializable and will be re-translated once it is deserialized. This means that a message could be localized in the English language, serialized and sent over the wire to another JVM with a German locale and when the deserialized message is retrieved again, it will be in German. This feature assumes a resource bundle with the same base bundle name exists in the JVM that deserialized the Msg
. If it does not, then the original message will be used (in the previous example, it would mean the English message would be retrieved in the JVM, even though its locale is German).
There is a method to the madness to some of the methods' parameter ordering. Anytime you want to specify a localized message, you always specify the base bundle name first, followed by the locale, the bundle key and the variable list of arguments that go with the keyed message (all in that order). Bundle name and locale are both optional. This is consistent with the way localized messages are specified in constructors for {@link LocalizedException} and {@link LocalizedRuntimeException}. When you need to specify a Throwable
with your localized message, it is specified before those parameters. Again, this is consistent both in this class and the localized exception classes (see {@link #createMsg(com.sos.i18n.Msg.BundleBaseName,Locale,String,Object[])} and{@link LocalizedException#LocalizedException(Throwable,com.sos.i18n.Msg.BundleBaseName,Locale,String,Object[])}as examples).
@author
John Mazzitelli
@version $Revision: 1.3 $
@see LocalizedException
@see LocalizedRuntimeException