org.springframework.binding.convert.support
Class CompositeConversionService

java.lang.Object
  extended by org.springframework.binding.convert.support.CompositeConversionService
All Implemented Interfaces:
ConversionService

public class CompositeConversionService
extends java.lang.Object
implements ConversionService

A conversion service that delegates to an ordered chain of other conversion services. The first correct reply received from a conversion service in the chain is returned to the caller.

Author:
Erwin Vervaet

Constructor Summary
CompositeConversionService(ConversionService[] conversionServices)
          Create a new composite conversion service.
 
Method Summary
 java.lang.Class getClassByAlias(java.lang.String alias)
          Return the class with the specified alias.
 ConversionExecutor getConversionExecutor(java.lang.Class sourceClass, java.lang.Class targetClass)
          Return a conversion executor command object capable of converting source objects of the specified sourceClass to instances of the targetClass.
 ConversionExecutor getConversionExecutorByTargetAlias(java.lang.Class sourceClass, java.lang.String targetAlias)
          Return a conversion executor command object capable of converting source objects of the specified sourceClass to target objects of the type associated with the specified alias.
 ConversionExecutor[] getConversionExecutorsForSource(java.lang.Class sourceClass)
          Return all conversion executors capable of converting source objects of the the specified sourceClass.
 ConversionService[] getConversionServices()
          Returns the conversion services in the chain managed by this composite conversion service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompositeConversionService

public CompositeConversionService(ConversionService[] conversionServices)
Create a new composite conversion service.

Parameters:
conversionServices - the conversion services in the chain
Method Detail

getConversionServices

public ConversionService[] getConversionServices()
Returns the conversion services in the chain managed by this composite conversion service.


getConversionExecutor

public ConversionExecutor getConversionExecutor(java.lang.Class sourceClass,
                                                java.lang.Class targetClass)
                                         throws ConversionException
Description copied from interface: ConversionService
Return a conversion executor command object capable of converting source objects of the specified sourceClass to instances of the targetClass.

The returned ConversionExecutor is thread-safe and may safely be cached for use in client code.

Specified by:
getConversionExecutor in interface ConversionService
Parameters:
sourceClass - the source class to convert from
targetClass - the target class to convert to
Returns:
the executor that can execute instance conversion, never null
Throws:
ConversionException - an exception occured retrieving a converter for the source-to-target pair

getConversionExecutorByTargetAlias

public ConversionExecutor getConversionExecutorByTargetAlias(java.lang.Class sourceClass,
                                                             java.lang.String targetAlias)
                                                      throws ConversionException
Description copied from interface: ConversionService
Return a conversion executor command object capable of converting source objects of the specified sourceClass to target objects of the type associated with the specified alias.

Specified by:
getConversionExecutorByTargetAlias in interface ConversionService
Parameters:
sourceClass - the sourceClass
targetAlias - the target alias
Returns:
the conversion executor, or null if the alias cannot be found
Throws:
ConversionException - an exception occured retrieving a converter for the source-to-target pair

getConversionExecutorsForSource

public ConversionExecutor[] getConversionExecutorsForSource(java.lang.Class sourceClass)
                                                     throws ConversionException
Description copied from interface: ConversionService
Return all conversion executors capable of converting source objects of the the specified sourceClass.

Specified by:
getConversionExecutorsForSource in interface ConversionService
Parameters:
sourceClass - the source class to convert from
Returns:
the matching conversion executors
Throws:
ConversionException - an exception occured retrieving the converters

getClassByAlias

public java.lang.Class getClassByAlias(java.lang.String alias)
                                throws ConversionException
Description copied from interface: ConversionService
Return the class with the specified alias.

Specified by:
getClassByAlias in interface ConversionService
Parameters:
alias - the class alias
Returns:
the class, or null if not aliased
Throws:
ConversionException - when an error occurs looking up the class by alias


Copyright © 2009 Spring Framework. All Rights Reserved.