Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Web Flow
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.binding.convert.service
Class GenericConversionService

    java.lang.Object
      org.springframework.binding.convert.service.GenericConversionService

All Implemented Interfaces:
  ConversionService

Direct Known Subclasses:
  DefaultConversionService

    public class GenericConversionService

extends java.lang.Object
implements ConversionService

Base implementation of a conversion service. Initially empty, e.g. no converters are registered by default.

Author:
  Keith Donald

Constructor Summary
`GenericConversionService()` Default constructor.
`GenericConversionService(org.springframework.core.convert.ConversionService delegateConversionService)` Constructor accepting a specific instance of a Spring ConversionService to delegate to.

Method Summary
`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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### GenericConversionService

    public GenericConversionService()

  Default constructor.

### GenericConversionService

    public GenericConversionService(org.springframework.core.convert.ConversionService delegateConversionService)

  Constructor accepting a specific instance of a Spring ConversionService to delegate to.

  Parameters:
    `delegateConversionService` - the conversion service

Method Detail

### getParent

    public ConversionService getParent()

  Returns the parent of this conversion service. Could be null.

### setParent

    public void setParent(ConversionService parent)

  Set the parent of this conversion service. This is optional.

### getDelegateConversionService

    public org.springframework.core.convert.ConversionService getDelegateConversionService()

  Description copied from interface: `ConversionService`
  Return the underlying Spring ConversionService.

  Specified by:
    `getDelegateConversionService` in interface `ConversionService`
  Returns:
    the Spring ConverterRegistry

### addConverter

    public void addConverter(Converter converter)

  Registers the given converter with the underlying Spring ConversionService with the help of an adapter. The adapter allows an existing Spring Binding converter to be invoked within Spring's type conversion system.

  Parameters:
    `converter` - the converter
  See Also:
    `ConverterRegistry`, `ConversionService`, `SpringBindingConverterAdapter`

### addConverter

    public 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).

  Add given custom converter to this conversion service. Note: Converters registered through this method will not be involve the Spring type conversion system, which is now used the default type conversion mechanism. Spring's type conversion does not support named converters. This method is provided for backwards compatibility.

  Parameters:
    `id` - the id of the custom converter instance
    `converter` - the converter

### addAlias

    public void addAlias(java.lang.String alias,
                         java.lang.Class targetType)

  Add an alias for given target type.

### getConversionExecutor

    public ConversionExecutor getConversionExecutor(java.lang.Class sourceClass,
                                                    java.lang.Class targetClass)
                                             throws ConversionExecutorNotFoundException

  Description copied from interface: `ConversionService`
  Return the default conversion executor 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 (required)
    `targetClass` - the target class to convert to (required)
  Returns:
    the executor that can execute instance type conversion, never null
  Throws:
    `ConversionExecutorNotFoundException` - when no suitable conversion executor could be found

### getConversionExecutor

    public ConversionExecutor getConversionExecutor(java.lang.String id,
                                                    java.lang.Class sourceClass,
                                                    java.lang.Class targetClass)
                                             throws ConversionExecutorNotFoundException

  Description copied from interface: `ConversionService`
  Return the custom conversion executor 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:
    `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)
  Returns:
    the executor that can execute instance type conversion, never null
  Throws:
    `ConversionExecutorNotFoundException` - when no suitable conversion executor could be found

### executeConversion

    public java.lang.Object executeConversion(java.lang.Object source,
                                              java.lang.Class targetClass)
                                       throws ConversionException

  Description copied from interface: `ConversionService`
  Execute a conversion of the source object provided to the specified `targetClass`

  Specified by:
    `executeConversion` in interface `ConversionService`
  Parameters:
    `source` - the source to convert from (may be null)
    `targetClass` - the target class to convert to
  Returns:
    the converted object, an instance of the `targetClass`
  Throws:
    `ConversionException` - if an exception occurred during the conversion process

### executeConversion

    public java.lang.Object executeConversion(java.lang.String converterId,
                                              java.lang.Object source,
                                              java.lang.Class targetClass)
                                       throws ConversionException

  Description copied from interface: `ConversionService`
  Execute a conversion using the custom converter with the provided id.

  Specified by:
    `executeConversion` in interface `ConversionService`
  Parameters:
    `converterId` - the id of the custom converter, which must be registered with this conversion service and capable of converting to the target class
    `source` - the source to convert from (may be null)
    `targetClass` - the target class to convert to
  Returns:
    the converted object, an instance of the `targetClass`
  Throws:
    `ConversionException` - if an exception occurred during the conversion process

### getClassForAlias

    public java.lang.Class getClassForAlias(java.lang.String name)
                                     throws java.lang.IllegalArgumentException

  Description copied from interface: `ConversionService`
  Lookup a class by its well-known alias. For example, `long` for `java.lang.Long`

  Specified by:
    `getClassForAlias` in interface `ConversionService`
  Parameters:
    `name` - the class alias
  Returns:
    the class, or `null` if no alias exists
  Throws:
    `java.lang.IllegalArgumentException`

Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Web Flow
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD