QJCC homepage

biz.chitec.quarterback.util
Class MF

java.lang.Object
  extended bybiz.chitec.quarterback.util.MF

public final class MF
extends java.lang.Object

Convenience methods for formatting messages with java.util.MessageFormat. All-static and uninstanciable.

Version:
$Id: 9a75971b94826e4609f0b85baebd4b571f5cf345 $
Author:
Dirk Hillbrecht 1997-1999, chitec/Dirk Hillbrecht 2000,2002. Distributed under the terms of the GNU LGPL.

Field Summary
(package private) static int BLANKAFTER
           
(package private) static int BLANKBEFORE
           
(package private) static int CARRIAGERETURN
           
 
Constructor Summary
private MF()
          This class is not instanciable.
 
Method Summary
static java.lang.String format(java.util.List l)
          formats a List assuming template at index 0 and variables at following indices.
static java.lang.String format(java.util.ResourceBundle rb, java.lang.String result)
          Formats a string containing template and parameters.
static java.lang.String format(java.lang.String pattern, java.util.List l)
          Formats lists by pattern beginning at index 0
static java.lang.String format(java.lang.String pattern, java.util.List l, boolean noindex0)
          formats a pattern with the variables given in the vector. if noindex0 is set, List.get(0) is not used at all (variables begin at index 1), otherwise variables are taken from index 0 on.
static java.lang.String format(java.lang.String pattern, java.util.Map m)
          Creates a formatted string by inserting m's values whereever {}-encapsulated keys of m occur.
static java.lang.String format(java.lang.String pattern, java.lang.Object o0)
          formats pattern with one variable object.
private static java.lang.String format(java.lang.String pattern, java.lang.Object[] oo)
          Internal helper method to format messages without pattern nicely.
static java.lang.String format(java.lang.String pattern, java.lang.Object o0, java.lang.Object o1)
          formats pattern with two variable objects.
static java.lang.String format(java.lang.String pattern, java.lang.Object o0, java.lang.Object o1, java.lang.Object o2)
          formats pattern with three variable objects.
static java.lang.String format(java.lang.String pattern, java.lang.Object o0, java.lang.Object o1, java.lang.Object o2, java.lang.Object o3)
          formats pattern with four variable objects.
static java.lang.String format(java.lang.String pattern, java.lang.Object o0, java.lang.Object o1, java.lang.Object o2, java.lang.Object o3, java.lang.Object o4)
          formats pattern with five variable objects.
static java.lang.String format(java.lang.String pattern, java.lang.Object o0, java.lang.Object o1, java.lang.Object o2, java.lang.Object o3, java.lang.Object o4, java.lang.Object o5)
          formats pattern with six variable objects.
private static int[] getFormatModifier(java.lang.String encaps)
          Parses the given string and returns the including format modifier as int array
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CARRIAGERETURN

static final int CARRIAGERETURN
See Also:
Constant Field Values

BLANKBEFORE

static final int BLANKBEFORE
See Also:
Constant Field Values

BLANKAFTER

static final int BLANKAFTER
See Also:
Constant Field Values
Constructor Detail

MF

private MF()
This class is not instanciable.

Method Detail

format

private static java.lang.String format(java.lang.String pattern,
                                       java.lang.Object[] oo)
Internal helper method to format messages without pattern nicely. If for some reason the pattern does not include placeholders, this method creates a representation that includes the pattern and all parameters.

Parameters:
pattern - The formatting pattern
oo - Array of parameters to the pattern
Returns:
The formatted message

format

public static java.lang.String format(java.util.List l)
formats a List assuming template at index 0 and variables at following indices.

Parameters:
l - Description of the Parameter
Returns:
The formatted message

format

public static java.lang.String format(java.lang.String pattern,
                                      java.util.List l,
                                      boolean noindex0)
formats a pattern with the variables given in the vector. if noindex0 is set, List.get(0) is not used at all (variables begin at index 1), otherwise variables are taken from index 0 on.

