Top Description Fields Constructors Methods
org.apache.logging.log4j.message

public Class ReusableSimpleMessage

extends Object
implements ReusableMessage, CharSequence, ParameterVisitable, Clearable
Class Inheritance
All Implemented Interfaces
org.apache.logging.log4j.message.Clearable, org.apache.logging.log4j.message.ParameterVisitable, java.lang.CharSequence, org.apache.logging.log4j.message.ReusableMessage, org.apache.logging.log4j.util.StringBuilderFormattable, org.apache.logging.log4j.message.Message, java.io.Serializable
Annotations
@PerformanceSensitive:allocation
Imports
org.apache.logging.log4j.util.Constants, .PerformanceSensitive

Mutable Message wrapper around a String message.
Since
2.6

Field Summary

Modifier and TypeField and Description
private CharSequence
private static final long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public char
charAt(final int
the index of the char value to be returned
index
)

Implements java.lang.CharSequence.charAt.

Returns the char value at the specified index.

public void
clear()

Implements org.apache.logging.log4j.message.Clearable.clear.

Resets the object to a clean state.

public <S> void
forEachParameter(final ParameterConsumer<S>
The action to be performed for each key-value pair in this collection
action
,
final S
the object to be passed as the third parameter to each invocation on the specified ParameterConsumer.
state
)

Implements org.apache.logging.log4j.message.ParameterVisitable.forEachParameter.

Performs the given action for each parameter until all values have been processed or the action throws an exception.

public void
formatTo(final StringBuilder
the StringBuilder to write into
buffer
)

Implements org.apache.logging.log4j.util.StringBuilderFormattable.formatTo.

Writes a text representation of this object into the specified StringBuilder, ideally without allocating temporary objects.

public String
getFormat()

Implements org.apache.logging.log4j.message.Message.getFormat.

Gets the format portion of the Message.

public String
getFormattedMessage()

Implements org.apache.logging.log4j.message.Message.getFormattedMessage.

Gets the Message formatted as a String.

public short

Returns:

0 (zero)
getParameterCount
()

Implements org.apache.logging.log4j.message.ReusableMessage.getParameterCount.

This message does not have any parameters so this method always returns zero.

public Object[]
getParameters()

Implements org.apache.logging.log4j.message.Message.getParameters.

Gets parameter values, if any.

public Throwable
public int
length()

Implements java.lang.CharSequence.length.

Returns the length of this character sequence.

public Message
memento()

Implements org.apache.logging.log4j.message.ReusableMessage.memento.

Returns an immutable snapshot of the current internal state of this reusable message.

public void
set(final String message)

public void
set(final CharSequence charSequence)

public CharSequence
subSequence(final int
the start index, inclusive
start
,
final int
the end index, exclusive
end
)

Implements java.lang.CharSequence.subSequence.

Returns a CharSequence that is a subsequence of this sequence.

public Object[]

Returns:

the specified array
swapParameters
(final Object[]
the parameter array to return
emptyReplacement
)

Implements org.apache.logging.log4j.message.ReusableMessage.swapParameters.

This message does not have any parameters, so this method returns the specified array.

private Object
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

charSequenceback to summary
private CharSequence charSequence
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

ReusableSimpleMessageback to summary
public ReusableSimpleMessage()

Method Detail

charAtback to summary
public char charAt(final int index)

Implements java.lang.CharSequence.charAt.

Doc from java.lang.CharSequence.charAt.

Returns the char value at the specified index. An index ranges from zero to length() - 1. The first char value of the sequence is at index zero, the next at index one, and so on, as for array indexing.

If the char value specified by the index is a surrogate, the surrogate value is returned.

Parameters
index:int

the index of the char value to be returned

Returns:char

the specified char value

Annotations
@Override
clearback to summary
public void clear()

Implements org.apache.logging.log4j.message.Clearable.clear.

Doc from org.apache.logging.log4j.message.Clearable.clear.

Resets the object to a clean state.

Annotations
@Override
forEachParameterback to summary
public <S> void forEachParameter(final ParameterConsumer<S> action, final S state)

Implements org.apache.logging.log4j.message.ParameterVisitable.forEachParameter.

Doc from org.apache.logging.log4j.message.ParameterVisitable.forEachParameter.

Performs the given action for each parameter until all values have been processed or the action throws an exception.

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.

