|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.beans.TypeConverterDelegate
class TypeConverterDelegate
Internal helper class for converting property values to target types.
Works on a given PropertyEditorRegistrySupport
instance.
Used as a delegate by BeanWrapperImpl
and SimpleTypeConverter
.
BeanWrapperImpl
,
SimpleTypeConverter
Field Summary | |
---|---|
private static Log |
logger
|
private PropertyEditorRegistrySupport |
propertyEditorRegistry
|
private java.lang.Object |
targetObject
|
Constructor Summary | |
---|---|
TypeConverterDelegate(PropertyEditorRegistrySupport propertyEditorRegistry)
Create a new TypeConverterDelegate for the given editor registry. |
|
TypeConverterDelegate(PropertyEditorRegistrySupport propertyEditorRegistry,
java.lang.Object targetObject)
Create a new TypeConverterDelegate for the given editor registry and bean instance. |
Method Summary | ||
---|---|---|
private java.lang.Object |
attemptToConvertStringToEnum(java.lang.Class<?> requiredType,
java.lang.String trimmedValue,
java.lang.Object currentConvertedValue)
|
|
private java.lang.String |
buildIndexedPropertyName(java.lang.String propertyName,
int index)
|
|
private java.lang.String |
buildKeyedPropertyName(java.lang.String propertyName,
java.lang.Object key)
|
|
private boolean |
canCreateCopy(java.lang.Class requiredType)
|
|
|
convertIfNecessary(java.lang.Object newValue,
java.lang.Class<T> requiredType,
MethodParameter methodParam)
Convert the value to the specified required type. |
|
|
convertIfNecessary(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue,
java.lang.Class<T> requiredType)
Convert the value to the required type for the specified property. |
|
|
convertIfNecessary(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue,
java.lang.Class<T> requiredType,
TypeDescriptor typeDescriptor)
Convert the value to the required type (if necessary from a String), for the specified property. |
|
protected java.lang.Object |
convertToTypedArray(java.lang.Object input,
java.lang.String propertyName,
java.lang.Class<?> componentType)
|
|
protected java.util.Collection |
convertToTypedCollection(java.util.Collection original,
java.lang.String propertyName,
java.lang.Class requiredType,
TypeDescriptor typeDescriptor)
|
|
protected java.util.Map |
convertToTypedMap(java.util.Map original,
java.lang.String propertyName,
java.lang.Class requiredType,
TypeDescriptor typeDescriptor)
|
|
protected java.lang.Object |
doConvertTextValue(java.lang.Object oldValue,
java.lang.String newTextValue,
java.beans.PropertyEditor editor)
Convert the given text value using the given property editor. |
|
protected java.lang.Object |
doConvertValue(java.lang.Object oldValue,
java.lang.Object newValue,
java.lang.Class<?> requiredType,
java.beans.PropertyEditor editor)
Convert the value to the required type (if necessary from a String), using the given property editor. |
|
protected java.beans.PropertyEditor |
findDefaultEditor(java.lang.Class requiredType,
TypeDescriptor typeDescriptor)
Find a default editor for the given type. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Log logger
private final PropertyEditorRegistrySupport propertyEditorRegistry
private final java.lang.Object targetObject
Constructor Detail |
---|
public TypeConverterDelegate(PropertyEditorRegistrySupport propertyEditorRegistry)
propertyEditorRegistry
- the editor registry to usepublic TypeConverterDelegate(PropertyEditorRegistrySupport propertyEditorRegistry, java.lang.Object targetObject)
propertyEditorRegistry
- the editor registry to usetargetObject
- the target object to work on (as context that can be passed to editors)Method Detail |
---|
public <T> T convertIfNecessary(java.lang.Object newValue, java.lang.Class<T> requiredType, MethodParameter methodParam) throws java.lang.IllegalArgumentException
newValue
- the proposed new valuerequiredType
- 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
)
java.lang.IllegalArgumentException
- if type conversion failedpublic <T> T convertIfNecessary(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue, java.lang.Class<T> requiredType) throws java.lang.IllegalArgumentException
propertyName
- name of the propertyoldValue
- the previous value, if available (may be null
)newValue
- the proposed new valuerequiredType
- the type we must convert to
(or null
if not known, for example in case of a collection element)
java.lang.IllegalArgumentException
- if type conversion failedpublic <T> T convertIfNecessary(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue, java.lang.Class<T> requiredType, TypeDescriptor typeDescriptor) throws java.lang.IllegalArgumentException
propertyName
- name of the propertyoldValue
- the previous value, if available (may be null
)newValue
- the proposed new valuerequiredType
- the type we must convert to
(or null
if not known, for example in case of a collection element)typeDescriptor
- the descriptor for the target property or field
java.lang.IllegalArgumentException
- if type conversion failedprivate java.lang.Object attemptToConvertStringToEnum(java.lang.Class<?> requiredType, java.lang.String trimmedValue, java.lang.Object currentConvertedValue)
protected java.beans.PropertyEditor findDefaultEditor(java.lang.Class requiredType, TypeDescriptor typeDescriptor)
requiredType
- the type to find an editor fordescriptor
- the JavaBeans descriptor for the property
null
if noneprotected java.lang.Object doConvertValue(java.lang.Object oldValue, java.lang.Object newValue, java.lang.Class<?> requiredType, java.beans.PropertyEditor editor)
oldValue
- the previous value, if available (may be null
)newValue
- the proposed new valuerequiredType
- the type we must convert to
(or null
if not known, for example in case of a collection element)editor
- the PropertyEditor to use
java.lang.IllegalArgumentException
- if type conversion failedprotected java.lang.Object doConvertTextValue(java.lang.Object oldValue, java.lang.String newTextValue, java.beans.PropertyEditor editor)
oldValue
- the previous value, if available (may be null
)newTextValue
- the proposed text valueeditor
- the PropertyEditor to use
protected java.lang.Object convertToTypedArray(java.lang.Object input, java.lang.String propertyName, java.lang.Class<?> componentType)
protected java.util.Collection convertToTypedCollection(java.util.Collection original, java.lang.String propertyName, java.lang.Class requiredType, TypeDescriptor typeDescriptor)
protected java.util.Map convertToTypedMap(java.util.Map original, java.lang.String propertyName, java.lang.Class requiredType, TypeDescriptor typeDescriptor)
private java.lang.String buildIndexedPropertyName(java.lang.String propertyName, int index)
private java.lang.String buildKeyedPropertyName(java.lang.String propertyName, java.lang.Object key)
private boolean canCreateCopy(java.lang.Class requiredType)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |