Package org.apache.log4j.helpers
Class MessageFormatter
- java.lang.Object
-
- org.apache.log4j.helpers.MessageFormatter
-
public final class MessageFormatter extends java.lang.Object
Formats messages according to very simple rules. Seeformat(String, Object)
andformat(String, Object, Object)
for more details.
-
-
Field Summary
Fields Modifier and Type Field Description private static char
DELIM_START
Start of replacement block.private static char
DELIM_STOP
End of replacement block.
-
Constructor Summary
Constructors Modifier Constructor Description private
MessageFormatter()
Private formatter since all methods and members are static.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
format(java.lang.String messagePattern, java.lang.Object argument)
Performs single argument substitution for the 'messagePattern' passed as parameter.static java.lang.String
format(java.lang.String messagePattern, java.lang.Object arg1, java.lang.Object arg2)
/** Performs a two argument substitution for the 'messagePattern' passed as parameter.
-
-
-
Field Detail
-
DELIM_START
private static final char DELIM_START
Start of replacement block.- See Also:
- Constant Field Values
-
DELIM_STOP
private static final char DELIM_STOP
End of replacement block.- See Also:
- Constant Field Values
-
-
Method Detail
-
format
public static java.lang.String format(java.lang.String messagePattern, java.lang.Object argument)
Performs single argument substitution for the 'messagePattern' passed as parameter.For example,
The {} pair is called the formatting element. It serves to designate the location where the argument needs to be inserted within the pattern.MessageFormatter.format("Hi {}.", "there");
will return the string "Hi there.".- Parameters:
messagePattern
- The message pattern which will be parsed and formattedargument
- The argument to be inserted instead of the formatting element- Returns:
- The formatted message
-
format
public static java.lang.String format(java.lang.String messagePattern, java.lang.Object arg1, java.lang.Object arg2)
/** Performs a two argument substitution for the 'messagePattern' passed as parameter.For example,
The '{}' pair is called a formatting element. It serves to designate the location where the arguments need to be inserted within the message pattern.MessageFormatter.format("Hi {}. My name is {}.", "there", "David");
will return the string "Hi there. My name is David.".- Parameters:
messagePattern
- The message pattern which will be parsed and formattedarg1
- The first argument to replace the first formatting elementarg2
- The second argument to replace the second formatting element- Returns:
- The formatted message
-
-