public class BeanWrapperImpl
extends org.springframework.beans.AbstractPropertyAccessor
implements org.springframework.beans.BeanWrapper
BeanWrapper implementation that should be sufficient
for all typical use cases. Caches introspection results for efficiency.
Note: Auto-registers default property editors from the
org.springframework.beans.propertyeditors package, which apply
in addition to the JDK's standard PropertyEditors. Applications can call
the PropertyEditorRegistrySupport.registerCustomEditor(Class, java.beans.PropertyEditor) method
to register an editor for a particular instance (i.e. they are not shared
across the application). See the base class
PropertyEditorRegistrySupport for details.
BeanWrapperImpl will convert collection and array values
to the corresponding target collections or arrays, if necessary. Custom
property editors that deal with collections or arrays can either be
written via PropertyEditor's setValue, or against a
comma-delimited String via setAsText, as String arrays are
converted in such a format if the array itself is not assignable.
NOTE: As of Spring 2.5, this is - for almost all purposes - an
internal class. It is just public in order to allow for access from
other framework packages. For standard application access purposes, use the
PropertyAccessorFactory.forBeanPropertyAccess(java.lang.Object) factory method instead.
PropertyEditorRegistrySupport.registerCustomEditor(java.lang.Class, java.beans.PropertyEditor),
AbstractPropertyAccessor.setPropertyValues(java.util.Map),
setPropertyValue(java.lang.String, java.lang.Object),
getPropertyValue(java.lang.String),
getPropertyType(java.lang.String),
BeanWrapper,
PropertyEditorRegistrySupport| 构造器和说明 |
|---|
BeanWrapperImpl()
Create new empty BeanWrapperImpl.
|
BeanWrapperImpl(boolean registerDefaultEditors)
Create new empty BeanWrapperImpl.
|
BeanWrapperImpl(Class clazz)
Create new BeanWrapperImpl, wrapping a new instance of the specified class.
|
BeanWrapperImpl(Object object)
Create new BeanWrapperImpl for the given object.
|
BeanWrapperImpl(Object object,
String nestedPath,
Object rootObject)
Create new BeanWrapperImpl for the given object,
registering a nested path that the object is in.
|
| 限定符和类型 | 方法和说明 |
|---|---|
Object |
convertForProperty(Object value,
String propertyName)
Convert the given value for the specified property to the latter's type.
|
Object |
convertIfNecessary(Object value,
Class requiredType,
org.springframework.core.MethodParameter methodParam) |
Object |
doTypeConversionIfNecessary(Object value,
Class requiredType)
已过时。
in favor of
convertIfNecessary |
protected BeanWrapperImpl |
getBeanWrapperForPropertyPath(String propertyPath)
Recursively navigate to return a BeanWrapper for the nested property path.
|
String |
getNestedPath()
Return the nested path of the object wrapped by this BeanWrapper.
|
PropertyDescriptor |
getPropertyDescriptor(String propertyName) |
protected PropertyDescriptor |
getPropertyDescriptorInternal(String propertyName)
Internal version of
getPropertyDescriptor(java.lang.String):
Returns null if not found rather than throwing an exception. |
PropertyDescriptor[] |
getPropertyDescriptors() |
Class |
getPropertyType(String propertyName) |
Object |
getPropertyValue(String propertyName) |
Class |
getRootClass()
Return the class of the root object at the top of the path of this BeanWrapper.
|
Object |
getRootInstance()
Return the root object at the top of the path of this BeanWrapper.
|
Class |
getWrappedClass() |
Object |
getWrappedInstance() |
boolean |
isAutoGrowNestedPaths()
If this BeanWrapper should "auto grow" nested paths.
|
boolean |
isReadableProperty(String propertyName) |
boolean |
isWritableProperty(String propertyName) |
protected BeanWrapperImpl |
newNestedBeanWrapper(Object object,
String nestedPath)
Create a new nested BeanWrapper instance.
|
void |
setAutoGrowNestedPaths(boolean autoGrowNestedPaths)
If this BeanWrapper should "auto grow" nested paths.
|
protected void |
setIntrospectionClass(Class clazz)
Set the class to introspect.
|
void |
setPropertyValue(PropertyValue pv) |
void |
setPropertyValue(String propertyName,
Object value) |
void |
setWrappedInstance(Object object)
Switch the target object, replacing the cached introspection results only
if the class of the new object is different to that of the replaced object.
|
void |
setWrappedInstance(Object object,
String nestedPath,
Object rootObject)
Switch the target object, replacing the cached introspection results only
if the class of the new object is different to that of the replaced object.
|
String |
toString() |
convertIfNecessary, isExtractOldValueForEditor, setExtractOldValueForEditor, setPropertyValue, setPropertyValues, setPropertyValues, setPropertyValues, setPropertyValuescopyCustomEditorsTo, copyDefaultEditorsTo, findCustomEditor, getDefaultEditor, guessPropertyTypeFromEditors, hasCustomEditorForElement, isSharedEditor, registerCustomEditor, registerCustomEditor, registerDefaultEditors, registerSharedEditor, useConfigValueEditorsclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitisExtractOldValueForEditor, setExtractOldValueForEditorsetPropertyValue, setPropertyValues, setPropertyValues, setPropertyValues, setPropertyValuespublic BeanWrapperImpl()
public BeanWrapperImpl(boolean registerDefaultEditors)
registerDefaultEditors - whether to register default editors
(can be suppressed if the BeanWrapper won't need any type conversion)setWrappedInstance(java.lang.Object)public BeanWrapperImpl(Object object)
object - object wrapped by this BeanWrapperpublic BeanWrapperImpl(Class clazz)
clazz - class to instantiate and wrappublic BeanWrapperImpl(Object object, String nestedPath, Object rootObject)
object - object wrapped by this BeanWrappernestedPath - the nested path of the objectrootObject - the root object at the top of the pathpublic void setAutoGrowNestedPaths(boolean autoGrowNestedPaths)
public boolean isAutoGrowNestedPaths()
public void setWrappedInstance(Object object)
setWrappedInstance 在接口中 org.springframework.beans.BeanWrapperobject - the new target objectpublic void setWrappedInstance(Object object, String nestedPath, Object rootObject)
object - the new target objectnestedPath - the nested path of the objectrootObject - the root object at the top of the pathpublic final Object getWrappedInstance()
getWrappedInstance 在接口中 org.springframework.beans.BeanWrapperpublic final Class getWrappedClass()
getWrappedClass 在接口中 org.springframework.beans.BeanWrapperpublic final String getNestedPath()
public final Object getRootInstance()
getNestedPath()public final Class getRootClass()
getNestedPath()protected void setIntrospectionClass(Class clazz)
clazz - the class to introspectpublic PropertyDescriptor[] getPropertyDescriptors()
getPropertyDescriptors 在接口中 org.springframework.beans.BeanWrapperpublic PropertyDescriptor getPropertyDescriptor(String propertyName) throws org.springframework.beans.BeansException
getPropertyDescriptor 在接口中 org.springframework.beans.BeanWrapperorg.springframework.beans.BeansExceptionprotected PropertyDescriptor getPropertyDescriptorInternal(String propertyName) throws org.springframework.beans.BeansException
getPropertyDescriptor(java.lang.String):
Returns null if not found rather than throwing an exception.propertyName - the property to obtain the descriptor fornull if not foundorg.springframework.beans.BeansException - in case of introspection failurepublic Class getPropertyType(String propertyName) throws org.springframework.beans.BeansException
getPropertyType 在接口中 org.springframework.beans.PropertyAccessorgetPropertyType 在类中 org.springframework.beans.AbstractPropertyAccessororg.springframework.beans.BeansExceptionpublic boolean isReadableProperty(String propertyName)
isReadableProperty 在接口中 org.springframework.beans.PropertyAccessorpublic boolean isWritableProperty(String propertyName)
isWritableProperty 在接口中 org.springframework.beans.PropertyAccessorpublic Object doTypeConversionIfNecessary(Object value, Class requiredType) throws org.springframework.beans.TypeMismatchException
convertIfNecessaryorg.springframework.beans.TypeMismatchExceptionAbstractPropertyAccessor.convertIfNecessary(Object, Class)public Object convertIfNecessary(Object value, Class requiredType, org.springframework.core.MethodParameter methodParam) throws org.springframework.beans.TypeMismatchException
convertIfNecessary 在接口中 org.springframework.beans.TypeConverterorg.springframework.beans.TypeMismatchExceptionpublic Object convertForProperty(Object value, String propertyName) throws org.springframework.beans.TypeMismatchException
This method is only intended for optimizations in a BeanFactory.
Use the convertIfNecessary methods for programmatic conversion.
value - the value to convertpropertyName - the target property
(note that nested or indexed properties are not supported here)org.springframework.beans.TypeMismatchException - if type conversion failedprotected BeanWrapperImpl getBeanWrapperForPropertyPath(String propertyPath)
propertyPath - property property path, which may be nestedprotected BeanWrapperImpl newNestedBeanWrapper(Object object, String nestedPath)
Default implementation creates a BeanWrapperImpl instance. Can be overridden in subclasses to create a BeanWrapperImpl subclass.
object - object wrapped by this BeanWrappernestedPath - the nested path of the objectpublic Object getPropertyValue(String propertyName) throws org.springframework.beans.BeansException
getPropertyValue 在接口中 org.springframework.beans.PropertyAccessorgetPropertyValue 在类中 org.springframework.beans.AbstractPropertyAccessororg.springframework.beans.BeansExceptionpublic void setPropertyValue(String propertyName, Object value) throws org.springframework.beans.BeansException
setPropertyValue 在接口中 org.springframework.beans.PropertyAccessorsetPropertyValue 在类中 org.springframework.beans.AbstractPropertyAccessororg.springframework.beans.BeansExceptionpublic void setPropertyValue(PropertyValue pv) throws org.springframework.beans.BeansException
org.springframework.beans.BeansExceptionCopyright © 2006-2013 开源组织. All Rights Reserved.