The Spring Framework

org.springframework.beans
Class TypeConverterDelegate

java.lang.Object
  extended by org.springframework.beans.TypeConverterDelegate

 class TypeConverterDelegate
extends Object

Internal helper class for converting property values to target types.

Works on a given PropertyEditorRegistrySupport instance. Used as a delegate by BeanWrapperImpl and SimpleTypeConverter.

Since:
2.0
Author:
Juergen Hoeller
See Also:
BeanWrapperImpl, SimpleTypeConverter

Constructor Summary
TypeConverterDelegate(PropertyEditorRegistrySupport propertyEditorRegistry)
          Create a new TypeConverterDelegate for the given editor registry.
TypeConverterDelegate(PropertyEditorRegistrySupport propertyEditorRegistry, Object targetObject)
          Create a new TypeConverterDelegate for the given editor registry and bean instance.
 
Method Summary
 Object convertIfNecessary(Object newValue, Class requiredType, MethodParameter methodParam)
          Convert the value to the specified required type.
 Object convertIfNecessary(Object oldValue, Object newValue, PropertyDescriptor descriptor)
          Convert the value to the required type for the specified property.
 Object convertIfNecessary(String propertyName, Object oldValue, Object newValue, Class requiredType)
          Convert the value to the required type for the specified property.
protected  Object convertIfNecessary(String propertyName, Object oldValue, Object newValue, Class requiredType, PropertyDescriptor descriptor, MethodParameter methodParam)
          Convert the value to the required type (if necessary from a String), for the specified property.
protected  Object convertToTypedArray(Object input, String propertyName, Class componentType)
           
protected  Collection convertToTypedCollection(Collection original, String propertyName, MethodParameter methodParam)
           
protected  Map convertToTypedMap(Map original, String propertyName, MethodParameter methodParam)
           
protected  Object convertValue(Object newValue, Class requiredType, PropertyEditor pe, Object oldValue)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypeConverterDelegate

public TypeConverterDelegate(PropertyEditorRegistrySupport propertyEditorRegistry)
Create a new TypeConverterDelegate for the given editor registry.

Parameters:
propertyEditorRegistry - the editor registry to use

TypeConverterDelegate

public TypeConverterDelegate(PropertyEditorRegistrySupport propertyEditorRegistry,
                             Object targetObject)
Create a new TypeConverterDelegate for the given editor registry and bean instance.

Parameters:
propertyEditorRegistry - the editor registry to use
targetObject - the target object to work on (as context that can be passed to editors)
Method Detail

convertIfNecessary

public Object convertIfNecessary(Object newValue,
                                 Class requiredType,
                                 MethodParameter methodParam)
                          throws IllegalArgumentException
Convert the value to the specified required type.

Parameters:
newValue - proposed change value
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 (may be null)
Returns:
the new value, possibly the result of type conversion
Throws:
IllegalArgumentException - if type conversion failed

convertIfNecessary

public Object convertIfNecessary(String propertyName,
                                 Object oldValue,
                                 Object newValue,
                                 Class requiredType)
                          throws IllegalArgumentException
Convert the value to the required type for the specified property.

Parameters:
propertyName - name of the property
oldValue - previous value, if available (may be null)
newValue - proposed change value
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:
IllegalArgumentException - if type conversion failed

convertIfNecessary

public Object convertIfNecessary(Object oldValue,
                                 Object newValue,
                                 PropertyDescriptor descriptor)
                          throws IllegalArgumentException
Convert the value to the required type for the specified property.

Parameters:
oldValue - previous value, if available (may be null)
newValue - proposed change value
descriptor - the JavaBeans descriptor for the property
Returns:
the new value, possibly the result of type conversion
Throws:
IllegalArgumentException - if type conversion failed

convertIfNecessary

protected Object convertIfNecessary(String propertyName,
                                    Object oldValue,
                                    Object newValue,
                                    Class requiredType,
                                    PropertyDescriptor descriptor,
                                    MethodParameter methodParam)
                             throws IllegalArgumentException
Convert the value to the required type (if necessary from a String), for the specified property.

Parameters:
propertyName - name of the property
oldValue - previous value, if available (may be null)
newValue - proposed change value
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 (may be null)
Returns:
the new value, possibly the result of type conversion
Throws:
IllegalArgumentException - if type conversion failed

convertValue

protected Object convertValue(Object newValue,
                              Class requiredType,
                              PropertyEditor pe,
                              Object oldValue)

convertToTypedArray

protected Object convertToTypedArray(Object input,
                                     String propertyName,
                                     Class componentType)

convertToTypedCollection

protected Collection convertToTypedCollection(Collection original,
                                              String propertyName,
                                              MethodParameter methodParam)

convertToTypedMap

protected Map convertToTypedMap(Map original,
                                String propertyName,
                                MethodParameter methodParam)

The Spring Framework

Copyright © 2002-2006 The Spring Framework.