|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.logging.log4j.message.ParameterizedMessage
public class ParameterizedMessage
Handles messages that consist of a format string containing '{}' to represent each replaceable token, and the parameters.
This class was originally written for Lillith (http://mac.freshmeat.net/projects/lilith-viewer) by Joern Huxhorn where it is licensed under the LGPL. It has been relicensed here with his permission providing that this attribution remain.
Field Summary | |
---|---|
static String |
ERROR_MSG_SEPARATOR
Separator for error messages. |
static String |
ERROR_PREFIX
Prefix for errors. |
static String |
ERROR_SEPARATOR
Separator for errors. |
static String |
ERROR_SUFFIX
Suffix for errors. |
static String |
RECURSION_PREFIX
Prefix for recursion. |
static String |
RECURSION_SUFFIX
Suffix for recursion. |
Constructor Summary | |
---|---|
ParameterizedMessage()
Create the ParameterizedMessage. |
|
ParameterizedMessage(String messagePattern,
Object arg)
Constructor with a pattern and a single parameter. |
|
ParameterizedMessage(String messagePattern,
Object[] arguments)
This method returns a ParameterizedMessage which contains the arguments converted to String as well as an optional Throwable. |
|
ParameterizedMessage(String messagePattern,
Object[] arguments,
Throwable throwable)
|
|
ParameterizedMessage(String messagePattern,
Object arg1,
Object arg2)
Constructor with a pattern and two parameters. |
|
ParameterizedMessage(String messagePattern,
String[] stringArgs,
Throwable throwable)
Create the parameterizedMessage. |
Method Summary | |
---|---|
static int |
countArgumentPlaceholders(String messagePattern)
Counts the number of unescaped placeholders in the given messagePattern. |
static String |
deepToString(Object o)
This method performs a deep toString of the given Object. |
boolean |
equals(Object o)
|
static String |
format(String messagePattern,
Object[] arguments)
Replace placeholders in the given messagePattern with arguments. |
protected String |
formatMessage(String msgPattern,
String[] sArgs)
|
String |
getFormattedMessage()
Return the formatted message. |
String |
getMessageFormat()
Returns the message pattern. |
Object[] |
getParameters()
Returns the message parameters. |
Throwable |
getThrowable()
Returns the Throwable that was given as the last argument, if any. |
int |
hashCode()
|
static String |
identityToString(Object obj)
This method returns the same as if Object.toString() would not have been overridden in obj. |
void |
setMessageFormat(String messagePattern)
Set the message pattern. |
void |
setParameters(Object[] parameters)
Sets the parameters for the message. |
void |
setParameters(String[] parameters)
Sets the parameters for the message. |
void |
setThrowable(Throwable throwable)
Set the Throwable for the message. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String RECURSION_PREFIX
public static final String RECURSION_SUFFIX
public static final String ERROR_PREFIX
public static final String ERROR_SEPARATOR
public static final String ERROR_MSG_SEPARATOR
public static final String ERROR_SUFFIX
Constructor Detail |
---|
public ParameterizedMessage()
public ParameterizedMessage(String messagePattern, String[] stringArgs, Throwable throwable)
messagePattern
- The message "format" string. This will be a String containing "{}" placeholders
where parameters should be substituted.stringArgs
- The arguments for substitution.throwable
- A Throwable.public ParameterizedMessage(String messagePattern, Object[] arguments, Throwable throwable)
public ParameterizedMessage(String messagePattern, Object[] arguments)
This method returns a ParameterizedMessage which contains the arguments converted to String as well as an optional Throwable.
If the last argument is a Throwable and is NOT used up by a placeholder in the message pattern it is returned
in ParameterizedMessage.getThrowable() and won't be contained in the created String[].
If it is used up ParameterizedMessage.getThrowable() will return null even if the last argument was a
Throwable!
messagePattern
- the message pattern that to be checked for placeholders.arguments
- the argument array to be converted.public ParameterizedMessage(String messagePattern, Object arg)
messagePattern
- The message pattern.arg
- The parameter.public ParameterizedMessage(String messagePattern, Object arg1, Object arg2)
messagePattern
- The message pattern.arg1
- The first parameter.arg2
- The second parameter.Method Detail |
---|
public String getFormattedMessage()
getFormattedMessage
in interface Message
public String getMessageFormat()
getMessageFormat
in interface Message
public void setMessageFormat(String messagePattern)
messagePattern
- The message pattern.public Object[] getParameters()
getParameters
in interface Message
public void setParameters(String[] parameters)
parameters
- The parameters.public void setParameters(Object[] parameters)
parameters
- The parameters.public void setThrowable(Throwable throwable)
throwable
- The Throwable.public Throwable getThrowable()
protected String formatMessage(String msgPattern, String[] sArgs)
public boolean equals(Object o)
equals
in class Object
public int hashCode()
hashCode
in class Object
public static String format(String messagePattern, Object[] arguments)
messagePattern
- the message pattern containing placeholders.arguments
- the arguments to be used to replace placeholders.
public static int countArgumentPlaceholders(String messagePattern)
messagePattern
- the message pattern to be analyzed.
public static String deepToString(Object o)
o
- The object.
public static String identityToString(Object obj)
obj
- the Object that is to be converted into an identity string.
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |