|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The central interface of Spring's low-level JavaBeans infrastructure. Typically not directly used by application code but rather implicitly via a BeanFactory or a DataBinder.
To be implemented by classes that can manipulate Java beans. Implementing classes have the ability to get and set property values (individually or in bulk), get property descriptors and query the readability and writability of properties.
This interface supports nested properties enabling the setting of properties on subproperties to an unlimited depth.
If a property update causes an exception, a PropertyVetoException will be thrown. Bulk updates continue after exceptions are encountered, throwing an exception wrapping all exceptions encountered during the update.
BeanWrapper implementations can be used repeatedly, with their "target" or wrapped object changed.
BeanFactory
,
DataBinder
Field Summary | |
static java.lang.String |
NESTED_PROPERTY_SEPARATOR
Path separator for nested properties. |
Method Summary | |
java.beans.PropertyEditor |
findCustomEditor(java.lang.Class requiredType,
java.lang.String propertyPath)
Find a custom property editor for the given type and property. |
java.beans.PropertyDescriptor |
getPropertyDescriptor(java.lang.String propertyName)
Get the property descriptor for a particular property. |
java.beans.PropertyDescriptor[] |
getPropertyDescriptors()
Get the PropertyDescriptors identified on this object (standard JavaBeans introspection). |
java.lang.Object |
getPropertyValue(java.lang.String propertyName)
Get the value of a property. |
java.lang.Class |
getWrappedClass()
Convenience method to return the class of the wrapped object. |
java.lang.Object |
getWrappedInstance()
Return the bean wrapped by this object (cannot be null). |
boolean |
isReadableProperty(java.lang.String propertyName)
Return whether this property is readable. |
boolean |
isWritableProperty(java.lang.String propertyName)
Return whether this property is writable. |
void |
registerCustomEditor(java.lang.Class requiredType,
java.beans.PropertyEditor propertyEditor)
Register the given custom property editor for all properties of the given type. |
void |
registerCustomEditor(java.lang.Class requiredType,
java.lang.String propertyPath,
java.beans.PropertyEditor propertyEditor)
Register the given custom property editor for the given type and property, or for all properties of the given type. |
void |
setPropertyValue(PropertyValue pv)
Update a property value. |
void |
setPropertyValue(java.lang.String propertyName,
java.lang.Object value)
Set a property value. |
void |
setPropertyValues(java.util.Map map)
Perform a bulk update from a Map. |
void |
setPropertyValues(PropertyValues pvs)
The preferred way to perform a bulk update. |
void |
setPropertyValues(PropertyValues pvs,
boolean ignoreUnknown)
Perform a bulk update with full control over behavior. |
void |
setWrappedInstance(java.lang.Object obj)
Change the wrapped object. |
Field Detail |
public static final java.lang.String NESTED_PROPERTY_SEPARATOR
Method Detail |
public void setWrappedInstance(java.lang.Object obj) throws BeansException
obj
- wrapped object that we are manipulating
BeansException
public java.lang.Object getWrappedInstance()
public java.lang.Class getWrappedClass()
public void registerCustomEditor(java.lang.Class requiredType, java.beans.PropertyEditor propertyEditor)
requiredType
- type of the propertypropertyEditor
- editor to registerpublic void registerCustomEditor(java.lang.Class requiredType, java.lang.String propertyPath, java.beans.PropertyEditor propertyEditor)
requiredType
- type of the property, can be null if a property is
given but should be specified in any case for consistency checkingpropertyPath
- path of the property (name or nested path), or
null if registering an editor for all properties of the given typepropertyEditor
- editor to registerpublic java.beans.PropertyEditor findCustomEditor(java.lang.Class requiredType, java.lang.String propertyPath)
requiredType
- type of the property, can be null if a property is
given but should be specified in any case for consistency checkingpropertyPath
- path of the property (name or nested path), or
null if looking for an editor for all properties of the given type
public java.lang.Object getPropertyValue(java.lang.String propertyName) throws BeansException
propertyName
- name of the property to get the value of
FatalBeanException
- if there is no such property, if the property
isn't readable, or if the property getter throws an exception.
BeansException
public void setPropertyValue(java.lang.String propertyName, java.lang.Object value) throws BeansException
propertyName
- name of the property to set value ofvalue
- the new value
BeansException
public void setPropertyValue(PropertyValue pv) throws BeansException
pv
- object containing new property value
BeansException
public void setPropertyValues(java.util.Map map) throws BeansException
Bulk updates from PropertyValues are more powerful: This method is provided for convenience. Behaviour will be identical to that of the setPropertyValues(PropertyValues) method.
map
- Map to take properties from. Contains property value objects,
keyed by property name
BeansException
public void setPropertyValues(PropertyValues pvs) throws BeansException
Note that performing a bulk update differs from performing a single update, in that an implementation of this class will continue to update properties if a recoverable error (such as a vetoed property change or a type mismatch, but not an invalid fieldname or the like) is encountered, throwing a PropertyAccessExceptionsException containing all the individual errors. This exception can be examined later to see all binding errors. Properties that were successfully updated stay changed.
Does not allow unknown fields. Equivalent to setPropertyValues(pvs, false, null).
pvs
- PropertyValues to set on the target object
BeansException
public void setPropertyValues(PropertyValues pvs, boolean ignoreUnknown) throws BeansException
Does not allow unknown fields.
pvs
- PropertyValues to set on the target objectignoreUnknown
- should we ignore unknown values (not found in the bean!?)
BeansException
public java.beans.PropertyDescriptor[] getPropertyDescriptors() throws BeansException
BeansException
public java.beans.PropertyDescriptor getPropertyDescriptor(java.lang.String propertyName) throws BeansException
propertyName
- property to check status for
FatalBeanException
- if there is no such property
BeansException
public boolean isReadableProperty(java.lang.String propertyName)
propertyName
- property to check status for
public boolean isWritableProperty(java.lang.String propertyName)
propertyName
- property to check status for
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |