public interface

PropertyAccessor

org.springframework.beans.PropertyAccessor
Known Indirect Subclasses

Class Overview

Common interface for classes that can access named properties (such as bean properties of an object or fields in an object) Serves as base interface for BeanWrapper.

Summary

Constants
String NESTED_PROPERTY_SEPARATOR Path separator for nested properties.
char NESTED_PROPERTY_SEPARATOR_CHAR
String PROPERTY_KEY_PREFIX Marker that indicates the start of a property key for an indexed or mapped property like "person.addresses[0]".
char PROPERTY_KEY_PREFIX_CHAR
String PROPERTY_KEY_SUFFIX Marker that indicates the end of a property key for an indexed or mapped property like "person.addresses[0]".
char PROPERTY_KEY_SUFFIX_CHAR
Public Methods
abstract 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.
abstract TypeDescriptor getPropertyTypeDescriptor(String propertyName)
Return a type descriptor for the specified property: preferably from the read method, falling back to the write method.
abstract Object getPropertyValue(String propertyName)
Get the current value of the specified property.
abstract boolean isReadableProperty(String propertyName)
Determine whether the specified property is readable.
abstract boolean isWritableProperty(String propertyName)
Determine whether the specified property is writable.
abstract void setPropertyValue(PropertyValue pv)
Set the specified value as current property value.
abstract void setPropertyValue(String propertyName, Object value)
Set the specified value as current property value.
abstract void setPropertyValues(PropertyValues pvs, boolean ignoreUnknown, boolean ignoreInvalid)
Perform a batch update with full control over behavior.
abstract void setPropertyValues(PropertyValues pvs)
The preferred way to perform a batch update.
abstract void setPropertyValues(Map<?, ?> map)
Perform a batch update from a Map.
abstract void setPropertyValues(PropertyValues pvs, boolean ignoreUnknown)
Perform a batch update with more control over behavior.

Constants

public static final String NESTED_PROPERTY_SEPARATOR

Also: SpringBeans

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

Constant Value: "."

public static final char NESTED_PROPERTY_SEPARATOR_CHAR

Also: SpringBeans

Constant Value: 46 (0x0000002e)

public static final String PROPERTY_KEY_PREFIX

Also: SpringBeans

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

Constant Value: "["

public static final char PROPERTY_KEY_PREFIX_CHAR

Also: SpringBeans

Constant Value: 91 (0x0000005b)

public static final String PROPERTY_KEY_SUFFIX

Also: SpringBeans

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

Constant Value: "]"

public static final char PROPERTY_KEY_SUFFIX_CHAR

Also: SpringBeans

Constant Value: 93 (0x0000005d)

Public Methods

public abstract Class getPropertyType (String propertyName)

Also: SpringBeans

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 the property to check (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
PropertyAccessException if the property was valid but the accessor method failed
BeansException

public abstract TypeDescriptor getPropertyTypeDescriptor (String propertyName)

Also: SpringBeans

Return a type descriptor for the specified property: preferably from the read method, falling back to the write method.

Parameters
propertyName the property to check (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

public abstract Object getPropertyValue (String propertyName)

Also: SpringBeans

Get the current value of the specified property.

Parameters
propertyName the name of the property to get the value of (may be a nested path and/or an indexed/mapped property)
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

public abstract boolean isReadableProperty (String propertyName)

Also: SpringBeans

Determine whether the specified property is readable.

Returns false if the property doesn't exist.

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

public abstract boolean isWritableProperty (String propertyName)

Also: SpringBeans

Determine whether the specified property is writable.

Returns false if the property doesn't exist.

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

public abstract void setPropertyValue (PropertyValue pv)

Also: SpringBeans

Set the specified value as current property value.

Parameters
pv an 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

public abstract void setPropertyValue (String propertyName, Object value)

Also: SpringBeans

Set the specified value as current property value.

Parameters
propertyName the name of the property to set the value of (may be a nested path and/or an indexed/mapped property)
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

public abstract void setPropertyValues (PropertyValues pvs, boolean ignoreUnknown, boolean ignoreInvalid)

Also: SpringBeans

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

public abstract void setPropertyValues (PropertyValues pvs)

Also: SpringBeans

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

public abstract void setPropertyValues (Map<?, ?> map)

Also: SpringBeans

Perform a batch update from a Map.

Bulk updates from PropertyValues are more powerful: This method is provided for convenience. Behavior 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

public abstract void setPropertyValues (PropertyValues pvs, boolean ignoreUnknown)

Also: SpringBeans

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