org.openbp.common
Class MsgFormat

java.lang.Object
  extended by org.openbp.common.MsgFormat

public final class MsgFormat
extends java.lang.Object

Custom message format class. This class works similar to the MessageFormat class except that
- it provides an additional syntax for quoted arguments
- it provides some convenience methods that avoid explicit argument array construction. \bQuoted Arguments\b Often, file and object names are enclosed in single quotes in a message. Due to a strange behavior of the original MessageFormat class, they have to be written as double single quotes in the message pattern (e. g. "...''{0}''..."). This is unhandy and a potential cause of errors. An additional syntax has been introduced that automatically wraps arguments in single quotes:
\c"...$n..."\c will be converted to "...''{0}''..." automatically. If the "$" is followed by a non-digit character, it will be printed as it is.

Author:
Heiko Erhardt

Method Summary
static java.lang.String format(java.lang.String pattern, java.lang.Object arg1)
          Formats a message using the given pattern and arguments.
static java.lang.String format(java.lang.String pattern, java.lang.Object[] args)
          Formats a message using the given pattern and arguments.
static java.lang.String format(java.lang.String pattern, java.lang.Object arg1, java.lang.Object arg2)
          Formats a message using the given pattern and arguments.
static java.lang.String format(java.lang.String pattern, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3)
          Formats a message using the given pattern and arguments.
static java.lang.String format(java.lang.String pattern, java.lang.Object arg1, java.lang.Object arg2, java.lang.Object arg3, java.lang.Object arg4)
          Formats a message using the given pattern and arguments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

format

public static java.lang.String format(java.lang.String pattern,
                                      java.lang.Object[] args)
Formats a message using the given pattern and arguments. Formats a message using the given pattern and arguments. Throws several types of RuntimeException if the pattern parsing or application fails.

Parameters:
pattern - The pattern to be used to format messages.
For details on the pattern argument placeholder syntax, see the MessageFormat class.
args - Array of message arguments
Returns:
The formatted message

format

public static java.lang.String format(java.lang.String pattern,
                                      java.lang.Object arg1)
Formats a message using the given pattern and arguments. Throws several types of RuntimeException if the pattern parsing or application fails.

Parameters:
pattern - The pattern to be used to format messages.
For details on the pattern argument placeholder syntax, see the MessageFormat class.
arg1 - First message argument
Returns:
The formatted message

format

public static java.lang.String format(java.lang.String pattern,
                                      java.lang.Object arg1,
                                      java.lang.Object arg2)
Formats a message using the given pattern and arguments. Throws several types of RuntimeException if the pattern parsing or application fails.

Parameters:
pattern - The pattern to be used to format messages.
For details on the pattern argument placeholder syntax, see the MessageFormat class.
arg1 - First message argument
arg2 - Second message argument
Returns:
The formatted message

format

public static java.lang.String format(java.lang.String pattern,
                                      java.lang.Object arg1,
                                      java.lang.Object arg2,
                                      java.lang.Object arg3)
Formats a message using the given pattern and arguments. Throws several types of RuntimeException if the pattern parsing or application fails.

Parameters:
pattern - The pattern to be used to format messages.
For details on the pattern argument placeholder syntax, see the MessageFormat class.
arg1 - First message argument
arg2 - Second message argument
arg3 - Third message argument
Returns:
The formatted message

format

public static java.lang.String format(java.lang.String pattern,
                                      java.lang.Object arg1,
                                      java.lang.Object arg2,
                                      java.lang.Object arg3,
                                      java.lang.Object arg4)
Formats a message using the given pattern and arguments. Throws several types of RuntimeException if the pattern parsing or application fails.

Parameters:
pattern - The pattern to be used to format messages.
For details on the pattern argument placeholder syntax, see the MessageFormat class.
arg1 - First message argument
arg2 - Second message argument
arg3 - Third message argument
arg4 - Fourth messageObject argument
Returns:
The formatted message


Copyright © 2011. All Rights Reserved.