public class GenericConversionService extends java.lang.Object implements ConversionService
| Constructor and Description |
|---|
GenericConversionService()
Default constructor.
|
GenericConversionService(org.springframework.core.convert.ConversionService delegateConversionService)
Constructor accepting a specific instance of a Spring ConversionService to delegate to.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAlias(java.lang.String alias,
java.lang.Class targetType)
Add an alias for given target type.
|
void |
addConverter(Converter converter)
Registers the given converter with the underlying Spring ConversionService with the help of an adapter.
|
void |
addConverter(java.lang.String id,
Converter converter)
Deprecated.
use
addConverter(Converter) instead or better yet use Spring 3 type conversion and
formatting options (see Spring Documentation). |
java.lang.Object |
executeConversion(java.lang.Object source,
java.lang.Class targetClass)
Execute a conversion of the source object provided to the specified
targetClass |
java.lang.Object |
executeConversion(java.lang.String converterId,
java.lang.Object source,
java.lang.Class targetClass)
Execute a conversion using the custom converter with the provided id.
|
java.lang.Class |
getClassForAlias(java.lang.String name)
Lookup a class by its well-known alias.
|
ConversionExecutor |
getConversionExecutor(java.lang.Class sourceClass,
java.lang.Class targetClass)
Return the default conversion executor capable of converting source objects of the specified
sourceClass to instances of the targetClass. |
ConversionExecutor |
getConversionExecutor(java.lang.String id,
java.lang.Class sourceClass,
java.lang.Class targetClass)
Return the custom conversion executor capable of converting source objects of the specified
sourceClass to instances of the targetClass. |
org.springframework.core.convert.ConversionService |
getDelegateConversionService()
Return the underlying Spring ConversionService.
|
ConversionService |
getParent()
Returns the parent of this conversion service.
|
void |
setParent(ConversionService parent)
Set the parent of this conversion service.
|
public GenericConversionService()
public GenericConversionService(org.springframework.core.convert.ConversionService delegateConversionService)
delegateConversionService - the conversion servicepublic ConversionService getParent()
public void setParent(ConversionService parent)
public org.springframework.core.convert.ConversionService getDelegateConversionService()
ConversionServicegetDelegateConversionService in interface ConversionServicepublic void addConverter(Converter converter)
converter - the converterConverterRegistry,
ConversionService,
SpringBindingConverterAdapterpublic void addConverter(java.lang.String id,
Converter converter)
addConverter(Converter) instead or better yet use Spring 3 type conversion and
formatting options (see Spring Documentation).id - the id of the custom converter instanceconverter - the converterpublic void addAlias(java.lang.String alias,
java.lang.Class targetType)
public ConversionExecutor getConversionExecutor(java.lang.Class sourceClass, java.lang.Class targetClass) throws ConversionExecutorNotFoundException
ConversionServicesourceClass to instances of the targetClass.
The returned ConversionExecutor is thread-safe and may safely be cached for use in client code.
getConversionExecutor in interface ConversionServicesourceClass - the source class to convert from (required)targetClass - the target class to convert to (required)ConversionExecutorNotFoundException - when no suitable conversion executor could be foundpublic ConversionExecutor getConversionExecutor(java.lang.String id, java.lang.Class sourceClass, java.lang.Class targetClass) throws ConversionExecutorNotFoundException
ConversionServicesourceClass to instances of the targetClass.
The returned ConversionExecutor is thread-safe and may safely be cached for use in client code.
getConversionExecutor in interface ConversionServiceid - the id of the custom conversion executor (required)sourceClass - the source class to convert from (required)targetClass - the target class to convert to (required)ConversionExecutorNotFoundException - when no suitable conversion executor could be foundpublic java.lang.Object executeConversion(java.lang.Object source,
java.lang.Class targetClass)
throws ConversionException
ConversionServicetargetClassexecuteConversion in interface ConversionServicesource - the source to convert from (may be null)targetClass - the target class to convert totargetClassConversionException - if an exception occurred during the conversion processpublic java.lang.Object executeConversion(java.lang.String converterId,
java.lang.Object source,
java.lang.Class targetClass)
throws ConversionException
ConversionServiceexecuteConversion in interface ConversionServiceconverterId - the id of the custom converter, which must be registered with this conversion service and
capable of converting to the target classsource - the source to convert from (may be null)targetClass - the target class to convert totargetClassConversionException - if an exception occurred during the conversion processpublic java.lang.Class getClassForAlias(java.lang.String name)
throws java.lang.IllegalArgumentException
ConversionServicelong for java.lang.LonggetClassForAlias in interface ConversionServicename - the class aliasnull if no alias existsjava.lang.IllegalArgumentException