com.tonbeller.wcf.format
Interface FormatHandler

All Known Implementing Classes:
FormatHandlerSupport

public interface FormatHandler

defines a parser/printer for user input/display


Method Summary
 boolean canHandle(java.lang.Object value)
          returns true if this handler can handle the given object
 java.lang.String format(java.lang.Object o, java.lang.String pattern)
          format an object
 java.lang.String getName()
          returns the name of the FormatHandler.
 java.lang.Object parse(java.lang.String s, java.lang.String pattern)
          parse a String and create an object
 void setLocale(java.util.Locale locale)
          sets the Locale that this handler should use
 java.lang.Object toNativeArray(java.util.List list)
          returns a native array of the data type.
 java.lang.Object[] toObjectArray(java.lang.Object value)
          returns an array of wrapper objects.
 

Method Detail

setLocale

public void setLocale(java.util.Locale locale)
sets the Locale that this handler should use


getName

public java.lang.String getName()
returns the name of the FormatHandler. Example "string" or "date".


format

public java.lang.String format(java.lang.Object o,
                               java.lang.String pattern)
format an object

Parameters:
o - the object to format
pattern - the format string to use. If null or empty string, the configured pattern for the locale will be used.

parse

public java.lang.Object parse(java.lang.String s,
                              java.lang.String pattern)
                       throws FormatException
parse a String and create an object

Parameters:
s - the string, eg user input
pattern - the format string to use. If null or empty string, the configured pattern for the locale will be used.
Throws:
FormatException

canHandle

public boolean canHandle(java.lang.Object value)
returns true if this handler can handle the given object


toNativeArray

public java.lang.Object toNativeArray(java.util.List list)
returns a native array of the data type. E.g., the int handler will return an int[] array.

Parameters:
list - contains wrapper objects (e.g. Integer)

toObjectArray

public java.lang.Object[] toObjectArray(java.lang.Object value)
returns an array of wrapper objects. E.g., the int handler will return an Integer[] array containing Integer instances.

Parameters:
value - either a scalar wrapper object (e.g. Integer) or an array of native types (e.g. int[])
Returns:
an array of wrapper types, e.g. Integer[]. If value is a scalar, the returned array contains value as its only element.