org.apache.commons.convert
Class AbstractConverter<S,T>

java.lang.Object
  extended by org.apache.commons.convert.AbstractConverter<S,T>
All Implemented Interfaces:
Converter<S,T>, ConverterLoader
Direct Known Subclasses:
AbstractLocalizedConverter, BooleanConverters.BooleanToInteger, BooleanConverters.IntegerToBoolean, BooleanConverters.StringToBoolean, CollectionConverters.ArrayToList, DateTimeConverters.CalendarToDate, DateTimeConverters.CalendarToLong, DateTimeConverters.CalendarToTimestamp, DateTimeConverters.DateToSqlDate, DateTimeConverters.DateToSqlTime, DateTimeConverters.DateToTimestamp, DateTimeConverters.GenericDateToLong, DateTimeConverters.LongToDate, DateTimeConverters.LongToSqlDate, DateTimeConverters.LongToSqlTime, DateTimeConverters.LongToTimestamp, DateTimeConverters.SqlDateToDate, DateTimeConverters.SqlDateToTimestamp, DateTimeConverters.StringToTimeZone, DateTimeConverters.TimestampToDate, DateTimeConverters.TimestampToSqlDate, DateTimeConverters.TimestampToSqlTime, DateTimeConverters.TimeZoneToString, GenericSingletonToList, GenericSingletonToSet, GenericToStringConverter, MiscConverters.BlobToByteArray, MiscConverters.ByteArrayToByteBuffer, MiscConverters.ByteBufferToByteArray, MiscConverters.CharsetToString, MiscConverters.ClobToString, MiscConverters.DecimalFormatToString, MiscConverters.EnumToString, MiscConverters.SimpleDateFormatToString, MiscConverters.StringToCharset, MiscConverters.StringToDecimalFormat, MiscConverters.StringToLocale, MiscConverters.StringToRegexPattern, MiscConverters.StringToSimpleDateFormat, MiscConverters.StringToUUID, NetConverters.InetAddressToString, NetConverters.StringToInetAddress, NetConverters.StringToURI, NetConverters.StringToURL, NetConverters.URIToURL, NetConverters.URLToURI, NumberConverters.GenericNumberToBigDecimal, NumberConverters.GenericNumberToBigInteger, NumberConverters.GenericNumberToByte, NumberConverters.GenericNumberToDouble, NumberConverters.GenericNumberToFloat, NumberConverters.GenericNumberToInteger, NumberConverters.GenericNumberToLong, NumberConverters.GenericNumberToShort, NumberConverters.LongToBigDecimal, NumberConverters.StringToByte, NumberConverters.StringToShort

public abstract class AbstractConverter<S,T>
extends Object
implements Converter<S,T>, ConverterLoader

Abstract converter class. This class handles converter registration and it implements some of the Converter methods.


Constructor Summary
protected AbstractConverter(Class<? super S> sourceClass, Class<? super T> targetClass)
           
 
Method Summary
 boolean canConvert(Class<?> sourceClass, Class<?> targetClass)
          Returns true if this object can convert sourceClass to targetClass.
 Class<? super S> getSourceClass()
          Returns the source Class for this converter.
 Class<? super T> getTargetClass()
          Returns the target Class for this converter.
 void loadConverters()
          Create and register converters with the Java object type conversion framework.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.convert.Converter
convert
 

Constructor Detail

AbstractConverter

protected AbstractConverter(Class<? super S> sourceClass,
                            Class<? super T> targetClass)
Method Detail

loadConverters

public void loadConverters()
Description copied from interface: ConverterLoader
Create and register converters with the Java object type conversion framework. If the converter extends one of the converter abstract classes, then the converter will register itself when an instance is created. Otherwise, call Converters.registerConverter(Converter) with the Converter instance.

Specified by:
loadConverters in interface ConverterLoader

canConvert

public boolean canConvert(Class<?> sourceClass,
                          Class<?> targetClass)
Description copied from interface: Converter
Returns true if this object can convert sourceClass to targetClass.

Implementations can accomodate class hierarchy ranges by converting super classes or interfaces.

Specified by:
canConvert in interface Converter<S,T>
Parameters:
sourceClass - The source Class
targetClass - The target Class
Returns:
true if this object can convert sourceClass to targetClass.

getSourceClass

public Class<? super S> getSourceClass()
Description copied from interface: Converter
Returns the source Class for this converter.

Specified by:
getSourceClass in interface Converter<S,T>
Returns:
The source Class for this converter

getTargetClass

public Class<? super T> getTargetClass()
Description copied from interface: Converter
Returns the target Class for this converter.

Specified by:
getTargetClass in interface Converter<S,T>
Returns:
The target Class for this converter


Copyright © 2003-2013 The Apache Software Foundation. All Rights Reserved.