Class AbstractPropertyAccessor

All Implemented Interfaces:
ConfigurablePropertyAccessor, PropertyAccessor, PropertyEditorRegistry, TypeConverter
Direct Known Subclasses:
AbstractNestablePropertyAccessor

public abstract class AbstractPropertyAccessor extends TypeConverterSupport implements ConfigurablePropertyAccessor
Abstract implementation of the PropertyAccessor interface. Provides base implementations of all convenience methods, with the implementation of actual property access left to subclasses.
Since:
2.0
Author:
Juergen Hoeller, Stephane Nicoll
See Also:
  • Constructor Details

    • AbstractPropertyAccessor

      public AbstractPropertyAccessor()
  • Method Details

    • setExtractOldValueForEditor

      public void setExtractOldValueForEditor(boolean extractOldValueForEditor)
      Description copied from interface: ConfigurablePropertyAccessor
      Set whether to extract the old property value when applying a property editor to a new value for a property.
      Specified by:
      setExtractOldValueForEditor in interface ConfigurablePropertyAccessor
    • isExtractOldValueForEditor

      public boolean isExtractOldValueForEditor()
      Description copied from interface: ConfigurablePropertyAccessor
      Return whether to extract the old property value when applying a property editor to a new value for a property.
      Specified by:
      isExtractOldValueForEditor in interface ConfigurablePropertyAccessor
    • setAutoGrowNestedPaths

      public void setAutoGrowNestedPaths(boolean autoGrowNestedPaths)
      Description copied from interface: ConfigurablePropertyAccessor
      Set whether this instance should attempt to "auto-grow" a nested path that contains a null value.

      If true, a null path location will be populated with a default object value and traversed instead of resulting in a NullValueInNestedPathException.

      Default is false on a plain PropertyAccessor instance.

      Specified by:
      setAutoGrowNestedPaths in interface ConfigurablePropertyAccessor
    • isAutoGrowNestedPaths

      public boolean isAutoGrowNestedPaths()
      Description copied from interface: ConfigurablePropertyAccessor
      Return whether "auto-growing" of nested paths has been activated.
      Specified by:
      isAutoGrowNestedPaths in interface ConfigurablePropertyAccessor
    • setPropertyValue

      public void setPropertyValue(PropertyValue pv) throws BeansException
      Description copied from interface: PropertyAccessor
      Set the specified value as current property value.
      Specified by:
      setPropertyValue in interface PropertyAccessor
      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
    • setPropertyValues

      public void setPropertyValues(Map<?,?> map) throws BeansException
      Description copied from interface: PropertyAccessor
      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 PropertyAccessor.setPropertyValues(PropertyValues) method.

      Specified by:
      setPropertyValues in interface PropertyAccessor
      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
    • setPropertyValues

      public void setPropertyValues(PropertyValues pvs) throws BeansException
      Description copied from interface: PropertyAccessor
      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.

      Specified by:
      setPropertyValues in interface PropertyAccessor
      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:
    • setPropertyValues

      public void setPropertyValues(PropertyValues pvs, boolean ignoreUnknown) throws BeansException
      Description copied from interface: PropertyAccessor
      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.

      Specified by:
      setPropertyValues in interface PropertyAccessor
      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:
    • setPropertyValues

      public void setPropertyValues(PropertyValues pvs, boolean ignoreUnknown, boolean ignoreInvalid) throws BeansException
      Description copied from interface: PropertyAccessor
      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.

      Specified by:
      setPropertyValues in interface PropertyAccessor
      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
    • getPropertyType

      @Nullable public Class<?> getPropertyType(String propertyPath)
      Description copied from class: PropertyEditorRegistrySupport
      Determine the property type for the given property path.

      Called by PropertyEditorRegistrySupport.findCustomEditor(java.lang.Class<?>, java.lang.String) if no required type has been specified, to be able to find a type-specific editor even if just given a property path.

      The default implementation always returns null. BeanWrapperImpl overrides this with the standard getPropertyType method as defined by the BeanWrapper interface.

      Specified by:
      getPropertyType in interface PropertyAccessor
      Overrides:
      getPropertyType in class PropertyEditorRegistrySupport
      Parameters:
      propertyPath - the property path to determine the type for
      Returns:
      the type of the property, or null if not determinable
      See Also:
    • getPropertyValue

      @Nullable public abstract Object getPropertyValue(String propertyName) throws BeansException
      Actually get the value of a property.
      Specified by:
      getPropertyValue in interface PropertyAccessor
      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
      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

      public abstract void setPropertyValue(String propertyName, @Nullable Object value) throws BeansException
      Actually set a property value.
      Specified by:
      setPropertyValue in interface PropertyAccessor
      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 occurred
      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