|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.ras.RASMessageCatalog
The RASMessageCatalog
class is used within the RAS system
to format messages according to the current locale (that is, in the
desired language). The text associated with any RAS message is kept
in a ResourceBundle
. Each message text is associated with a
"key," which is, essentially, a name for the message text.
RASMessageCatalog
formats the message text using a
java.text.MessageFormat
object. One way to define the
messages is through a PropertyResourceBundle
file, backed
up by a Properties
file. Here is a sample:
# {0} is the name of a file. # {1} is the detailed message created when the file creation error # occurred ERR_FILE_WRITER=Unable to create a FileWriter for {0}: {1} # {0} is a text string naming the missing message key. ERR_MISSING_KEY=Message key {0} was not found in any searched catalog. ERR_SOCKET=Unable to connect to the RAS Log Server.To create a message catalog, pass it the base name of the resource bundle. For example, if your base file was
com.ibm.ras.RASMsgs.properties
you would code:
RASMessageCatalog msgCat = new RASMessageCatalog("com.ibm.ras.RASMsgs");Use the
RASMessageCatalog.getMessage()
methods to retrieve
the message text in the desired locale. Java will look for the proper
translation of this file according to the supplied or default locale.
For example, it might first search for
RASMsgs_en_GB.properties
, then RASMsgs_en.properties
and, finally RASMsgs.properties
.
It is not necessary for an application to create a
RASMessageCatalog
. This class is used only by the
RASMessageFormatter
to format a message text in the desired
language.
RASMessageFormatter
Constructor Summary | |
RASMessageCatalog(java.util.ResourceBundle bundle)
Creates a RASMessageCatalog using the default locale. |
|
RASMessageCatalog(java.util.ResourceBundle bundle,
java.util.Locale loc)
Creates a RASMessageCatalog . |
|
RASMessageCatalog(java.lang.String baseName)
Creates a RASMessageCatalog using the default locale. |
|
RASMessageCatalog(java.lang.String baseName,
java.util.Locale loc)
Creates a RASMessageCatalog . |
Method Summary | |
java.util.Locale |
getLocale()
Gets the locale used by the RASMessageCatalog . |
java.lang.String |
getMessage(java.lang.String key)
Gets a message with no inserts from the catalog. |
java.lang.String |
getMessage(java.lang.String key,
java.lang.Object insert1)
Gets a message with one insert from the catalog. |
java.lang.String |
getMessage(java.lang.String key,
java.lang.Object[] inserts)
Gets a message with an array of inserts from the catalog. |
java.lang.String |
getMessage(java.lang.String key,
java.lang.Object insert1,
java.lang.Object insert2)
Gets a message with two inserts from the catalog. |
void |
setLocale(java.util.Locale loc)
Sets the locale to be used by the RASMessageCatalog . |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public RASMessageCatalog(java.lang.String baseName) throws java.util.MissingResourceException
RASMessageCatalog
using the default locale.baseName
- The base name of the ResourceBundle
which contains the messages.ResourceBundle
cannot be loaded.public RASMessageCatalog(java.util.ResourceBundle bundle)
RASMessageCatalog
using the default locale.bundle
- The ResourceBundle
which contains
the messages.public RASMessageCatalog(java.lang.String baseName, java.util.Locale loc) throws java.util.MissingResourceException
RASMessageCatalog
.baseName
- The base name of the ResourceBundle
which contains the messages.loc
- The locale with which the messages should be
displayed.ResourceBundle
cannot be loaded.public RASMessageCatalog(java.util.ResourceBundle bundle, java.util.Locale loc)
RASMessageCatalog
.bundle
- The ResourceBundle
which contains
the messages.loc
- The locale with which the messages should be
displayed.Method Detail |
public java.util.Locale getLocale()
RASMessageCatalog
.Locale.getDefault
is returned.public void setLocale(java.util.Locale loc)
RASMessageCatalog
.loc
- The new locale. If this locale is null
,
the default locale is used.public java.lang.String getMessage(java.lang.String key) throws java.util.MissingResourceException
key
- The key name of this message.public java.lang.String getMessage(java.lang.String key, java.lang.Object insert1) throws java.util.MissingResourceException
key
- The key name of this message.insert1
- An element to be inserted into the message.public java.lang.String getMessage(java.lang.String key, java.lang.Object insert1, java.lang.Object insert2) throws java.util.MissingResourceException
key
- The key name of this message.insert1
- An element to be inserted into the message.insert2
- An element to be inserted into the message.public java.lang.String getMessage(java.lang.String key, java.lang.Object[] inserts) throws java.util.MissingResourceException
key
- The key name of this message.inserts
- An array of elements to be inserted into the message.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |