Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.cantaloop.tools.conversion
Class AbstractConverter  view AbstractConverter download AbstractConverter.java

java.lang.Object
  extended byorg.cantaloop.tools.conversion.AbstractConverter
All Implemented Interfaces:
Converter
Direct Known Subclasses:
CollectionConverter, DateConverter, DateFormatter, IntegerConverter, IntegerLiteralConverter, IntLiteralConverter, LinkedConverter, SetConverter, SetLiteralConverter, StringConverter, StringLiteralConverter

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

AbstractConverter.java

Version:
@version@ ($Revision: 1.6 $)

Field Summary
private  boolean m_canConvertNull
           
protected  java.util.Set m_inputTypes
           
protected  java.util.Set m_outputTypes
           
 
Constructor Summary
protected AbstractConverter(java.lang.Class[] input, java.lang.Class[] output)
           
protected AbstractConverter(java.lang.Class[] input, java.lang.Class[] output, boolean canConvertNull)
           
protected AbstractConverter(java.lang.Class input, java.lang.Class output)
           
protected AbstractConverter(java.lang.Class input, java.lang.Class output, boolean canConvertNull)
           
protected AbstractConverter(java.util.Set sin, java.util.Set sout)
           
 
Method Summary
protected  java.lang.Class checkTypes(java.lang.Object obj, java.lang.Class type)
          Checks ifobj can converted to type.
 java.util.Set getInputTypes()
          Returns a set containing the classes that are supported as input types.
 java.util.Set getOutputTypes()
          Returns a set containing the classes that are supported as output types.
protected  void throwException(java.lang.Object o, java.lang.Class type)
          Throws a generic ConversionException.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.cantaloop.tools.conversion.Converter
convert
 

Field Detail

m_inputTypes

protected java.util.Set m_inputTypes

m_outputTypes

protected java.util.Set m_outputTypes

m_canConvertNull

private boolean m_canConvertNull
Constructor Detail

AbstractConverter

protected AbstractConverter(java.lang.Class input,
                            java.lang.Class output)

AbstractConverter

protected AbstractConverter(java.lang.Class input,
                            java.lang.Class output,
                            boolean canConvertNull)

AbstractConverter

protected AbstractConverter(java.lang.Class[] input,
                            java.lang.Class[] output)

AbstractConverter

protected AbstractConverter(java.lang.Class[] input,
                            java.lang.Class[] output,
                            boolean canConvertNull)

AbstractConverter

protected AbstractConverter(java.util.Set sin,
                            java.util.Set sout)
Method Detail

checkTypes

protected final java.lang.Class checkTypes(java.lang.Object obj,
                                           java.lang.Class type)
                                    throws ConversionException
Checks ifobj can converted to type. Subclasses should call this method from the convert method before performing the conversion. It also chooses the appropriate type if type is not contained in the output types but a supertype of it.


throwException

protected final void throwException(java.lang.Object o,
                                    java.lang.Class type)
                             throws ConversionException
Throws a generic ConversionException. Subclasses should only use this methods if no other information about the failure of the conversion are available.
Note: The ConversionException is always thrown.


getInputTypes

public java.util.Set getInputTypes()
Description copied from interface: Converter

Returns a set containing the classes that are supported as input types. Subtypes of these base classes have to be supported, too.

Example:
If the set contains java.util.List.class, any class that implements java.util.List must be supported.

Note:null is never a valid input type.

Specified by:
getInputTypes in interface Converter

getOutputTypes

public java.util.Set getOutputTypes()
Description copied from interface: Converter
Returns a set containing the classes that are supported as output types. It must be possible to convert each of the input types 55 to each of the output types.

Specified by:
getOutputTypes in interface Converter