|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.tivoli.jflt.LogCatalogSupport
It provides an implemenation of the LogCatalog
interface.
LogCatalogSupport
formats messages for the Java Flexible Logging
Toolkit according to the current locale.
One way to define the messages is through a PropertyResourceBundle
file, backed up by a Properties file. See the following example:
# {0} is the name of a file.
# {1} is the detailed error message created when the file is open
ERR_FILE_OPEN=Unable to open file {0}: {1}
To configure a message catalog, pass it the base name of the resource bundle.
For example, if your base file was com.mycompany.Msgs.properties
you would write:
LogCatalog catalog = new LogCatalogSupport();
catalog.setMessageCatalog("com.mycompany.Msgs");
Constructor Summary | |
LogCatalogSupport()
Creates a LogCatalog . |
Method Summary | |
java.lang.String |
formatMessage(java.lang.String msg,
java.lang.Object[] aobj)
Formats a message by inserting an array of run-time objects into a pattern, according to the rules of the java.util.MessageFormat
class. |
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 obj)
Gets a message with one insert from the catalog. |
java.lang.String |
getMessage(java.lang.String key,
java.lang.Object[] objects)
Gets a message with an array of inserts from the catalog. |
java.lang.String |
getMessage(java.lang.String key,
java.lang.Object obj1,
java.lang.Object obj2)
Gets a message with two inserts from the catalog. |
java.lang.String |
getMessageCatalog()
Gets the message catalog name. |
void |
setMessageCatalog(java.lang.String file)
Sets the message catalog name for this catalog. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public LogCatalogSupport()
LogCatalog
.Method Detail |
public void setMessageCatalog(java.lang.String file)
file
- The base name of the ResourceBundle
which contains
the messages. If null
, the current value is not changed.public java.lang.String getMessageCatalog()
public java.lang.String getMessage(java.lang.String key)
key
- The key name of this messagepublic java.lang.String getMessage(java.lang.String key, java.lang.Object obj)
key
- The key name of this messageobj
- An element to be inserted into the messagepublic java.lang.String getMessage(java.lang.String key, java.lang.Object obj1, java.lang.Object obj2)
key
- The key name of this messageobj1
- An element to be inserted into the messageobj2
- An element to be inserted into the messagepublic java.lang.String getMessage(java.lang.String key, java.lang.Object[] objects)
key
- The key name of this messageobjects
- An array of elements to be inserted into the messagepublic java.lang.String formatMessage(java.lang.String msg, java.lang.Object[] aobj)
java.util.MessageFormat
class.
The following code shows an example on how to use this method:
LogCatalogSupport catalog = new LogCatalogSupport(MyResourceBundle);
String my_msg = catalog.formatMessage("My name is {0}.", "Mimmo");
msg
- The message pattern.aobj
- 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 |