public class MapMessage extends Objectimplements MultiformatMessage
Thread-safety note: the contents of this message can be modified after construction. When using asynchronous loggers and appenders it is not recommended to modify this message after the message is logged, because it is undefined whether the logged message string will contain the old values or the modified values.
| Modifier and Type | Class and Description |
|---|---|
static class |
MapMessage
When set as the format specifier causes the Map to be formatted as XML.
|
| Constructor and Description |
|---|
MapMessage()
Constructor.
|
MapMessage(Map
Constructor based on an existing Map.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
appendMap(StringBuilder
|
protected void |
asJava(StringBuilder
|
protected void |
asJson(StringBuilder
|
String |
asString()
Format the Structured data as described in RFC 5424.
|
String |
asString(String
|
void |
asXml(StringBuilder
|
void |
clear()
Clear the data.
|
boolean |
equals(Object
|
String |
get(String
Retrieve the value of the element with the specified key or null if the key is not present.
|
Map |
getData()
Returns the message data as an unmodifiable Map.
|
String |
getFormat()
Returns the message.
|
String |
getFormats()
Returns the supported formats.
|
String |
getFormattedMessage()
Format the message and return it.
|
String |
getFormattedMessage(String
Returns the Message formatted as a String.
|
Object |
getParameters()
Returns the data elements as if they were parameters on the logging event.
|
Throwable |
getThrowable()
Always returns null.
|
int |
hashCode()
|
MapMessage |
newInstance(Map
|
void |
put(String
Add an item to the data Map.
|
void |
putAll(Map
Add all the elements from the specified Map.
|
String |
remove(String
Remove the element with the specified name.
|
String |
toString()
|
protected void |
validate(String
|
MapMessage |
with(String
Add an item to the data Map in fluent style.
|
public String[] getFormats()
MultiformatMessage
getFormats in interface
MultiformatMessage
public Object[] getParameters()
getParameters in interface
Message
public StringgetFormat()
public Map<String ,String > getData()
public void clear()
public MapMessagewith(String key, String value)
key - The name of the data item.
value - The value of the data item.
this
public void put(Stringkey, String value)
key - The name of the data item.
value - The value of the data item.
public void putAll(Map<String ,String > map)
map - The Map to add.
public Stringget(String key)
key - The name of the element.
public Stringremove(String key)
key - The name of the element.
public StringasString()
public void asXml(StringBuildersb)
public StringgetFormattedMessage()
getFormattedMessage in interface
Message
public StringgetFormattedMessage(String [] formats)
MultiformatMessage
getFormattedMessage in interface
MultiformatMessage
formats - An array of Strings that provide extra information about how to format the message. MapMessage uses the first format specifier it recognizes. The supported formats are XML, JSON, and JAVA. The default format is key1="value1" key2="value2" as required by RFC 5424 messages.
protected void appendMap(StringBuildersb)
protected void asJson(StringBuildersb)
protected void asJava(StringBuildersb)
public MapMessagenewInstance(Map <String ,String > map)
public StringtoString()
public boolean equals(Objecto)
public int hashCode()
public ThrowablegetThrowable()
getThrowable in interface
Message