|
||||||||||
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(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[] objectArgs,
Throwable throwable)
Creates a parameterized message. |
|
ParameterizedMessage(String messagePattern,
Object arg1,
Object arg2)
Constructor with a pattern and two parameters. |
|
ParameterizedMessage(String messagePattern,
String[] stringArgs,
Throwable throwable)
Creates a parameterized message. |
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 |
getFormat()
Returns the message pattern. |
String |
getFormattedMessage()
Returns the formatted message. |
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. |
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(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[] objectArgs, Throwable throwable)
messagePattern
- The message "format" string. This will be a String containing "{}" placeholders
where parameters should be substituted.objectArgs
- The arguments for substitution.throwable
- A 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 getFormat()
getFormat
in interface Message
public Object[] getParameters()
getParameters
in interface Message
public Throwable getThrowable()
getThrowable
in interface Message
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 |
Copyright © 1999-2014 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.