Interface PropertyAccessor
- All Known Subinterfaces:
- BeanWrapper,- ConfigurablePropertyAccessor
- All Known Implementing Classes:
- AbstractNestablePropertyAccessor,- AbstractPropertyAccessor,- BeanWrapperImpl,- DirectFieldAccessor
Serves as base interface for BeanWrapper.
- Since:
- 1.1
- Author:
- Juergen Hoeller
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringPath separator for nested properties.static final charPath separator for nested properties.static final StringMarker that indicates the start of a property key for an indexed or mapped property like "person.addresses[0]".static final charMarker that indicates the start of a property key for an indexed or mapped property like "person.addresses[0]".static final StringMarker that indicates the end of a property key for an indexed or mapped property like "person.addresses[0]".static final charMarker that indicates the end of a property key for an indexed or mapped property like "person.addresses[0]".
- 
Method SummaryModifier and TypeMethodDescriptionClass<?>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.getPropertyTypeDescriptor(String propertyName) Return a type descriptor for the specified property: preferably from the read method, falling back to the write method.getPropertyValue(String propertyName) Get the current value of the specified property.booleanisReadableProperty(String propertyName) Determine whether the specified property is readable.booleanisWritableProperty(String propertyName) Determine whether the specified property is writable.voidsetPropertyValue(String propertyName, Object value) Set the specified value as current property value.voidSet the specified value as current property value.voidsetPropertyValues(Map<?, ?> map) Perform a batch update from a Map.voidThe preferred way to perform a batch update.voidsetPropertyValues(PropertyValues pvs, boolean ignoreUnknown) Perform a batch update with more control over behavior.voidsetPropertyValues(PropertyValues pvs, boolean ignoreUnknown, boolean ignoreInvalid) Perform a batch update with full control over behavior.
- 
Field Details- 
NESTED_PROPERTY_SEPARATORPath separator for nested properties. Follows normal Java conventions: getFoo().getBar() would be "foo.bar".- See Also:
 
- 
NESTED_PROPERTY_SEPARATOR_CHARstatic final char NESTED_PROPERTY_SEPARATOR_CHARPath separator for nested properties. Follows normal Java conventions: getFoo().getBar() would be "foo.bar".- See Also:
 
- 
PROPERTY_KEY_PREFIXMarker that indicates the start of a property key for an indexed or mapped property like "person.addresses[0]".- See Also:
 
- 
PROPERTY_KEY_PREFIX_CHARstatic final char PROPERTY_KEY_PREFIX_CHARMarker that indicates the start of a property key for an indexed or mapped property like "person.addresses[0]".- See Also:
 
- 
PROPERTY_KEY_SUFFIXMarker that indicates the end of a property key for an indexed or mapped property like "person.addresses[0]".- See Also:
 
- 
PROPERTY_KEY_SUFFIX_CHARstatic final char PROPERTY_KEY_SUFFIX_CHARMarker that indicates the end of a property key for an indexed or mapped property like "person.addresses[0]".- See Also:
 
 
- 
- 
Method Details- 
isReadablePropertyDetermine whether the specified property is readable.Returns falseif 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
 
- 
isWritablePropertyDetermine whether the specified property is writable.Returns falseif 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
 
- 
getPropertyTypeDetermine 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 nullif not determinable
- Throws:
- PropertyAccessException- if the property was valid but the accessor method failed
- BeansException
 
- 
getPropertyTypeDescriptorReturn 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 nullif not determinable
- Throws:
- PropertyAccessException- if the property was valid but the accessor method failed
- BeansException
 
- 
getPropertyValueGet 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
 
- 
setPropertyValueSet 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 occurred
- BeansException
 
- 
setPropertyValueSet 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 occurred
- BeansException
 
- 
setPropertyValuesPerform 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- a 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 occurred for specific properties during the batch update. This exception bundles all individual PropertyAccessExceptions. All other properties will have been successfully updated.
- BeansException
 
- 
setPropertyValuesThe 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 PropertyBatchUpdateExceptioncontaining 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- a 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 occurred for specific properties during the batch update. This exception bundles all individual PropertyAccessExceptions. All other properties will have been successfully updated.
- BeansException
- See Also:
 
- 
setPropertyValuesPerform 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 PropertyBatchUpdateExceptioncontaining all the individual errors. This exception can be examined later to see all binding errors. Properties that were successfully updated remain changed.- Parameters:
- pvs- a 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 occurred for specific properties during the batch update. This exception bundles all individual PropertyAccessExceptions. All other properties will have been successfully updated.
- BeansException
- See Also:
 
- 
setPropertyValuesvoid 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 PropertyBatchUpdateExceptioncontaining all the individual errors. This exception can be examined later to see all binding errors. Properties that were successfully updated remain changed.- Parameters:
- pvs- a 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 occurred for specific properties during the batch update. This exception bundles all individual PropertyAccessExceptions. All other properties will have been successfully updated.
- BeansException
 
 
-