public class AdvancedMessageFormat
extends java.lang.Object
MessageFormat
but uses named parameters and supports conditional sub-groups.
Example:
Missing field "{fieldName}"[ at location: {location}]!
Modifier and Type | Class and Description |
---|---|
static interface |
AdvancedMessageFormat.Function
Implementations of this interface do some computation based on the message parameters
given to it.
|
static interface |
AdvancedMessageFormat.ObjectFormatter
Implementations of this interface format certain objects to strings.
|
static interface |
AdvancedMessageFormat.Part
Represents a message template part.
|
static interface |
AdvancedMessageFormat.PartFactory
Implementations of this interface parse a field part and return message parts.
|
Constructor and Description |
---|
AdvancedMessageFormat(java.lang.CharSequence pattern)
Construct a new message format.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
format(java.util.Map<java.lang.String,java.lang.Object> params)
Formats a message with the given parameters.
|
void |
format(java.util.Map<java.lang.String,java.lang.Object> params,
java.lang.StringBuffer target)
Formats a message with the given parameters.
|
static void |
formatObject(java.lang.Object obj,
java.lang.StringBuffer target)
Formats an object to a string and writes the result to a string buffer.
|
public AdvancedMessageFormat(java.lang.CharSequence pattern)
pattern
- the message format pattern.public java.lang.String format(java.util.Map<java.lang.String,java.lang.Object> params)
params
- a Map of named parameters (Contents: public void format(java.util.Map<java.lang.String,java.lang.Object> params, java.lang.StringBuffer target)
params
- a Map of named parameters (Contents: target
- the target StringBuffer to write the formatted message topublic static void formatObject(java.lang.Object obj, java.lang.StringBuffer target)
toString()
method unless there is an
AdvancedMessageFormat.ObjectFormatter
that supports the object. AdvancedMessageFormat.ObjectFormatter
s are registered
through the service provider mechanism defined by the JAR specification.obj
- the object to be formattedtarget
- the target string bufferCopyright 1999-2012 The Apache Software Foundation. All Rights Reserved.