Spring Web Flow

org.springframework.binding.convert.converters
Interface Converter

All Known Subinterfaces:
TwoWayConverter
All Known Implementing Classes:
ArrayToArray, ArrayToCollection, CollectionToCollection, DataModelConverter, FormattedStringToNumber, NumberToNumber, ObjectToArray, ObjectToCollection, PropertyEditorConverter, ReverseConverter, SpringConvertingConverterAdapter, StringToBigDecimal, StringToBigInteger, StringToBoolean, StringToByte, StringToCharacter, StringToClass, StringToDate, StringToDouble, StringToEnum, StringToFloat, StringToInteger, StringToLabeledEnum, StringToLocale, StringToLong, StringToObject, StringToShort

public interface Converter

A converter is capable of converting a source object of type getSourceClass() to a target type of type getTargetClass(). If the converter is a TwoWayConverter, it can also convert from the target back to the source.

Implementations of this interface are thread-safe and can be shared.

Author:
Keith Donald

Method Summary
 java.lang.Object convertSourceToTargetClass(java.lang.Object source, java.lang.Class<?> targetClass)
          Convert the provided source object argument to an instance of the specified target class.
 java.lang.Class<?> getSourceClass()
          The source class this converter can convert from.
 java.lang.Class<?> getTargetClass()
          The target class this converter can convert to.
 

Method Detail

getSourceClass

java.lang.Class<?> getSourceClass()
The source class this converter can convert from. May be an interface or abstract type to allow this converter to convert specific subclasses as well.

Returns:
the source type

getTargetClass

java.lang.Class<?> getTargetClass()
The target class this converter can convert to. May be an interface or abstract type to allow this converter to convert specific subclasses as well.

Returns:
the target type

convertSourceToTargetClass

java.lang.Object convertSourceToTargetClass(java.lang.Object source,
                                            java.lang.Class<?> targetClass)
                                            throws java.lang.Exception
Convert the provided source object argument to an instance of the specified target class.

Parameters:
source - the source object to convert, which must be an instance of getSourceClass()
targetClass - the target class to convert the source to, which must be equal to or a specialization of getTargetClass()
Returns:
the converted object, which must be an instance of the targetClass
Throws:
java.lang.Exception - an exception occurred performing the conversion

Spring Web Flow