org.springframework.beans
Interface BeanWrapper

All Superinterfaces:
PropertyAccessor, PropertyEditorRegistry
All Known Implementing Classes:
BeanWrapperImpl

public interface BeanWrapper
extends PropertyAccessor, PropertyEditorRegistry

The central interface of Spring's low-level JavaBeans infrastructure. Extends the PropertyAccessor and PropertyEditorRegistry interfaces.

Typically not used directly but rather implicitly via a BeanFactory or a DataBinder.

Provides operations to analyze and manipulate standard JavaBeans: the ability to get and set property values (individually or in bulk), get property descriptors, and query the readability/writability of properties.

This interface supports nested properties enabling the setting of properties on subproperties to an unlimited depth. A BeanWrapper instance can be used repeatedly, with its target object (the wrapped JavaBean instance) changing as required.

A BeanWrapper instance can be used repeatedly, with its target object (the wrapped Java Bean instance) changing.

Since:
13 April 2001
Author:
Rod Johnson, Juergen Hoeller
See Also:
PropertyAccessor, PropertyEditorRegistry, BeanWrapperImpl, BeanFactory, DataBinder

Field Summary
 
Fields inherited from interface org.springframework.beans.PropertyAccessor
NESTED_PROPERTY_SEPARATOR, NESTED_PROPERTY_SEPARATOR_CHAR, PROPERTY_KEY_PREFIX, PROPERTY_KEY_PREFIX_CHAR, PROPERTY_KEY_SUFFIX, PROPERTY_KEY_SUFFIX_CHAR
 
Method Summary
 PropertyDescriptor getPropertyDescriptor(String propertyName)
          Obtain the property descriptor for a specific property of the wrapped object.
 PropertyDescriptor[] getPropertyDescriptors()
          Obtain the PropertyDescriptors for the wrapped object (as determined by standard JavaBeans introspection).
 Class getPropertyType(String propertyName)
          Determine the property type for the specified property, either checking the property descriptor or checking the value in case of an indexed or mapped element.
 Class getWrappedClass()
          Return the type of the wrapped JavaBean object.
 Object getWrappedInstance()
          Return the bean instance wrapped by this object, if any.
 boolean isExtractOldValueForEditor()
          Return whether to extract the old property value when applying a property editor to a new value for a property.
 boolean isReadableProperty(String propertyName)
          Determine whether the specified property is readable.
 boolean isWritableProperty(String propertyName)
          Determine whether the specified property is writable.
 void setExtractOldValueForEditor(boolean extractOldValueForEditor)
          Set whether to extract the old property value when applying a property editor to a new value for a property.
 void setWrappedInstance(Object obj)
          Change the wrapped JavaBean object.
 
Methods inherited from interface org.springframework.beans.PropertyAccessor
getPropertyValue, setPropertyValue, setPropertyValue, setPropertyValues, setPropertyValues, setPropertyValues
 
Methods inherited from interface org.springframework.beans.PropertyEditorRegistry
findCustomEditor, registerCustomEditor, registerCustomEditor
 

Method Detail

setWrappedInstance

void setWrappedInstance(Object obj)
Change the wrapped JavaBean object.

Parameters:
obj - the bean instance to wrap

getWrappedInstance

Object getWrappedInstance()
Return the bean instance wrapped by this object, if any.

Returns:
the bean instance, or null if none set

getWrappedClass

Class getWrappedClass()
Return the type of the wrapped JavaBean object.

Returns:
the type of the wrapped bean instance, or null if no wrapped object has been set

setExtractOldValueForEditor

void setExtractOldValueForEditor(boolean extractOldValueForEditor)
Set whether to extract the old property value when applying a property editor to a new value for a property.

Default is "false", avoiding side effects caused by getters. Turn this to "true" to expose previous property values to custom editors.


isExtractOldValueForEditor

boolean isExtractOldValueForEditor()
Return whether to extract the old property value when applying a property editor to a new value for a property.


getPropertyDescriptors

PropertyDescriptor[] getPropertyDescriptors()
Obtain the PropertyDescriptors for the wrapped object (as determined by standard JavaBeans introspection).

Returns:
the PropertyDescriptors for the wrapped object

getPropertyDescriptor

PropertyDescriptor getPropertyDescriptor(String propertyName)
                                         throws BeansException
Obtain the property descriptor for a specific property of the wrapped object.

Parameters:
propertyName - the property to obtain the descriptor for (may be a nested path, but no indexed/mapped property)
Returns:
the property descriptor for the specified property
Throws:
InvalidPropertyException - if there is no such property
BeansException

getPropertyType

Class getPropertyType(String propertyName)
                      throws BeansException
Determine the property type for the specified property, either checking the property descriptor or checking the value in case of an indexed or mapped element.

Parameters:
propertyName - property to check status for (may be a nested path and/or an indexed/mapped property)
Returns:
the property type for the particular property, or null if not determinable
Throws:
InvalidPropertyException - if there is no such property or if the property isn't readable
BeansException

isReadableProperty

boolean isReadableProperty(String propertyName)
Determine whether the specified property is readable.

Returns false if the property doesn't exist.

Parameters:
propertyName - property to check status for (may be a nested path and/or an indexed/mapped property)
Returns:
whether the property is readable

isWritableProperty

boolean isWritableProperty(String propertyName)
Determine whether the specified property is writable.

Returns false if the property doesn't exist.

Parameters:
propertyName - property to check status for (may be a nested path and/or an indexed/mapped property)
Returns:
whether the property is writable


Copyright (c) 2002-2007 The Spring Framework Project.