|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.binding.convert.service.GenericConversionService
public class GenericConversionService
Base implementation of a conversion service. Initially empty, e.g. no converters are registered by default.
Constructor Summary | |
---|---|
GenericConversionService()
|
Method Summary | |
---|---|
void |
addAlias(java.lang.String alias,
java.lang.Class targetType)
Add an alias for given target type. |
void |
addConverter(Converter converter)
Add given converter to this conversion service. |
void |
addConverter(java.lang.String id,
Converter converter)
Add given custom converter to this conversion service. |
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 . |
java.util.Set |
getConversionExecutors(java.lang.Class sourceClass)
Return all conversion executors capable of converting from the provided sourceClass . |
protected Converter |
getConverter(java.lang.Class sourceClass,
java.lang.Class targetClass)
Returns a registered converter object |
ConversionService |
getParent()
Returns the parent of this conversion service. |
protected java.util.Map |
getSourceClassConverters()
Returns an indexed map of converters. |
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 ConversionService getParent()
public void setParent(ConversionService parent)
public void addConverter(Converter converter)
converter
- the converterpublic void addConverter(java.lang.String id, Converter converter)
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
ConversionService
sourceClass
to instances of the targetClass
.
The returned ConversionExecutor is thread-safe and may safely be cached for use in client code.
getConversionExecutor
in interface ConversionService
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 ConversionExecutor getConversionExecutor(java.lang.String id, java.lang.Class sourceClass, java.lang.Class targetClass) throws ConversionExecutorNotFoundException
ConversionService
sourceClass
to instances of the targetClass
.
The returned ConversionExecutor is thread-safe and may safely be cached for use in client code.
getConversionExecutor
in interface ConversionService
id
- 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
ConversionService
targetClass
executeConversion
in interface ConversionService
source
- the source to convert from (may be null)targetClass
- the target class to convert to
targetClass
ConversionException
- 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
ConversionService
executeConversion
in interface ConversionService
converterId
- 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 to
targetClass
ConversionException
- if an exception occurred during the conversion processpublic java.lang.Class getClassForAlias(java.lang.String name) throws java.lang.IllegalArgumentException
ConversionService
long
for java.lang.Long
getClassForAlias
in interface ConversionService
name
- the class alias
null
if no alias exists
java.lang.IllegalArgumentException
public java.util.Set getConversionExecutors(java.lang.Class sourceClass)
ConversionService
sourceClass
. For
example, getConversionExecutor(String.class)
would return all converters that convert from String to
some other Object. Mainly useful for adapting a set of converters to some other environment.
getConversionExecutors
in interface ConversionService
sourceClass
- the source class converting from
protected java.util.Map getSourceClassConverters()
protected Converter getConverter(java.lang.Class sourceClass, java.lang.Class targetClass)
sourceClass
- the source classtargetClass
- the target class
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |