Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1)

E13403-03

oracle.javatools.resourcebundle
Class NamedMessageFormat

java.lang.Object
  extended by oracle.javatools.resourcebundle.NamedMessageFormat

public class NamedMessageFormat
extends java.lang.Object

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. Like MessageFormat, a single quote must be represented using two consecutive single quotes, but the contents of any text between single quotes will not be interpreted. So, the following pattern could be used to include a left bracket:
     some'{'text{first}
 

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

NamedMessageFormat

public NamedMessageFormat(java.lang.String formatString)
Creates a NamedMessageFormat based on the given format string.

Method Detail

format

public 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. It is legal for this Map to contain keys not supported by the pattern, or to omit keys looked for in the pattern.

Parameters:
parameters - a Map of key/value String pairs

format

public 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. It is legal for this Map to contain keys not supported by the pattern, or to omit keys looked for in the pattern.

Parameters:
parameters - a Map of key/value String pairs
parameterSize - the accumulated size of the parameters, if known. Pass zero for an unknown size. This allows for optimizing to reduce buffer reallocation.

formatMsg

public 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. This method uses 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)

Parameters:
message - the message string with tokens in place
parameters - parameters map of tokens to objects
Returns:
formatted message with named tokens replaced with data from the parameters map

formatMsgPlain

public 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. The object put into the parameters map for the token must either be a String or support toString().

Parameters:
message - the message string with tokens in place
parameters - map of tokens to objects
Returns:
formatted message with named tokens replaced with data from the parameters map

formatMsgMixed

public 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. This method allows some parameter objects to be substituted directly and some to be formatted in the default locale. For example, if a message were something like: {PO_NUMBER} is greater than {MAX_VALUE} you probably want the po_number to be unformatted but let the max_value be formatted.

Parameters:
message - the message string with tokens in place
formatValues - map of tokens to objects that should be formatted
noformatValues - map of tokens to objects that should not be formatted
Returns:
formatted message with named tokens replaced with data from the parameters map

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1)

E13403-03

Copyright © 1997, 2009, Oracle. All rights reserved.