Parameters:
pattern - The formatting pattern
l - List of parameters to the pattern
noindex0 - Flag whether element at index 0 in the list should be seen as parameter or not
Returns:
The formatted message

format

public static java.lang.String format(java.lang.String pattern,
                                      java.util.List l)
Formats lists by pattern beginning at index 0

Parameters:
pattern - The formatting pattern
l - List of parameters to the pattern
Returns:
The formatted message

format

public static java.lang.String format(java.lang.String pattern,
                                      java.util.Map m)
Creates a formatted string by inserting m's values whereever {}-encapsulated keys of m occur. The keys of m should be Strings as they won't be found otherwise. Case matters! The encapsulated keys of the pattern could contain following format modifiers:
  1. %n forces a carriage return
  2. %sb forces an ending blank
  3. %se forces a leading blank

Parameters:
pattern - Formatting pattern
m - Map with parameters
Returns:
Formatted message

getFormatModifier

private static int[] getFormatModifier(java.lang.String encaps)
Parses the given string and returns the including format modifier as int array

Parameters:
encaps - String with format modifiers
Returns:
int[] containing formatmodifiers

format

public static java.lang.String format(java.lang.String pattern,
                                      java.lang.Object o0)
formats pattern with one variable object.

Parameters:
pattern - The formatting pattern
o0 - The first parameter to the pattern
Returns:
The formatted message

format

public static java.lang.String format(java.lang.String pattern,
                                      java.lang.Object o0,
                                      java.lang.Object o1)
formats pattern with two variable objects.

Parameters:
pattern - The formatting pattern
o0 - The first parameter to the pattern
o1 - The second parameter to the pattern
Returns:
The formatted message

format

public static java.lang.String format(java.lang.String pattern,
                                      java.lang.Object o0,
                                      java.lang.Object o1,
                                      java.lang.Object o2)
formats pattern with three variable objects.

Parameters:
pattern - The formatting pattern
o0 - The first parameter to the pattern
o1 - The second parameter to the pattern
o2 - The third parameter to the pattern
Returns:
The formatted message

format

public static java.lang.String format(java.lang.String pattern,
                                      java.lang.Object o0,
                                      java.lang.Object o1,
                                      java.lang.Object o2,
                                      java.lang.Object o3)
formats pattern with four variable objects.

Parameters:
pattern - The formatting pattern
o0 - The first parameter to the pattern
o1 - The second parameter to the pattern
o2 - The third parameter to the pattern
o3 - The fourth parameter to the pattern
Returns:
The formatted message

format

public static java.lang.String format(java.lang.String pattern,
                                      java.lang.Object o0,
                                      java.lang.Object o1,
                                      java.lang.Object o2,
                                      java.lang.Object o3,
                                      java.lang.Object o4)
formats pattern with five variable objects.

Parameters:
pattern - The formatting pattern
o0 - The first parameter to the pattern
o1 - The second parameter to the pattern
o2 - The third parameter to the pattern
o3 - The fourth parameter to the pattern
o4 - The fifth parameter to the pattern
Returns:
The formatted message

format

public static java.lang.String format(java.lang.String pattern,
                                      java.lang.Object o0,
                                      java.lang.Object o1,
                                      java.lang.Object o2,
                                      java.lang.Object o3,
                                      java.lang.Object o4,
                                      java.lang.Object o5)
formats pattern with six variable objects.

Parameters:
pattern - The formatting pattern
o0 - The first parameter to the pattern
o1 - The second parameter to the pattern
o2 - The third parameter to the pattern
o3 - The fourth parameter to the pattern
o4 - The fifth parameter to the pattern
o5 - The sixth parameter to the pattern
Returns:
The formatted message

format

public static java.lang.String format(java.util.ResourceBundle rb,
                                      java.lang.String result)
Formats a string containing template and parameters. Template is evaluated through given ResourceBundle. Parameters are seperated by "|".


QJCC homepage