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

## org.springframework.beans
Class SimpleTypeConverter

    java.lang.Object
      org.springframework.beans.PropertyEditorRegistrySupport
          org.springframework.beans.SimpleTypeConverter

All Implemented Interfaces:
  PropertyEditorRegistry, TypeConverter

    public class SimpleTypeConverter

extends PropertyEditorRegistrySupport
implements TypeConverter

Simple implementation of the TypeConverter interface that does not operate on any specific target object. This is an alternative to using a full-blown BeanWrapperImpl instance for arbitrary type conversion needs.

Since:
  2.0
Author:
  Juergen Hoeller
See Also:
  `BeanWrapperImpl`

Constructor Summary
`SimpleTypeConverter()`

Method Summary
`Object` | `convertIfNecessary(Object value, Class requiredType)` Convert the value to the required type (if necessary from a String).
`Object` | `convertIfNecessary(Object value, Class requiredType, MethodParameter methodParam)` Convert the value to the required type (if necessary from a String).

Methods inherited from class org.springframework.beans.PropertyEditorRegistrySupport
`copyCustomEditorsTo, copyDefaultEditorsTo, findCustomEditor, getDefaultEditor, getPropertyType, guessPropertyTypeFromEditors, hasCustomEditorForElement, isSharedEditor, registerCustomEditor, registerCustomEditor, registerDefaultEditors, registerSharedEditor, useConfigValueEditors`

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

Constructor Detail

### SimpleTypeConverter

    public SimpleTypeConverter()

Method Detail

### convertIfNecessary

    public Object convertIfNecessary(Object value,
                                     Class requiredType)
                              throws TypeMismatchException

  Description copied from interface: `TypeConverter`
  Convert the value to the required type (if necessary from a String).

  Conversions from String to any type will typically use the `setAsText` method of the PropertyEditor class. Note that a PropertyEditor must be registered for the given class for this to work; this is a standard JavaBeans API. A number of PropertyEditors are automatically registered.

  Specified by:
    `convertIfNecessary` in interface `TypeConverter`
  Parameters:
    `value` - the value to convert
    `requiredType` - the type we must convert to (or `null` if not known, for example in case of a collection element)
  Returns:
    the new value, possibly the result of type conversion
  Throws:
    `TypeMismatchException` - if type conversion failed
  See Also:
    `PropertyEditor.setAsText(String)`, `PropertyEditor.getValue()`

### convertIfNecessary

    public Object convertIfNecessary(Object value,
                                     Class requiredType,
                                     MethodParameter methodParam)
                              throws TypeMismatchException

  Description copied from interface: `TypeConverter`
  Convert the value to the required type (if necessary from a String).

  Conversions from String to any type will typically use the `setAsText` method of the PropertyEditor class. Note that a PropertyEditor must be registered for the given class for this to work; this is a standard JavaBeans API. A number of PropertyEditors are automatically registered.

  Specified by:
    `convertIfNecessary` in interface `TypeConverter`
  Parameters:
    `value` - the value to convert
    `requiredType` - the type we must convert to (or `null` if not known, for example in case of a collection element)
    `methodParam` - the method parameter that is the target of the conversion (for analysis of generic types; may be `null`)
  Returns:
    the new value, possibly the result of type conversion
  Throws:
    `TypeMismatchException` - if type conversion failed
  See Also:
    `PropertyEditor.setAsText(String)`, `PropertyEditor.getValue()`

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

Copyright © 2002-2008 The Spring Framework.