public class ReusableSimpleMessage extends Object implements ReusableMessage, CharSequence, ParameterVisitable
Constructor and Description |
---|
ReusableSimpleMessage() |
Modifier and Type | Method and Description |
---|---|
char |
charAt(int index) |
void |
clear()
Resets the object to a clean state.
|
<S> void |
forEachParameter(ParameterConsumer<S> action,
S state)
Performs the given action for each parameter until all values
have been processed or the action throws an exception.
|
void |
formatTo(StringBuilder buffer)
Writes a text representation of this object into the specified
StringBuilder , ideally without allocating
temporary objects. |
String |
getFormat()
Gets the format portion of the Message.
|
String |
getFormattedMessage()
Gets the Message formatted as a String.
|
short |
getParameterCount()
This message does not have any parameters so this method always returns zero.
|
Object[] |
getParameters()
Gets parameter values, if any.
|
Throwable |
getThrowable()
Gets the throwable, if any.
|
int |
length() |
Message |
memento()
Returns an immutable snapshot of the current internal state of this reusable message.
|
void |
set(CharSequence charSequence) |
void |
set(String message) |
CharSequence |
subSequence(int start,
int end) |
Object[] |
swapParameters(Object[] emptyReplacement)
This message does not have any parameters, so this method returns the specified array.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
chars, codePoints, toString
public ReusableSimpleMessage()
public void set(CharSequence charSequence)
public String getFormattedMessage()
Message
When configured to log asynchronously, this method is called before the Message is queued, unless this
message implements ReusableMessage
or is annotated with AsynchronouslyFormattable
.
This gives the Message implementation class a chance to create a formatted message String with the current value
of any mutable objects.
The intention is that the Message implementation caches this formatted message and returns it on subsequent
calls. (See LOG4J2-763.)
When logging synchronously, this method will not be called for Messages that implement the
StringBuilderFormattable
interface: instead, the
formatTo(StringBuilder)
method will be called so the
Message can format its contents without creating intermediate String objects.
getFormattedMessage
in interface Message
public String getFormat()
Message
getFormat
in interface Message
public Object[] getParameters()
Message
getParameters
in interface Message
public Throwable getThrowable()
Message
getThrowable
in interface Message
public void formatTo(StringBuilder buffer)
StringBuilderFormattable
StringBuilder
, ideally without allocating
temporary objects.formatTo
in interface StringBuilderFormattable
buffer
- the StringBuilder to write intopublic Object[] swapParameters(Object[] emptyReplacement)
swapParameters
in interface ReusableMessage
emptyReplacement
- the parameter array to returnReusableMessage.getParameterCount()
public short getParameterCount()
getParameterCount
in interface ReusableMessage
public <S> void forEachParameter(ParameterConsumer<S> action, S state)
ParameterVisitable
The second parameter lets callers pass in a stateful object to be modified with the key-value pairs, so the TriConsumer implementation itself can be stateless and potentially reusable.
forEachParameter
in interface ParameterVisitable
S
- type of the third parameteraction
- The action to be performed for each key-value pair in this collectionstate
- the object to be passed as the third parameter to each invocation on the
specified ParameterConsumer.public Message memento()
ReusableMessage
memento
in interface ReusableMessage
public int length()
length
in interface CharSequence
public char charAt(int index)
charAt
in interface CharSequence
public CharSequence subSequence(int start, int end)
subSequence
in interface CharSequence
public void clear()
Copyright © 1999-1969 The 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.