com.fdsapi
Class ConverterBase

java.lang.Object
  |
  +--com.fdsapi.ConverterBase
All Implemented Interfaces:
Converter
Direct Known Subclasses:
ConverterDateToString, ConverterMapValue, ConverterNumToString

public abstract class ConverterBase
extends java.lang.Object
implements Converter

Base class for Converter objects used to convert an input Object to an output Object. This class implements the decorator design pattern that allows the chaining of Converters together. Each one checking the passed in data and taking action if appropriate. The last decorator in the chain takes action first and passes the CHANGED output Object up the chain and further action may be taken by other Converters at this point. Keep in mind that the Object being passed up the change for action may not be the same type as the input Object was. For example a Date may go down the chain and a Date converted to a String may come up the chain. The last Converter in the chain is always the NullConverter which simply returns the input Object.

View Code


Constructor Summary
ConverterBase()
          Creates a new instance of ConverterBase
ConverterBase(Converter nextConverter)
          Constructor that takes the next Converter in the decorator chain
 
Method Summary
 Converter createInstance()
           
protected abstract  Converter createInstance(Converter nextConverter)
          This method returns the usable copy of this object.
protected  java.lang.Object decoratorConvert(java.lang.Object inputObj)
          This method calls the decorator chain of Converters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.fdsapi.Converter
convert
 

Constructor Detail

ConverterBase

public ConverterBase()
Creates a new instance of ConverterBase


ConverterBase

public ConverterBase(Converter nextConverter)
Constructor that takes the next Converter in the decorator chain

Method Detail

decoratorConvert

protected java.lang.Object decoratorConvert(java.lang.Object inputObj)
This method calls the decorator chain of Converters. In general the last Converter in the chain takes the first action, and the first converters in the chain act on this methods return value and not the inputObj local variable.


createInstance

public Converter createInstance()
Specified by:
createInstance in interface Converter

createInstance

protected abstract Converter createInstance(Converter nextConverter)
This method returns the usable copy of this object. Note it is passed the next Converter so it can recreate the whole chain of converters in the copied/clone/returned instance.