Parameters
<S>
type of the third parameter
action:ParameterConsumer<S>

The action to be performed for each key-value pair in this collection

state:S

the object to be passed as the third parameter to each invocation on the specified ParameterConsumer.

Annotations
@Override
formatToback to summary
public void formatTo(final StringBuilder buffer)

Implements org.apache.logging.log4j.util.StringBuilderFormattable.formatTo.

Doc from org.apache.logging.log4j.util.StringBuilderFormattable.formatTo.

Writes a text representation of this object into the specified StringBuilder, ideally without allocating temporary objects.

Parameters
buffer:StringBuilder

the StringBuilder to write into

Annotations
@Override
getFormatback to summary
public String getFormat()

Implements org.apache.logging.log4j.message.Message.getFormat.

Doc from org.apache.logging.log4j.message.Message.getFormat.

Gets the format portion of the Message.

Returns:String

The message format. Some implementations, such as ParameterizedMessage, will use this as the message "pattern". Other Messages may simply return an empty String. TODO Do all messages have a format? What syntax? Using a Formatter object could be cleaner. (RG) In SimpleMessage the format is identical to the formatted message. In ParameterizedMessage and StructuredDataMessage it is not. It is up to the Message implementer to determine what this method will return. A Formatter is inappropriate as this is very specific to the Message implementation so it isn't clear to me how having a Formatter separate from the Message would be cleaner.

Annotations
@Override
getFormattedMessageback to summary
public String getFormattedMessage()

Implements org.apache.logging.log4j.message.Message.getFormattedMessage.

Doc from org.apache.logging.log4j.message.Message.getFormattedMessage.

Gets the Message formatted as a String. Each Message implementation determines the appropriate way to format the data encapsulated in the Message. Messages that provide more than one way of formatting the Message will implement MultiformatMessage.

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.

Returns:String

The message String.

Annotations
@Override
getParameterCountback to summary
public short getParameterCount()

Implements org.apache.logging.log4j.message.ReusableMessage.getParameterCount.

This message does not have any parameters so this method always returns zero.

Returns:short

0 (zero)

Annotations
@Override
getParametersback to summary
public Object[] getParameters()

Implements org.apache.logging.log4j.message.Message.getParameters.

Doc from org.apache.logging.log4j.message.Message.getParameters.

Gets parameter values, if any.

Returns:Object[]

An array of parameter values or null.

Annotations
@Override
getThrowableback to summary
public Throwable getThrowable()

Implements org.apache.logging.log4j.message.Message.getThrowable.

Doc from org.apache.logging.log4j.message.Message.getThrowable.

Gets the throwable, if any.

Returns:Throwable

the throwable or null.

Annotations
@Override
lengthback to summary
public int length()

Implements java.lang.CharSequence.length.

Doc from java.lang.CharSequence.length.

Returns the length of this character sequence. The length is the number of 16-bit chars in the sequence.

Returns:int

the number of chars in this sequence

Annotations
@Override
mementoback to summary
public Message memento()

Implements org.apache.logging.log4j.message.ReusableMessage.memento.

Doc from org.apache.logging.log4j.message.ReusableMessage.memento.

Returns an immutable snapshot of the current internal state of this reusable message. The returned snapshot will not be affected by subsequent modifications of this reusable message.

Returns:Message

an immutable snapshot of this message

Annotations
@Override
setback to summary
public void set(final String message)
setback to summary
public void set(final CharSequence charSequence)
subSequenceback to summary
public CharSequence subSequence(final int start, final int end)

Implements java.lang.CharSequence.subSequence.

Doc from java.lang.CharSequence.subSequence.

Returns a CharSequence that is a subsequence of this sequence. The subsequence starts with the char value at the specified index and ends with the char value at index end - 1. The length (in chars) of the returned sequence is end - start, so if start == end then an empty sequence is returned.

Parameters
start:int

the start index, inclusive

end:int

the end index, exclusive

Returns:CharSequence

the specified subsequence

Annotations
@Override
swapParametersback to summary
public Object[] swapParameters(final Object[] emptyReplacement)

Implements org.apache.logging.log4j.message.ReusableMessage.swapParameters.

This message does not have any parameters, so this method returns the specified array.

Parameters
emptyReplacement:Object[]

the parameter array to return

Returns:Object[]

the specified array

Annotations
@Override
writeReplaceback to summary
private Object writeReplace()