com.iternum.swlink.beanutils
Class FormatConverter

java.lang.Object
  extended bycom.iternum.swlink.beanutils.FormatConverter
All Implemented Interfaces:
org.apache.commons.beanutils.Converter

public class FormatConverter
extends java.lang.Object
implements org.apache.commons.beanutils.Converter

This class is a beanutils converter that is used to convert objects of a specific type to a String using configurable formatters that extent the java.text.Format interface.

Author:
bankkar

Constructor Summary
FormatConverter()
          Creates an empty format converter.
 
Method Summary
 java.lang.Object convert(java.lang.Class pTargetClass, java.lang.Object pSource)
          This class converts an incoming String for various incoming objects.
 void setFormat(java.lang.Class pClass, Format pFormat)
          Add a Format for a class, replacing an existing format for the same class.
 void setFormat(java.lang.Class pClass, java.text.Format pFormat)
          Convenience method to add a java.text.Format for a class, replacing an existing format for the same class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FormatConverter

public FormatConverter()
Creates an empty format converter.

Method Detail

convert

public java.lang.Object convert(java.lang.Class pTargetClass,
                                java.lang.Object pSource)
This class converts an incoming String for various incoming objects. Where a formatter is registered for the supplied type, the formatter is applied. If no formatter is supplied, the source objects toString() method is applied.

Specified by:
convert in interface org.apache.commons.beanutils.Converter
Parameters:
pTargetClass - The type to return. Only java.lang.String is allowed.
pSource - The object to be formatted
Returns:
The formatted String

setFormat

public final void setFormat(java.lang.Class pClass,
                            Format pFormat)
Add a Format for a class, replacing an existing format for the same class.

Parameters:
pClass - The class to apply the format for
pFormat - The format to set

setFormat

public final void setFormat(java.lang.Class pClass,
                            java.text.Format pFormat)
Convenience method to add a java.text.Format for a class, replacing an existing format for the same class.

Parameters:
pClass - The class to apply the format for
pFormat - The java.text.Format to set