java.lang.Objectucot.Messages
public class Messages
This class contains interface to the localised message strings.
Strings are readed using ResourceBundle that uses ucot/message.properties file (or its localized version).
Field Summary | |
---|---|
private static java.lang.String |
BUNDLE_NAME
|
private static java.util.ResourceBundle |
RESOURCE_BUNDLE
|
Constructor Summary | |
---|---|
Messages()
|
Method Summary | |
---|---|
static java.lang.String |
formatMessage(java.lang.String messageString,
java.lang.Object... args)
Method formats messages with parameters to user readable format. |
static java.lang.String |
getFormatedMessage(java.lang.String key,
java.lang.Object... args)
Gets string localized string and format the arguments using it. |
static java.lang.String |
getString(java.lang.String key)
Returns localized string for the given key. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final java.lang.String BUNDLE_NAME
private static final java.util.ResourceBundle RESOURCE_BUNDLE
Constructor Detail |
---|
public Messages()
Method Detail |
---|
public static java.lang.String getString(java.lang.String key)
Returns localized string for the given key. If no string is found then !key! is returned (where key is the key-string that was given as parameter)
getString("FILE_NOT_FOUND"); would return some string definded for example in properties file or string "!FILE_NOT_FOUND!" if no matching key is located.
key
- Key for the string required.
public static java.lang.String formatMessage(java.lang.String messageString, java.lang.Object... args)
Method formats messages with parameters to user readable format. MessageString is normal string that marks the places for the dynamic information with {}-marks and number in between them.
For example: formatMessage("File {0} not found.", new File("file.txt")); would return string: "File file.txt not found.".
To use with getString method you can do like this: System.out.println(formatMessage(getString("FILE_NOT_FOUND"), new File("file.txt")));. If there is property file that contains line: FILE_NOT_FOUND=File {0} not found. then it would return the same string: "File file.txt not found.".
messageString
- Message format string.args
- Arguments for the string.
public static java.lang.String getFormatedMessage(java.lang.String key, java.lang.Object... args)
Gets string localized string and format the arguments using it.
formatMessage(String, Object[])
,
getString(String)