The Spring Framework

org.springframework.beans
Interface PropertyAccessor

All Known Subinterfaces:
BeanWrapper, ConfigurablePropertyAccessor
All Known Implementing Classes:
AbstractPropertyAccessor, BeanWrapperImpl, DirectFieldAccessor

public interface PropertyAccessor

Common interface for classes that can access bean properties. Serves as base interface for BeanWrapper.

Since:
1.1
Author:
Juergen Hoeller
See Also:
BeanWrapper

Field Summary
static String NESTED_PROPERTY_SEPARATOR
          Path separator for nested properties.
static char NESTED_PROPERTY_SEPARATOR_CHAR
           
static String PROPERTY_KEY_PREFIX
          Marker that indicates the start of a property key for an indexed or mapped property like "person.addresses[0]".
static char PROPERTY_KEY_PREFIX_CHAR
           
static String PROPERTY_KEY_SUFFIX
          Marker that indicates the end of a property key for an indexed or mapped property like "person.addresses[0]".
static char PROPERTY_KEY_SUFFIX_CHAR
           
 
Method Summary
 Class getPropertyType(String propertyName)
          Determine the property type for a particular property, either checking the property descriptor or checking the value in case of an indexed or mapped element.
 Object getPropertyValue(String propertyName)
          Get the value of a property.
 boolean isReadableProperty(String propertyName)
          Return whether this property is readable.
 boolean isWritableProperty(String propertyName)
          Return whether this property is writable.
 void setPropertyValue(PropertyValue pv)
          Set a property value.
 void setPropertyValue(String propertyName, Object value)
          Set a property value.
 void setPropertyValues(Map map)
          Perform a batch update from a Map.
 void setPropertyValues(PropertyValues pvs)
          The preferred way to perform a batch update.
 void setPropertyValues(PropertyValues pvs, boolean ignoreUnknown)
          Perform a batch update with more control over behavior.
 void setPropertyValues(PropertyValues pvs, boolean ignoreUnknown, boolean ignoreInvalid)
          Perform a batch update with full control over behavior.
 

Field Detail

NESTED_PROPERTY_SEPARATOR

static final String NESTED_PROPERTY_SEPARATOR
Path separator for nested properties. Follows normal Java conventions: getFoo().getBar() would be "foo.bar".

See Also:
Constant Field Values

NESTED_PROPERTY_SEPARATOR_CHAR

static final char NESTED_PROPERTY_SEPARATOR_CHAR
See Also:
Constant Field Values

PROPERTY_KEY_PREFIX

static final String PROPERTY_KEY_PREFIX
Marker that indicates the start of a property key for an indexed or mapped property like "person.addresses[0]".

See Also:
Constant Field Values

PROPERTY_KEY_PREFIX_CHAR

static final char PROPERTY_KEY_PREFIX_CHAR
See Also:
Constant Field Values

PROPERTY_KEY_SUFFIX

static final String PROPERTY_KEY_SUFFIX
Marker that indicates the end of a property key for an indexed or mapped property like "person.addresses[0]".

See Also:
Constant Field Values

PROPERTY_KEY_SUFFIX_CHAR

static final char PROPERTY_KEY_SUFFIX_CHAR
See Also:
Constant Field Values
Method Detail

isReadableProperty

boolean isReadableProperty(String propertyName)
                           throws BeansException
Return whether this property is readable. Returns false if the property doesn't exist.

Parameters:
propertyName - property to check status for
Returns:
whether this property is readable
Throws:
BeansException

isWritableProperty

boolean isWritableProperty(String propertyName)
                           throws BeansException
Return whether this property is writable. Returns false if the property doesn't exist.

Parameters:
propertyName - property to check status for
Returns:
whether this property is writable
Throws:
BeansException

getPropertyType

Class getPropertyType(String propertyName)
                      throws BeansException
Determine the property type for a particular 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
Returns:
the property type for the particular property, or null if not determinable
Throws:
BeansException

getPropertyValue

Object getPropertyValue(String propertyName)
                        throws BeansException
Get the value of a property.

