|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectwt.util.WTMessage
public class WTMessage
WTMessage is the wrapper class for getting a formatted,
localized message, from a resource bundle.
The following are examples of how WTMessage would be used:
Static usage:
Object[] textInserts = { getName() };
System.out.println(
WTMessage.getLocalizedMessage( RESOURCE, "17", textInserts )
);
Instance usage:
Object[] textInserts = { getName() };
WTMessage wtMessage = new WTMessage( RESOURCE, "17", textInserts
);
// ... other stuff
wtMessage.getLocalizedMessage();
Localization of the WTMessage messages relies on the resource
bundle and text formatting features of Java.
In the example above, RESOURCE is a string constant that
identifies the resource bundle containing the localizable message.
Objects that act as text insert parameters of the message will make use
of the
getLocalizedMessage(Locale) method, if those insert objects
implement the wt.util.LocalizableMessage interface. This
enables the message inserts to be localized, along with the message itself,
at the time the localized message is requested.
Supported API: true
Extendable: false
ResourceBundle,
MessageFormat,
LocalizableMessage.getLocalizedMessage(java.util.Locale),
Serialized Form| Constructor Summary | |
|---|---|
WTMessage(String rb,
String key,
Object[] params)
Constructs a Windchill message with a localizable detailed message. |
|
| Method Summary | |
|---|---|
static String |
formatLocalizedMessage(String localizedString,
Object[] inserts)
This method will process an already localized string by escaping any appropriate characters, and then call java.text.MessageFormat on the String to properly insert any inserts. |
String |
getLocalizedMessage()
Gets the localized message, for the instance. |
String |
getLocalizedMessage(Locale locale)
Obtain a message, localized to the specified locale. |
static String |
getLocalizedMessage(String resourceBundle,
String messageKey,
Object[] textInserts)
Gets the localized message, for passed arguments. |
static String |
getLocalizedMessage(String resourceBundle,
String messageKey,
Object[] textInserts,
Locale locale)
Gets the localized message, for passed arguments. |
String |
getMessageIdentifier()
Gets the identity of the message. |
static WTMessage[] |
getMessages(String rb,
String key,
Object[] params)
Loops over the arrayed elements of params to generate multiple WTMessages, one for each element. |
String |
toString()
Returns the localized message, for the instance. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public WTMessage(String rb,
String key,
Object[] params)
Param objects of type wt.util.LocalizableMessage will be expanded
by invoking getLocalizedMessage(Locale) on them.
Supported API: true
rb - the name of the base resource bundle subclass containing the localizable message.key - the key associated with the localizable messageparams - an optional set of objects to be formatted into the localizable message text.ResourceBundle,
MessageFormat,
LocalizableMessage.getLocalizedMessage(java.util.Locale)| Method Detail |
|---|
public String getLocalizedMessage(Locale locale)
getLocalizedMessage in interface LocalizableMessagelocale -
public static WTMessage[] getMessages(String rb,
String key,
Object[] params)
Param objects of type wt.util.LocalizableMessage will be expanded
by invoking getLocalizedMessage(Locale) on them.
Supported API: true
rb - the name of the base resource bundle subclass containing the localizable message.key - the key associated with the localizable messageparams - an optional set of objects to be formatted into the localizable message text.
If an element of params is itself an array, loop over those elements to produce
multiple WTMessages, one for each element.params - an optional set of objects to be formatted into the localizable message text.ResourceBundle,
MessageFormat,
LocalizableMessage.getLocalizedMessage(java.util.Locale)public String getLocalizedMessage()
ResourceBundle,
MessageFormat
public static String getLocalizedMessage(String resourceBundle,
String messageKey,
Object[] textInserts)
Param objects of type wt.util.LocalizableMessage will be expanded
by invoking getLocalizedMessage(Locale) on them.
Supported API: true
rb - the name of the base resource bundle subclass containing the localizable message.key - the key associated with the localizable messageparams - an optional set of objects to be formatted into the localizable message text.ResourceBundle,
MessageFormat,
LocalizableMessage.getLocalizedMessage(java.util.Locale)
public static String formatLocalizedMessage(String localizedString,
Object[] inserts)
getLocalizedMessage( ) should be used, since this allows
for caching of resources etc. However in some cases, to avoid rewriting
major pieces of code, MessageFormat.format( ) can be directly replaced
with WTMessage.formatLocalizedMessage( )
localizedString - The localized String to formatinserts - The inserts to insert via the MessageFormat
public static String getLocalizedMessage(String resourceBundle,
String messageKey,
Object[] textInserts,
Locale locale)
Param objects of type wt.util.LocalizableMessage will be expanded
by invoking getLocalizedMessage(Locale) on them.
Implementation Notes: Any usage of "{" or "}" characters in which there
are intended to be used as "{" or "}" (and not inset delimiters) should be enclosed
in "'" (apostrophes). For example, if you would like to have a String
"My name in curly brackets {developer}""My name in curly brackets '{'developer'}'"
rb - the name of the base resource bundle subclass containing the localizable message.key - the key associated with the localizable messageparams - an optional set of objects to be formatted into the localizable message text.locale - the locale for which to get the localized message.ResourceBundle,
MessageFormat,
LocalizableMessage.getLocalizedMessage(java.util.Locale)public String getMessageIdentifier()
public String toString()
toString in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||