net.sf.staccatocommons.check.format
Class VariableFormatter

java.lang.Object
  extended by net.sf.staccatocommons.check.format.VariableFormatter

public class VariableFormatter
extends Object

A formatter that creates strings that show a variable content, for debugging and error messages.

Author:
fbulgarelli

Field Summary
static String DEFAULT_FORMATTING_STRING
          The default formatting string.
 
Constructor Summary
VariableFormatter()
          Creates a VariableFormatter with the default formatting string
VariableFormatter(String formattingString)
          Creates a VariableFormatter with a custom formatting string, in the form of the formatting string expected by String.format(String, Object...).
 
Method Summary
 String format(String name, Object value)
          Creates a string that shows the content of a variable
 String format(String name, Object value, String suffix)
          Creates a string that shows the content of a variable, followed by a suffix
 String format(String prefix, String name, Object value)
          Creates a string that shows the content of a variable, preceded by a prefix
 String format(String prefix, String name, Object value, String suffix)
          Creates a string that shows the content of a variable, preceded by a prefix string and ended with a suffix string
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_FORMATTING_STRING

public static final String DEFAULT_FORMATTING_STRING
The default formatting string. It produces formatted string in the form variableName=[variableValue]

See Also:
Constant Field Values
Constructor Detail

VariableFormatter

public VariableFormatter(String formattingString)
Creates a VariableFormatter with a custom formatting string, in the form of the formatting string expected by String.format(String, Object...). It must match the expression .*\%s.*\%s.*

Parameters:
formattingString -

VariableFormatter

public VariableFormatter()
Creates a VariableFormatter with the default formatting string

Method Detail

format

public String format(String name,
                     Object value)
Creates a string that shows the content of a variable

Parameters:
name - the variable name. Non null.
value - the variable value. Nullable
Returns:
the formatted variable, using this VariableFormatter formatting string

format

public String format(String prefix,
                     String name,
                     Object value)
Creates a string that shows the content of a variable, preceded by a prefix

Parameters:
prefix - a string that will be inserted after the formatted variable A space is inserted between them. Non null
name - the variable name. Non null.
value - the variable value. Nullable
Returns:
the formatted variable, using this VariableFormatter formatting string, preceded by a prefix

format

public String format(String name,
                     Object value,
                     String suffix)
Creates a string that shows the content of a variable, followed by a suffix

Parameters:
name - the variable name. Non null.
value - the variable value. Nullable
suffix - a string that will be inserted after the formatted string. A space is inserted between them. Non null
Returns:
the formatted variable, using this VariableFormatter formatting string, preceded by a prefix

format

public String format(String prefix,
                     String name,
                     Object value,
                     String suffix)
Creates a string that shows the content of a variable, preceded by a prefix string and ended with a suffix string

Parameters:
prefix - a string that will be inserted before of the formatted variable. A space is inserted between them. Non null
name - the variable name. Non null.
value - the variable value. Nullable
suffix - a string that will be inserted after the formatted variable. A space is inserted between them. Non null
Returns:
the formatted variable, using this VariableFormatter formatting string, preceded by a prefix, and ended with a suffix


Get Staccatocommons at SourceForge.net. Fast, secure and Free Open Source software downloads