|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.9.0) E52944-01 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
oracle.javatools.resourcebundle.NamedMessageFormat
public class NamedMessageFormat
The NamedMessageFormat class is a greatly reduced version of the java.text.MessageFormat class, supporting named-parameter replacement instead of index-based replacement.
The only syntax supported by this class is simple name-based replacement, namely:
some{first}text{second}here{more-complicated}andthere
as well as escaping using single quotes. However, unlike MessageFormat, the contents of the text between two single quotes is not interpreted only if the first single quote is followed by a left bracket. That is, the following pattern
some'{text'more
will be interpred as:
some{textmore
Otherwise, a standalone single quote will be interpreted as a single quote. Followings are some examples:
Parameters: first = seven, second = ten Unformatted message: They've {first} java tests and we've {second} java tests. Formatted message: They've seven java tests and we've ten java tests.
Parameters: null Unformatted message: Use '''{amount}''' to indicate negative amount Formatted message: Use '{amount}' to indicate negative amount
Parameters: diskname = Mydisk Unformatted message: ''{diskname}'' is full Formatted message: 'Mydisk' is full
The names of the parameters can contain any characters other than single quotes and right braces. Single-quote escaping is also not permitted within keys, so the following is illegal:
some text{fir'{'st}
Constructor Summary | |
---|---|
NamedMessageFormat(java.lang.String formatString) Creates a NamedMessageFormat based on the given format string. |
Method Summary | |
---|---|
java.lang.String |
format(java.util.Map<java.lang.String,java.lang.String> parameters) Formats the given Map of strings based on the initial pattern. |
java.lang.String |
format(java.util.Map<java.lang.String,java.lang.String> parameters, int parameterSize) Formats the given Map of strings based on the initial pattern. |
static java.lang.String |
formatMsg(java.lang.String message, java.util.Map<java.lang.String,java.lang.Object> parameters) Takes the given message and replaces any named tokens in the message with the value from the tokens map. |
static java.lang.String |
formatMsgMixed(java.lang.String message, java.util.Map<java.lang.String,java.lang.Object> formatValues, java.util.Map<java.lang.String,java.lang.Object> noformatValues) /** Takes the given message and replaces any named tokens in the message that are included in the parameters map and replaces them with the value in the parameter map. |
static java.lang.String |
formatMsgPlain(java.lang.String message, java.util.Map<java.lang.String,java.lang.Object> parameters) Takes the given message and replaces any named tokens in the message that are included in the parameters map and replaces them with the value in the parameter map. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public NamedMessageFormat(java.lang.String formatString)
Method Detail |
---|
public java.lang.String format(java.util.Map<java.lang.String,java.lang.String> parameters)
parameters
- a Map of key/value String pairspublic java.lang.String format(java.util.Map<java.lang.String,java.lang.String> parameters, int parameterSize)
parameters
- a Map of key/value String pairsparameterSize
- no longer used, still here for api compatibilitypublic static java.lang.String formatMsg(java.lang.String message, java.util.Map<java.lang.String,java.lang.Object> parameters)
MessageFormat
so parameters whose object is not a string already will be formatted according to the default locale (eg, a number like 1000 may become 1,000)message
- the message string with tokens in placeparameters
- parameters map of tokens to objectspublic static java.lang.String formatMsgPlain(java.lang.String message, java.util.Map<java.lang.String,java.lang.Object> parameters)
message
- the message string with tokens in placeparameters
- map of tokens to objectspublic static java.lang.String formatMsgMixed(java.lang.String message, java.util.Map<java.lang.String,java.lang.Object> formatValues, java.util.Map<java.lang.String,java.lang.Object> noformatValues)
message
- the message string with tokens in placeformatValues
- map of tokens to objects that should be formattednoformatValues
- map of tokens to objects that should not be formatted
|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference 11g Release 1 (11.1.1.9.0) E52944-01 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |