net.sf.molae.pipe.text
Class FormatTransformer

java.lang.Object
  |
  +--net.sf.molae.pipe.text.FormatTransformer
All Implemented Interfaces:
Transformer, TwoWayTransformer

public final class FormatTransformer
extends Object
implements TwoWayTransformer

A text format as a transformer.


Constructor Summary
FormatTransformer(Format base)
          Creates a new FormatTransformer based on the specified format.
FormatTransformer(Format base, boolean injective)
          Creates a new FormatTransformer based on the specified format.
 
Method Summary
 boolean isRetrievable(Object input)
          Returns the value specified in the constructor.
 Object retransform(Object input)
          Calls parseObject(String) of the underlying format.
 String toString()
          Returns a string representation of the object.
 Object transform(Object input)
          Calls format(Object) of the underlying format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FormatTransformer

public FormatTransformer(Format base,
                         boolean injective)
Creates a new FormatTransformer based on the specified format.
Parameters:
base - the base format
injective - indicates if this transformer is injective for all objects except null
Throws:
NullPointerException - base is null.

FormatTransformer

public FormatTransformer(Format base)
Creates a new FormatTransformer based on the specified format. It is assumed that the transformation is injective.
Parameters:
base - the base format
Throws:
NullPointerException - base is null.
Method Detail

toString

public String toString()
Returns a string representation of the object.
Overrides:
toString in class Object
Returns:
a string representation of the object.

transform

public Object transform(Object input)
Calls format(Object) of the underlying format.
Specified by:
transform in interface Transformer
Throws:
IllegalArgumentException - if the Format cannot format the type of object

retransform

public Object retransform(Object input)
Calls parseObject(String) of the underlying format.
Specified by:
retransform in interface TwoWayTransformer
Throws:
ClassCastException - if the input object is not a string
IllegalArgumentException - if a parsing exception occurred

isRetrievable

public boolean isRetrievable(Object input)
Returns the value specified in the constructor.
Specified by:
isRetrievable in interface TwoWayTransformer
Following copied from interface: net.sf.molae.pipe.trafo.TwoWayTransformer
Parameters:
input - the object for which the transformation origin is searched.
Returns:
true if the origin of the specified object can be calculated.