public class AdvancedMessageFormat extends 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(CharSequence pattern)
Construct a new message format.
|
| Modifier and Type | Method and Description |
|---|---|
String |
format(Map<String,Object> params)
Formats a message with the given parameters.
|
void |
format(Map<String,Object> params,
StringBuffer target)
Formats a message with the given parameters.
|
static void |
formatObject(Object obj,
StringBuffer target)
Formats an object to a string and writes the result to a string buffer.
|
public AdvancedMessageFormat(CharSequence pattern)
pattern - the message format pattern.public String format(Map<String,Object> params)
params - a Map of named parameters (Contents: <String, Object>)public void format(Map<String,Object> params, StringBuffer target)
params - a Map of named parameters (Contents: <String, Object>)target - the target StringBuffer to write the formatted message topublic static void formatObject(Object obj, StringBuffer target)
toString() method unless there is an
AdvancedMessageFormat.ObjectFormatter that supports the object. AdvancedMessageFormat.ObjectFormatters are registered
through the service provider mechanism defined by the JAR specification.obj - the object to be formattedtarget - the target string bufferCopyright © 2023 Apache Software Foundation. All rights reserved.