org.springframework.binding.convert.support
Class ConversionServiceAwareConverter

java.lang.Object
  extended by org.springframework.binding.convert.support.AbstractConverter
      extended by org.springframework.binding.convert.support.ConversionServiceAwareConverter
All Implemented Interfaces:
Converter, ConversionServiceAware
Direct Known Subclasses:
TextToClass, TextToMethodSignature

public abstract class ConversionServiceAwareConverter
extends AbstractConverter
implements ConversionServiceAware

Base class for converters that use other converters to convert things, thus they are conversion-service aware.

Author:
Keith Donald

Constructor Summary
protected ConversionServiceAwareConverter()
          Default constructor, expectes to conversion service to be injected using setConversionService(ConversionService).
protected ConversionServiceAwareConverter(ConversionService conversionService)
          Create a converter using given conversion service.
 
Method Summary
protected  ConversionExecutor converterFor(java.lang.Class sourceClass, java.lang.Class targetClass)
          Returns a conversion executor capable of converting objects from one class to another.
protected  ConversionExecutor fromStringTo(java.lang.Class targetClass)
          Returns a conversion executor capable of converting string objects to the specified target class.
protected  ConversionExecutor fromStringToAliased(java.lang.String targetAlias)
          Returns a conversion executor capable of converting string objects to the target class aliased by the provided alias.
 ConversionService getConversionService()
          Returns the conversion service used.
protected  Expression parseExpression(java.lang.String expressionString)
          Helper that parsers the given expression string into an expression, using the installed String->Expression converter.
 void setConversionService(ConversionService conversionService)
          Set the conversion service this object should be made aware of (as it presumably depends on it).
 
Methods inherited from class org.springframework.binding.convert.support.AbstractConverter
convert, convert, convert, convert, doConvert
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.binding.convert.Converter
getSourceClasses, getTargetClasses
 

Constructor Detail

ConversionServiceAwareConverter

protected ConversionServiceAwareConverter()
Default constructor, expectes to conversion service to be injected using setConversionService(ConversionService).


ConversionServiceAwareConverter

protected ConversionServiceAwareConverter(ConversionService conversionService)
Create a converter using given conversion service.

Method Detail

getConversionService

public ConversionService getConversionService()
Returns the conversion service used.


setConversionService

public void setConversionService(ConversionService conversionService)
Description copied from interface: ConversionServiceAware
Set the conversion service this object should be made aware of (as it presumably depends on it).

Specified by:
setConversionService in interface ConversionServiceAware
Parameters:
conversionService - the conversion service

fromStringTo

protected ConversionExecutor fromStringTo(java.lang.Class targetClass)
Returns a conversion executor capable of converting string objects to the specified target class.

Parameters:
targetClass - the target class
Returns:
the conversion executor, never null

fromStringToAliased

protected ConversionExecutor fromStringToAliased(java.lang.String targetAlias)
Returns a conversion executor capable of converting string objects to the target class aliased by the provided alias.

Parameters:
targetAlias - the target class alias, e.g "long" or "float"
Returns:
the conversion executor, or null if no suitable converter exists for alias

converterFor

protected ConversionExecutor converterFor(java.lang.Class sourceClass,
                                          java.lang.Class targetClass)
Returns a conversion executor capable of converting objects from one class to another.

Parameters:
sourceClass - the source class to convert from
targetClass - the target class to convert to
Returns:
the conversion executor, never null

parseExpression

protected Expression parseExpression(java.lang.String expressionString)
Helper that parsers the given expression string into an expression, using the installed String->Expression converter.

Parameters:
expressionString - the expression string to parse
Returns:
the parsed, evaluatable expression


Copyright © 2009 Spring Framework. All Rights Reserved.