Package org.springframework.beans

# Class DirectFieldAccessor

java.lang.Object
org.springframework.beans.PropertyEditorRegistrySupport
org.springframework.beans.TypeConverterSupport
org.springframework.beans.AbstractPropertyAccessor
org.springframework.beans.AbstractNestablePropertyAccessor
org.springframework.beans.DirectFieldAccessor

All Implemented Interfaces:
  `ConfigurablePropertyAccessor`, `PropertyAccessor`, `PropertyEditorRegistry`, `TypeConverter`

public class DirectFieldAccessor extends AbstractNestablePropertyAccessor
`ConfigurablePropertyAccessor` implementation that directly accesses instance fields. Allows for direct binding to fields instead of going through JavaBean setters.

As of Spring 4.2, the vast majority of the `BeanWrapper` features have been merged to `AbstractPropertyAccessor`, which means that property traversal as well as collections and map access is now supported here as well.

A DirectFieldAccessor's default for the "extractOldValueForEditor" setting is "true", since a field can always be read without side effects.

Since:
  2.0
Author:
  Juergen Hoeller, Stephane Nicoll
See Also:
  - `AbstractPropertyAccessor.setExtractOldValueForEditor(boolean)`
  - `BeanWrapper`
  - `org.springframework.validation.DirectFieldBindingResult`
  - `org.springframework.validation.DataBinder#initDirectFieldAccess()`

## Nested Class Summary

## Nested classes/interfaces inherited from class org.springframework.beans.AbstractNestablePropertyAccessor

`AbstractNestablePropertyAccessor.PropertyHandler, AbstractNestablePropertyAccessor.PropertyTokenHolder`

## Field Summary

### Fields inherited from interface org.springframework.beans.PropertyAccessor

`NESTED_PROPERTY_SEPARATOR, NESTED_PROPERTY_SEPARATOR_CHAR, PROPERTY_KEY_PREFIX, PROPERTY_KEY_PREFIX_CHAR, PROPERTY_KEY_SUFFIX, PROPERTY_KEY_SUFFIX_CHAR`

## Constructor Summary

Constructors
Modifier
Constructor
Description
``
`DirectFieldAccessor(Object object)`
Create a new DirectFieldAccessor for the given object.
`protected`
`DirectFieldAccessor(Object object, String nestedPath, DirectFieldAccessor parent)`
Create a new DirectFieldAccessor for the given object, registering a nested path that the object is in.

## Method Summary

Modifier and Type
Method
Description
`protected NotWritablePropertyException`
`createNotWritablePropertyException(String propertyName)`
Create a `NotWritablePropertyException` for the specified property.
`protected AbstractNestablePropertyAccessor.PropertyHandler`
`getLocalPropertyHandler(String propertyName)`
Return a `AbstractNestablePropertyAccessor.PropertyHandler` for the specified local `propertyName`.
`protected DirectFieldAccessor`
`newNestedPropertyAccessor(Object object, String nestedPath)`
Create a new nested property accessor instance.

### Methods inherited from class org.springframework.beans.AbstractNestablePropertyAccessor

`convertForProperty, getAutoGrowCollectionLimit, getFinalPath, getNestedPath, getPropertyAccessorForPropertyPath, getPropertyHandler, getPropertyType, getPropertyTypeDescriptor, getPropertyValue, getPropertyValue, getRootClass, getRootInstance, getWrappedClass, getWrappedInstance, isReadableProperty, isWritableProperty, setAutoGrowCollectionLimit, setPropertyValue, setPropertyValue, setPropertyValue, setWrappedInstance, setWrappedInstance, toString`

### Methods inherited from class org.springframework.beans.AbstractPropertyAccessor

`isAutoGrowNestedPaths, isExtractOldValueForEditor, setAutoGrowNestedPaths, setExtractOldValueForEditor, setPropertyValues, setPropertyValues, setPropertyValues, setPropertyValues`

### Methods inherited from class org.springframework.beans.TypeConverterSupport

`convertIfNecessary, convertIfNecessary, convertIfNecessary, convertIfNecessary`

### Methods inherited from class org.springframework.beans.PropertyEditorRegistrySupport

`copyCustomEditorsTo, copyDefaultEditorsTo, findCustomEditor, getConversionService, getDefaultEditor, guessPropertyTypeFromEditors, hasCustomEditorForElement, overrideDefaultEditor, registerCustomEditor, registerCustomEditor, registerDefaultEditors, setConversionService, setDefaultEditorRegistrar, useConfigValueEditors`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.springframework.beans.ConfigurablePropertyAccessor

`getConversionService, setConversionService`

### Methods inherited from interface org.springframework.beans.PropertyEditorRegistry

`findCustomEditor, registerCustomEditor, registerCustomEditor`

### Methods inherited from interface org.springframework.beans.TypeConverter

`convertIfNecessary, convertIfNecessary, convertIfNecessary, convertIfNecessary`

## Constructor Details

### DirectFieldAccessor

public DirectFieldAccessor(Object object)
Create a new DirectFieldAccessor for the given object.

Parameters:
  `object` - the object wrapped by this DirectFieldAccessor

### DirectFieldAccessor

protected DirectFieldAccessor(Object object, String nestedPath, DirectFieldAccessor parent)
Create a new DirectFieldAccessor for the given object, registering a nested path that the object is in.

Parameters:
  `object` - the object wrapped by this DirectFieldAccessor
  `nestedPath` - the nested path of the object
  `parent` - the containing DirectFieldAccessor (must not be `null`)

## Method Details

### getLocalPropertyHandler

@Nullable protected AbstractNestablePropertyAccessor.PropertyHandler getLocalPropertyHandler(String propertyName)
Description copied from class: `AbstractNestablePropertyAccessor`
Return a `AbstractNestablePropertyAccessor.PropertyHandler` for the specified local `propertyName`. Only used to reach a property available in the current context.

Specified by:
  `getLocalPropertyHandler` in class `AbstractNestablePropertyAccessor`
Parameters:
  `propertyName` - the name of a local property
Returns:
  the handler for that property, or `null` if it has not been found

### newNestedPropertyAccessor

protected DirectFieldAccessor newNestedPropertyAccessor(Object object, String nestedPath)
Description copied from class: `AbstractNestablePropertyAccessor`
Create a new nested property accessor instance. Can be overridden in subclasses to create a PropertyAccessor subclass.

Specified by:
  `newNestedPropertyAccessor` in class `AbstractNestablePropertyAccessor`
Parameters:
  `object` - the object wrapped by this PropertyAccessor
  `nestedPath` - the nested path of the object
Returns:
  the nested PropertyAccessor instance

### createNotWritablePropertyException

protected NotWritablePropertyException createNotWritablePropertyException(String propertyName)
Description copied from class: `AbstractNestablePropertyAccessor`
Create a `NotWritablePropertyException` for the specified property.

Specified by:
  `createNotWritablePropertyException` in class `AbstractNestablePropertyAccessor`