org.oddjob.arooa.convert
Class DefaultConverter

java.lang.Object
  extended by org.oddjob.arooa.convert.DefaultConverter
All Implemented Interfaces:
ArooaConverter, ConversionLookup

public class DefaultConverter
extends Object
implements ArooaConverter

The Default ArooaConverter. This converter uses a ConversionLookup to provide the ConversionPath for the conversion. If none is provided the DefaultConversionLookup is used.

Author:
rob

Constructor Summary
DefaultConverter()
           
DefaultConverter(ConversionLookup convertlets)
          Only Constructor.
 
Method Summary
<F,T> T
convert(F from, Class<T> required)
          Perform a conversion.
<F,T> ConversionPath<F,T>
findConversion(Class<F> fromClass, Class<T> required)
          Find a conversion in the convertletRegistry.
 ConversionLookup getRegistry()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultConverter

public DefaultConverter(ConversionLookup convertlets)
Only Constructor.

Parameters:
convertlets - A ConvertletRegistry.

DefaultConverter

public DefaultConverter()
Method Detail

getRegistry

public ConversionLookup getRegistry()

convert

public <F,T> T convert(F from,
                       Class<T> required)
          throws NoConversionAvailableException,
                 ConversionFailedException
Perform a conversion. This is the main entry point method. It does the following.

Specified by:
convert in interface ArooaConverter
See Also:
ArooaConverter.convert(java.lang.Object, java.lang.Class)
Parameters:
from - The Object to convert. May be null.
required - The Class the object is to converted into.
Returns:
The converted object. Will be of the class given as the required parameter or null.
Throws:
NoConversionAvailableException - If ther is no conversion to the required type.
ConversionFailedException - If applying the conversion failed.

findConversion

public <F,T> ConversionPath<F,T> findConversion(Class<F> fromClass,
                                                Class<T> required)
Find a conversion in the convertletRegistry.

Specified by:
findConversion in interface ConversionLookup
Parameters:
fromClass - Class to convert from.
required - Class to convert to.
Returns:
A conversion path that can be used to perform the conversion.
Throws:
NoConversionAvailableException - If no conversion is available.