public class ReusableParameterizedMessage extends Object implements ReusableMessage
ParameterizedMessage
,
Serialized FormConstructor and Description |
---|
ReusableParameterizedMessage()
Creates a reusable message.
|
Modifier and Type | Method and Description |
---|---|
void |
formatTo(StringBuilder buffer)
Writes a text representation of this object into the specified
StringBuilder , ideally without allocating
temporary objects. |
String |
getFormat()
Returns the message pattern.
|
String |
getFormattedMessage()
Returns the formatted message.
|
short |
getParameterCount()
Returns the number of parameters that was used to initialize this reusable message for the current content.
|
Object[] |
getParameters()
Returns the message parameters.
|
Throwable |
getThrowable()
Returns the Throwable that was given as the last argument, if any.
|
Message |
memento()
Returns an immutable snapshot of the current internal state of this reusable message.
|
Object[] |
swapParameters(Object[] emptyReplacement)
Returns the parameter array that was used to initialize this reusable message and replaces it with the specified
array.
|
String |
toString() |
public ReusableParameterizedMessage()
public Object[] swapParameters(Object[] emptyReplacement)
ReusableMessage
ReusableMessages that have no parameters return the specified array.
This method is used by asynchronous loggers to pass the parameter array to a background thread without
allocating new objects.
The actual number of parameters in the returned array can be determined with ReusableMessage.getParameterCount()
.
swapParameters
in interface ReusableMessage
emptyReplacement
- the parameter array that can be used for subsequent uses of this reusable message.
This replacement array must have at least 10 elements (the number of varargs supported by the Logger
API).ReusableMessage.getParameterCount()
public short getParameterCount()
ReusableMessage
The parameter array returned by ReusableMessage.swapParameters(Object[])
may be larger than the actual number of
parameters. Callers should use this method to determine how many elements the array contains.
getParameterCount
in interface ReusableMessage
public Message memento()
ReusableMessage
memento
in interface ReusableMessage
public String getFormat()
public Object[] getParameters()
getParameters
in interface Message
public Throwable getThrowable()
getThrowable
in interface Message
public String getFormattedMessage()
getFormattedMessage
in interface Message
public void formatTo(StringBuilder buffer)
StringBuilderFormattable
StringBuilder
, ideally without allocating
temporary objects.formatTo
in interface StringBuilderFormattable
buffer
- the StringBuilder to write intoCopyright © 1999-2016 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.