Parameters:
propertyName - name of the property to get the value of
Returns:
the value of the property
Throws:
InvalidPropertyException - if there is no such property or if the property isn't readable
PropertyAccessException - if the property was valid but the accessor method failed
BeansException

setPropertyValue

void setPropertyValue(String propertyName,
                      Object value)
                      throws BeansException
Set a property value.

Parameters:
propertyName - name of the property to set value of
value - the new value
Throws:
InvalidPropertyException - if there is no such property or if the property isn't writable
PropertyAccessException - if the property was valid but the accessor method failed or a type mismatch occured
BeansException

setPropertyValue

void setPropertyValue(PropertyValue pv)
                      throws BeansException
Set a property value.

Parameters:
pv - object containing the new property value
Throws:
InvalidPropertyException - if there is no such property or if the property isn't writable
PropertyAccessException - if the property was valid but the accessor method failed or a type mismatch occured
BeansException

setPropertyValues

void setPropertyValues(Map map)
                       throws BeansException
Perform a batch update from a Map.

Bulk updates from PropertyValues are more powerful: This method is provided for convenience. Behaviour will be identical to that of the setPropertyValues(PropertyValues) method.

Parameters:
map - Map to take properties from. Contains property value objects, keyed by property name
Throws:
InvalidPropertyException - if there is no such property or if the property isn't writable
PropertyBatchUpdateException - if one or more PropertyAccessExceptions occured for specific properties during the batch update. This exception bundles all individual PropertyAccessExceptions. All other properties will have been successfully updated.
BeansException

setPropertyValues

void setPropertyValues(PropertyValues pvs)
                       throws BeansException
The preferred way to perform a batch update.

Note that performing a batch 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 type mismatch, but not an invalid field name or the like) is encountered, throwing a PropertyBatchUpdateException containing all the individual errors. This exception can be examined later to see all binding errors. Properties that were successfully updated remain changed.

Does not allow unknown fields or invalid fields.

Parameters:
pvs - PropertyValues to set on the target object
Throws:
InvalidPropertyException - if there is no such property or if the property isn't writable
PropertyBatchUpdateException - if one or more PropertyAccessExceptions occured for specific properties during the batch update. This exception bundles all individual PropertyAccessExceptions. All other properties will have been successfully updated.
BeansException
See Also:
setPropertyValues(PropertyValues, boolean, boolean)

setPropertyValues

void setPropertyValues(PropertyValues pvs,
                       boolean ignoreUnknown)
                       throws BeansException
Perform a batch update with more control over behavior.

Note that performing a batch 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 type mismatch, but not an invalid field name or the like) is encountered, throwing a PropertyBatchUpdateException containing all the individual errors. This exception can be examined later to see all binding errors. Properties that were successfully updated remain changed.

Parameters:
pvs - PropertyValues to set on the target object
ignoreUnknown - should we ignore unknown properties (not found in the bean)
Throws:
InvalidPropertyException - if there is no such property or if the property isn't writable
PropertyBatchUpdateException - if one or more PropertyAccessExceptions occured for specific properties during the batch update. This exception bundles all individual PropertyAccessExceptions. All other properties will have been successfully updated.
BeansException
See Also:
setPropertyValues(PropertyValues, boolean, boolean)

setPropertyValues

void setPropertyValues(PropertyValues pvs,
                       boolean ignoreUnknown,
                       boolean ignoreInvalid)
                       throws BeansException
Perform a batch update with full control over behavior.

Note that performing a batch 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 type mismatch, but not an invalid field name or the like) is encountered, throwing a PropertyBatchUpdateException containing all the individual errors. This exception can be examined later to see all binding errors. Properties that were successfully updated remain changed.

Parameters:
pvs - PropertyValues to set on the target object
ignoreUnknown - should we ignore unknown properties (not found in the bean)
ignoreInvalid - should we ignore invalid properties (found but not accessible)
Throws:
InvalidPropertyException - if there is no such property or if the property isn't writable
PropertyBatchUpdateException - if one or more PropertyAccessExceptions occured for specific properties during the batch update. This exception bundles all individual PropertyAccessExceptions. All other properties will have been successfully updated.
BeansException

The Spring Framework

Copyright © 2002-2007 The Spring Framework.