java.lang.Object | |
↳ | org.springframework.core.convert.support.GenericConversionService |
Known Direct Subclasses |
Known Indirect Subclasses |
Base ConversionService
implementation suitable for use in most environments.
Implements ConverterRegistry
as registration API.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Add a plain converter to this registry.
| |||||||||||
Add a generic converter to this registry.
| |||||||||||
Add a ranged converter factory to this registry.
| |||||||||||
Returns true if objects of sourceType can be converted to the targetType.
| |||||||||||
Returns true if objects of sourceType can be converted to targetType.
| |||||||||||
Convert the source to targetType.
| |||||||||||
Convert the source to targetType.
| |||||||||||
Remove any converters from sourceType to targetType.
| |||||||||||
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Template method to convert a null source.
| |||||||||||
Hook method to lookup the converter for a given sourceType/targetType pair.
| |||||||||||
Return the default converter if no converter is found for the given sourceType/targetType pair.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
org.springframework.core.convert.ConversionService
| |||||||||||
From interface
org.springframework.core.convert.converter.ConverterRegistry
|
Add a plain converter to this registry.
Add a generic converter to this registry.
Add a ranged converter factory to this registry.
Returns true if objects of sourceType can be converted to the targetType. The TypeDescriptors provide additional context about the field locations where conversion would occur, often object property locations. This flavor of the canConvert operation exists mainly for use by a general purpose data mapping framework, and not for use by user code.
sourceType | context about the source type to convert from (required) |
---|---|
targetType | context about the target type to convert to (required) |
Returns true if objects of sourceType can be converted to targetType.
sourceType | the source type to convert from (required) |
---|---|
targetType | the target type to convert to (required) |
Convert the source to targetType.
source | the source object to convert (may be null) |
---|---|
targetType | the target type to convert to (required) |
Convert the source to targetType. The TypeDescriptors provide additional context about the field locations where conversion will occur, often object property locations. This flavor of the convert operation exists mainly for use by a general purpose data mapping framework, and not for use by user code.
source | the source object to convert (may be null) |
---|---|
sourceType | context about the source type converting from (required) |
targetType | context about the target type to convert to (required) |
targetType
Remove any converters from sourceType to targetType.
sourceType | the source type |
---|---|
targetType | the target type |
Template method to convert a null source.
Default implementation returns null
.
Throws a ConversionFailedException
if the targetType is a primitive type,
as null
cannot be assigned to a primitive type.
Subclasses may override to return custom null objects for specific target types.
sourceType | the sourceType to convert from |
---|---|
targetType | the targetType to convert to |
Hook method to lookup the converter for a given sourceType/targetType pair. First queries this ConversionService's converter cache. On a cache miss, then performs an exhaustive search for a matching converter. If no converter matches, returns the default converter. Subclasses may override.
sourceType | the source type to convert from |
---|---|
targetType | the target type to convert to |
null
if no suitable converter was foundReturn the default converter if no converter is found for the given sourceType/targetType pair.
Returns a NO_OP Converter if the sourceType is assignable to the targetType.
Returns null
otherwise, indicating no suitable converter could be found.
Subclasses may override.
sourceType | the source type to convert from |
---|---|
targetType | the target type to convert to |