java.lang.Object | |||
↳ | org.springframework.beans.PropertyEditorRegistrySupport | ||
↳ | org.springframework.beans.AbstractPropertyAccessor | ||
↳ | org.springframework.beans.BeanWrapperImpl |
Default 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 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
forBeanPropertyAccess(Object)
factory method instead.
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
org.springframework.beans.PropertyAccessor
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create new empty BeanWrapperImpl.
| |||||||||||
Create new empty BeanWrapperImpl.
| |||||||||||
Create new BeanWrapperImpl for the given object.
| |||||||||||
Create new BeanWrapperImpl, wrapping a new instance of the specified class.
| |||||||||||
Create new BeanWrapperImpl for the given object,
registering a nested path that the object is in.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Convert the given value for the specified property to the latter's type.
| |||||||||||
Convert the value to the required type (if necessary from a String).
| |||||||||||
Return the nested path of the object wrapped by this BeanWrapper.
| |||||||||||
Obtain the property descriptor for a specific property
of the wrapped object.
| |||||||||||
Obtain the PropertyDescriptors for the wrapped object
(as determined by standard JavaBeans introspection).
| |||||||||||
Determine the property type for the given property path.
| |||||||||||
Return a type descriptor for the specified property:
preferably from the read method, falling back to the write method.
| |||||||||||
Actually get the value of a property.
| |||||||||||
Return the class of the root object at the top of the path of this BeanWrapper.
| |||||||||||
Return the root object at the top of the path of this BeanWrapper.
| |||||||||||
Return the security context used during the invocation of the wrapped instance methods.
| |||||||||||
Return the type of the wrapped JavaBean object.
| |||||||||||
Return the bean instance wrapped by this object, if any.
| |||||||||||
If this BeanWrapper should "auto grow" nested paths.
| |||||||||||
Determine whether the specified property is readable.
| |||||||||||
Determine whether the specified property is writable.
| |||||||||||
If this BeanWrapper should "auto grow" nested paths.
| |||||||||||
Actually set a property value.
| |||||||||||
Set the specified value as current property value.
| |||||||||||
Set the security context used during the invocation of the wrapped instance methods.
| |||||||||||
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.
| |||||||||||
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.
| |||||||||||
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Recursively navigate to return a BeanWrapper for the nested property path.
| |||||||||||
Internal version of
getPropertyDescriptor(String) :
Returns null if not found rather than throwing an exception. | |||||||||||
Create a new nested BeanWrapper instance.
| |||||||||||
Set the class to introspect.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.beans.AbstractPropertyAccessor
| |||||||||||
From class
org.springframework.beans.PropertyEditorRegistrySupport
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
org.springframework.beans.BeanWrapper
| |||||||||||
From interface
org.springframework.beans.ConfigurablePropertyAccessor
| |||||||||||
From interface
org.springframework.beans.PropertyAccessor
| |||||||||||
From interface
org.springframework.beans.PropertyEditorRegistry
| |||||||||||
From interface
org.springframework.beans.TypeConverter
|
Create new empty BeanWrapperImpl. Wrapped instance needs to be set afterwards. Registers default editors.
Create new empty BeanWrapperImpl. Wrapped instance needs to be set afterwards.
registerDefaultEditors | whether to register default editors (can be suppressed if the BeanWrapper won't need any type conversion) |
---|
Create new BeanWrapperImpl for the given object.
object | object wrapped by this BeanWrapper |
---|
Create new BeanWrapperImpl, wrapping a new instance of the specified class.
clazz | class to instantiate and wrap |
---|
Create new BeanWrapperImpl for the given object, registering a nested path that the object is in.
object | object wrapped by this BeanWrapper |
---|---|
nestedPath | the nested path of the object |
rootObject | the root object at the top of the path |
Convert the given value for the specified property to the latter's type.
This method is only intended for optimizations in a BeanFactory.
Use the convertIfNecessary
methods for programmatic conversion.
value | the value to convert |
---|---|
propertyName | the target property (note that nested or indexed properties are not supported here) |
TypeMismatchException | if type conversion failed |
---|
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.
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 ) |
TypeMismatchException |
---|
Return the nested path of the object wrapped by this BeanWrapper.
Obtain the property descriptor for a specific property of the wrapped object.
propertyName | the property to obtain the descriptor for (may be a nested path, but no indexed/mapped property) |
---|
BeansException |
---|
Obtain the PropertyDescriptors for the wrapped object (as determined by standard JavaBeans introspection).
Determine the property type for the given property path.
Called by findCustomEditor(Class, String)
if no required type has been specified,
to be able to find a type-specific editor even if just given a property path.
The default implementation always returns null
.
BeanWrapperImpl overrides this with the standard getPropertyType
method as defined by the BeanWrapper interface.
propertyName | the property path to determine the type for |
---|
null
if not determinableBeansException |
---|
Return a type descriptor for the specified property: preferably from the read method, falling back to the write method.
propertyName | the property to check (may be a nested path and/or an indexed/mapped property) |
---|
null
if not determinableBeansException |
---|
Actually get the value of a property.
propertyName | name of the property to get the value of |
---|
BeansException |
---|
Return the class of the root object at the top of the path of this BeanWrapper.
Return the root object at the top of the path of this BeanWrapper.
Return the security context used during the invocation of the wrapped instance methods. Can be null.
Return the type of the wrapped JavaBean object.
null
if no wrapped object has been set
Return the bean instance wrapped by this object, if any.
null
if none set
If this BeanWrapper should "auto grow" nested paths.
Determine whether the specified property is readable.
Returns false
if the property doesn't exist.
propertyName | the property to check (may be a nested path and/or an indexed/mapped property) |
---|
Determine whether the specified property is writable.
Returns false
if the property doesn't exist.
propertyName | the property to check (may be a nested path and/or an indexed/mapped property) |
---|
If this BeanWrapper should "auto grow" nested paths. When true, auto growth is triggered on nested paths when null values are encountered. When true, auto growth is triggered on collection properties when out of bounds indexes are accessed. Default is false.
Actually set a property value.
propertyName | name of the property to set value of |
---|---|
value | the new value |
BeansException |
---|
Set the specified value as current property value.
pv | an object containing the new property value |
---|
BeansException |
---|
Set the security context used during the invocation of the wrapped instance methods. Can be null.
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.
object | the new target 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.
object | the new target object |
---|---|
nestedPath | the nested path of the object |
rootObject | the root object at the top of the path |
Recursively navigate to return a BeanWrapper for the nested property path.
propertyPath | property property path, which may be nested |
---|
Internal version of getPropertyDescriptor(String)
:
Returns null
if not found rather than throwing an exception.
propertyName | the property to obtain the descriptor for |
---|
null
if not foundBeansException | in case of introspection failure |
---|
Create a new nested BeanWrapper instance.
Default implementation creates a BeanWrapperImpl instance. Can be overridden in subclasses to create a BeanWrapperImpl subclass.
object | object wrapped by this BeanWrapper |
---|---|
nestedPath | the nested path of the object |
Set the class to introspect. Needs to be called when the target object changes.
clazz | the class to introspect |
---|