|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.springframework.core.convert.support.GenericConversionService
public class GenericConversionService
Base implementation of a conversion service.
addConverter(Converter),
addConverterFactory(ConverterFactory)| Constructor Summary | |
|---|---|
GenericConversionService()
|
|
| Method Summary | ||
|---|---|---|
void |
addConverter(Converter<?,?> converter)
Add a converter to this registry. |
|
void |
addConverterFactory(ConverterFactory<?,?> converterFactory)
Add a ranged converter factory to this registry. |
|
protected void |
addGenericConverter(Class<?> sourceType,
Class<?> targetType,
GenericConverter converter)
Registers a GenericConverter. |
|
boolean |
canConvert(Class<?> sourceType,
Class<?> targetType)
Returns true if objects of sourceType can be converted to targetType. |
|
boolean |
canConvert(TypeDescriptor sourceType,
TypeDescriptor targetType)
Returns true if objects of sourceType can be converted to the targetType. |
|
|
convert(Object source,
Class<T> targetType)
Convert the source to targetType. |
|
Object |
convert(Object source,
TypeDescriptor sourceType,
TypeDescriptor targetType)
Convert the source to targetType. |
|
protected Object |
convertNull(TypeDescriptor sourceType,
TypeDescriptor targetType)
Hook method to convert a null value. |
|
protected GenericConverter |
getConverter(TypeDescriptor sourceType,
TypeDescriptor targetType)
Hook method to lookup the converter for a given sourceType/targetType pair. |
|
ConversionService |
getParent()
Returns the parent of this conversion service. |
|
void |
removeConvertible(Class<?> sourceType,
Class<?> targetType)
Remove the conversion logic for the sourceType to the targetType. |
|
void |
setConverterFactories(Set<ConverterFactory> converters)
Registers the converter factories in the set provided. |
|
void |
setConverters(Set<Converter> converters)
Registers the converters in the set provided. |
|
void |
setParent(ConversionService parent)
Set the parent of this conversion service. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public GenericConversionService()
| Method Detail |
|---|
public void setConverters(Set<Converter> converters)
addConverter(Converter).
addConverter(Converter)public void setConverterFactories(Set<ConverterFactory> converters)
addConverterFactory(ConverterFactory).
addConverterFactory(ConverterFactory)public void setParent(ConversionService parent)
public ConversionService getParent()
public void addConverter(Converter<?,?> converter)
ConverterRegistry
addConverter in interface ConverterRegistrypublic void addConverterFactory(ConverterFactory<?,?> converterFactory)
ConverterRegistry
addConverterFactory in interface ConverterRegistry
public void removeConvertible(Class<?> sourceType,
Class<?> targetType)
ConverterRegistry
removeConvertible in interface ConverterRegistrysourceType - the source typetargetType - the target type
public boolean canConvert(Class<?> sourceType,
Class<?> targetType)
ConversionService
canConvert in interface ConversionServicesourceType - the source type to convert from (required)targetType - the target type to convert to (required)
public <T> T convert(Object source,
Class<T> targetType)
ConversionService
convert in interface ConversionServicesource - the source object to convert (may be null)targetType - the target type to convert to (required)
public boolean canConvert(TypeDescriptor sourceType,
TypeDescriptor targetType)
ConversionService
canConvert in interface ConversionServicesourceType - context about the source type to convert from (required)targetType - context about the target type to convert to (required)
public Object convert(Object source,
TypeDescriptor sourceType,
TypeDescriptor targetType)
ConversionService
convert in interface ConversionServicesource - 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
protected void addGenericConverter(Class<?> sourceType,
Class<?> targetType,
GenericConverter converter)
sourceType - the source type to convert fromtargetType - the target type to convert toconverter - the generic converter.
protected Object convertNull(TypeDescriptor sourceType,
TypeDescriptor targetType)
null.
Subclasses may override to return a custom null objects for specific target types.
sourceType - the sourceTypetargetType - the tagetType
protected GenericConverter getConverter(TypeDescriptor sourceType,
TypeDescriptor targetType)
parent is set, then queries the parent.
If still no suitable Converter is found, returns a NO_OP Converter if the sourceType and targetType are assignable.
Returns null if this ConversionService simply cannot convert between sourceType and targetType.
Subclasses may override.
sourceType - the source type to convert fromtargetType - the target type to convert to
null if no suitable converter was found
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||