| java.lang.Object org.slf4j.helpers.MessageFormatter
MessageFormatter | public class MessageFormatter (Code) | | Formats messages according to very simple substitution rules. Substitutions
can be made 1, 2 or more arguments.
For example,
MessageFormatter.format("Hi {}.", "there");
will return the string "Hi there.".
The {} pair is called the formatting anchor. It serves to
designate the location where arguments need to be substituted within the
message pattern.
In the rare case where you need to place the '{' or '}' in the message
pattern itself but do not want them to be interpreted as a formatting
anchors, you can espace the '{' character with '\', that is the backslash
character. Only the '{' character should be escaped. There is no need to
escape the '}' character. For example,
MessageFormatter.format("Set \\{1,2,3} is not equal to {}.", "1,2");
will return the string "Set {1,2,3} is not equal to 1,2.".
The escaping behaviour just described can be overridden by
escaping the escape character '\'. Calling
MessageFormatter.format("File name is C:\\\\{}.", "file.zip");
will return the string "File name is C:\file.zip".
See
MessageFormatter.format(String,Object) ,
MessageFormatter.format(String,Object,Object) and
MessageFormatter.arrayFormat(String,Object[]) methods for more details.
author: Ceki Gülcü |
Method Summary | |
public static String | arrayFormat(String messagePattern, Object[] argArray) Same principle as the
MessageFormatter.format(String,Object) and
MessageFormatter.format(String,Object,Object) methods except that any number of
arguments can be passed in an array. | public static String | format(String messagePattern, Object arg) Performs single argument substitution for the 'messagePattern' passed as
parameter. | public static String | format(String messagePattern, Object arg1, Object arg2) Performs a two argument substitution for the 'messagePattern' passed as
parameter.
For example,
MessageFormatter.format("Hi {}. | static boolean | isDoubleEscaped(String messagePattern, int delimeterStartIndex) | static boolean | isEscapedDelimeter(String messagePattern, int delimeterStartIndex) |
DELIM_START | final static char DELIM_START(Code) | | |
DELIM_STOP | final static char DELIM_STOP(Code) | | |
format | public static String format(String messagePattern, Object arg)(Code) | | Performs single argument substitution for the 'messagePattern' passed as
parameter.
For example,
MessageFormatter.format("Hi {}.", "there");
will return the string "Hi there.".
Parameters: messagePattern - The message pattern which will be parsed and formatted Parameters: argument - The argument to be substituted in place of the formatting anchor The formatted message |
format | public static String format(String messagePattern, Object arg1, Object arg2)(Code) | | Performs a two argument substitution for the 'messagePattern' passed as
parameter.
For example,
MessageFormatter.format("Hi {}. My name is {}.", "Alice", "Bob");
will return the string "Hi Alice. My name is Bob.".
Parameters: messagePattern - The message pattern which will be parsed and formatted Parameters: arg1 - The argument to be substituted in place of the first formattinganchor Parameters: arg2 - The argument to be substituted in place of the second formattinganchor The formatted message |
isDoubleEscaped | static boolean isDoubleEscaped(String messagePattern, int delimeterStartIndex)(Code) | | |
isEscapedDelimeter | static boolean isEscapedDelimeter(String messagePattern, int delimeterStartIndex)(Code) | | |
|
|