public interface PropertyAccessor
BeanWrapper
.BeanWrapper
,
PropertyAccessorFactory.forBeanPropertyAccess(java.lang.Object)
,
PropertyAccessorFactory.forDirectFieldAccess(java.lang.Object)
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
NESTED_PROPERTY_SEPARATOR
Path separator for nested properties.
|
static char |
NESTED_PROPERTY_SEPARATOR_CHAR |
static java.lang.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 java.lang.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 |
Modifier and Type | Method and Description |
---|---|
java.lang.Class<?> |
getPropertyType(java.lang.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.
|
TypeDescriptor |
getPropertyTypeDescriptor(java.lang.String propertyName)
Return a type descriptor for the specified property:
preferably from the read method, falling back to the write method.
|
java.lang.Object |
getPropertyValue(java.lang.String propertyName)
Get the current value of the specified property.
|
boolean |
isReadableProperty(java.lang.String propertyName)
Determine whether the specified property is readable.
|
boolean |
isWritableProperty(java.lang.String propertyName)
Determine whether the specified property is writable.
|
void |
setPropertyValue(PropertyValue pv)
Set the specified value as current property value.
|
void |
setPropertyValue(java.lang.String propertyName,
java.lang.Object value)
Set the specified value as current property value.
|
void |
setPropertyValues(java.util.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.
|
static final java.lang.String NESTED_PROPERTY_SEPARATOR
static final char NESTED_PROPERTY_SEPARATOR_CHAR
static final java.lang.String PROPERTY_KEY_PREFIX
static final char PROPERTY_KEY_PREFIX_CHAR
static final java.lang.String PROPERTY_KEY_SUFFIX
static final char PROPERTY_KEY_SUFFIX_CHAR
boolean isReadableProperty(java.lang.String propertyName)
Returns false
if the property doesn't exist.
propertyName
- the property to check
(may be a nested path and/or an indexed/mapped property)boolean isWritableProperty(java.lang.String propertyName)
Returns false
if the property doesn't exist.
propertyName
- the property to check
(may be a nested path and/or an indexed/mapped property)java.lang.Class<?> getPropertyType(java.lang.String propertyName) throws BeansException
propertyName
- the property to check
(may be a nested path and/or an indexed/mapped property)null
if not determinablePropertyAccessException
- if the property was valid but the
accessor method failedBeansException
TypeDescriptor getPropertyTypeDescriptor(java.lang.String propertyName) throws BeansException
propertyName
- the property to check
(may be a nested path and/or an indexed/mapped property)null
if not determinablePropertyAccessException
- if the property was valid but the
accessor method failedBeansException
java.lang.Object getPropertyValue(java.lang.String propertyName) throws BeansException
propertyName
- the name of the property to get the value of
(may be a nested path and/or an indexed/mapped property)InvalidPropertyException
- if there is no such property or
if the property isn't readablePropertyAccessException
- if the property was valid but the
accessor method failedBeansException
void setPropertyValue(java.lang.String propertyName, java.lang.Object value) throws BeansException
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 valueInvalidPropertyException
- if there is no such property or
if the property isn't writablePropertyAccessException
- if the property was valid but the
accessor method failed or a type mismatch occurredBeansException
void setPropertyValue(PropertyValue pv) throws BeansException
pv
- an object containing the new property valueInvalidPropertyException
- if there is no such property or
if the property isn't writablePropertyAccessException
- if the property was valid but the
accessor method failed or a type mismatch occurredBeansException
void setPropertyValues(java.util.Map<?,?> map) throws BeansException
Bulk updates from PropertyValues are more powerful: This method is
provided for convenience. Behavior will be identical to that of
the setPropertyValues(PropertyValues)
method.
map
- Map to take properties from. Contains property value objects,
keyed by property nameInvalidPropertyException
- if there is no such property or
if the property isn't writablePropertyBatchUpdateException
- 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
void setPropertyValues(PropertyValues pvs) throws BeansException
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.
pvs
- PropertyValues to set on the target objectInvalidPropertyException
- if there is no such property or
if the property isn't writablePropertyBatchUpdateException
- 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
setPropertyValues(PropertyValues, boolean, boolean)
void setPropertyValues(PropertyValues pvs, boolean ignoreUnknown) throws BeansException
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.
pvs
- PropertyValues to set on the target objectignoreUnknown
- should we ignore unknown properties (not found in the bean)InvalidPropertyException
- if there is no such property or
if the property isn't writablePropertyBatchUpdateException
- 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
setPropertyValues(PropertyValues, boolean, boolean)
void setPropertyValues(PropertyValues pvs, boolean ignoreUnknown, boolean ignoreInvalid) throws BeansException
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.
pvs
- PropertyValues to set on the target objectignoreUnknown
- should we ignore unknown properties (not found in the bean)ignoreInvalid
- should we ignore invalid properties (found but not accessible)InvalidPropertyException
- if there is no such property or
if the property isn't writablePropertyBatchUpdateException
- 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