org.springframework.expression.spel.support
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 the TypeConverter
interface,
delegating to a core Spring ConversionService
.
- Since:
- 3.0
- Author:
- Juergen Hoeller, Andy Clement
- See Also:
ConversionService
Method Summary |
boolean |
canConvert(Class<?> sourceType,
Class<?> targetType)
Return true if the type converter can convert the specified type to the desired target type. |
Object |
convertValue(Object value,
TypeDescriptor typeDescriptor)
Convert (may coerce) a value from one type to another, for example from a boolean to a string. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
StandardTypeConverter
public StandardTypeConverter()
StandardTypeConverter
public StandardTypeConverter(ConversionService conversionService)
canConvert
public boolean canConvert(Class<?> sourceType,
Class<?> targetType)
- Description copied from interface:
TypeConverter
- Return true if the type converter can convert the specified type to the desired target type.
- Specified by:
canConvert
in interface TypeConverter
- Parameters:
sourceType
- the type to be converted fromtargetType
- the type to be converted to
- Returns:
- true if that conversion can be performed
convertValue
public Object convertValue(Object value,
TypeDescriptor typeDescriptor)
throws EvaluationException
- Description copied from interface:
TypeConverter
- Convert (may coerce) a value from one type to another, for example from a boolean to a string.
The typeDescriptor parameter enables support for typed collections - if the caller really wishes they
can have a List for example, rather than simply a List.
- Specified by:
convertValue
in interface TypeConverter
- Parameters:
value
- the value to be convertedtypeDescriptor
- a type descriptor that supplies extra information about the requested result type
- Returns:
- the converted value
- Throws:
EvaluationException
- if conversion is not possible