Class StandardTypeConverter
- java.lang.Object
- org.springframework.expression.spel.support.StandardTypeConverter
- All Implemented Interfaces:
TypeConverter
public class StandardTypeConverter extends Object implements TypeConverter
Default implementation of theTypeConverter
interface, delegating to a core SpringConversionService
.- Since:
- 3.0
- Author:
- Juergen Hoeller, Andy Clement
- See Also:
ConversionService
Constructor Summary
Constructors Constructor Description StandardTypeConverter()
Create a StandardTypeConverter for the default ConversionService.StandardTypeConverter(ConversionService conversionService)
Create a StandardTypeConverter for the given ConversionService.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canConvert(TypeDescriptor sourceType, TypeDescriptor targetType)
Returntrue
if the type converter can convert the specified type to the desired target type.Object
convertValue(Object value, TypeDescriptor sourceType, TypeDescriptor targetType)
Convert (or coerce) a value from one type to another, for example from aboolean
to aString
.
Constructor Detail
StandardTypeConverter
public StandardTypeConverter()
Create a StandardTypeConverter for the default ConversionService.
StandardTypeConverter
public StandardTypeConverter(ConversionService conversionService)
Create a StandardTypeConverter for the given ConversionService.- Parameters:
conversionService
- the ConversionService to delegate to
Method Detail
canConvert
public boolean canConvert(TypeDescriptor sourceType, TypeDescriptor targetType)
Description copied from interface:TypeConverter
Returntrue
if the type converter can convert the specified type to the desired target type.- Specified by:
canConvert
in interfaceTypeConverter
- Parameters:
sourceType
- a type descriptor that describes the source typetargetType
- a type descriptor that describes the requested result type- Returns:
true
if that conversion can be performed
convertValue
public Object convertValue(Object value, TypeDescriptor sourceType, TypeDescriptor targetType)
Description copied from interface:TypeConverter
Convert (or coerce) a value from one type to another, for example from aboolean
to aString
.The
TypeDescriptor
parameters enable support for typed collections: A caller may prefer aList<Integer>
, for example, rather than simply anyList
.- Specified by:
convertValue
in interfaceTypeConverter
- Parameters:
value
- the value to be convertedsourceType
- a type descriptor that supplies extra information about the source objecttargetType
- a type descriptor that supplies extra information about the requested result type- Returns:
- the converted value