Top Description Inners Fields Constructors Methods
org.springframework.beans

public Class DirectFieldAccessor

extends AbstractNestablePropertyAccessor
Class Inheritance
Imports
java.lang.reflect.Field, java.util.HashMap, .Map, org.springframework.core.ResolvableType, org.springframework.core.convert.TypeDescriptor, org.springframework.lang.Nullable, org.springframework.util.ReflectionUtils

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.

Authors
Juergen Hoeller, Stephane Nicoll
Since
2.0
See Also
setExtractOldValueForEditor, BeanWrapper, org.springframework.validation.DirectFieldBindingResult, org.springframework.validation.DataBinder#initDirectFieldAccess()

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private final Map<String, DirectFieldAccessor.FieldPropertyHandler>
Inherited from org.springframework.beans.AbstractNestablePropertyAccessor:
rootObjectwrappedObject

Constructor Summary

AccessConstructor and Description
public
DirectFieldAccessor(Object
the object wrapped by this DirectFieldAccessor
object
)

Create a new DirectFieldAccessor for the given object.

protected
DirectFieldAccessor(Object
the object wrapped by this DirectFieldAccessor
object
,
String
the nested path of the object
nestedPath
,
DirectFieldAccessor
the containing DirectFieldAccessor (must not be null)
parent
)

Create a new DirectFieldAccessor for the given object, registering a nested path that the object is in.

Method Summary

Modifier and TypeMethod and Description
protected NotWritablePropertyException
protected DirectFieldAccessor.FieldPropertyHandler
getLocalPropertyHandler(String
the name of a local property
propertyName
)

Implements abstract org.springframework.beans.AbstractNestablePropertyAccessor.getLocalPropertyHandler.

Return a PropertyHandler for the specified local propertyName.

protected DirectFieldAccessor
newNestedPropertyAccessor(Object
the object wrapped by this PropertyAccessor
object
,
String
the nested path of the object
nestedPath
)

Implements abstract org.springframework.beans.AbstractNestablePropertyAccessor.newNestedPropertyAccessor.

Create a new nested property accessor instance.

Inherited from org.springframework.beans.AbstractNestablePropertyAccessor:
convertForPropertygetAutoGrowCollectionLimitgetFinalPathgetNestedPathgetPropertyAccessorForPropertyPathgetPropertyHandlergetPropertyTypegetPropertyTypeDescriptorgetPropertyValuegetPropertyValuegetRootClassgetRootInstancegetWrappedClassgetWrappedInstanceisReadablePropertyisWritablePropertysetAutoGrowCollectionLimitsetPropertyValuesetPropertyValuesetPropertyValuesetWrappedInstancesetWrappedInstancetoString

Field Detail

fieldMapback to summary
private final Map<String, DirectFieldAccessor.FieldPropertyHandler> fieldMap

Constructor Detail

DirectFieldAccessorback to summary
public DirectFieldAccessor(Object object)

Create a new DirectFieldAccessor for the given object.

Parameters
object:Object

the object wrapped by this DirectFieldAccessor

DirectFieldAccessorback to summary
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:Object

the object wrapped by this DirectFieldAccessor

nestedPath:String

the nested path of the object

parent:DirectFieldAccessor

the containing DirectFieldAccessor (must not be null)

Method Detail

createNotWritablePropertyExceptionback to summary
protected NotWritablePropertyException createNotWritablePropertyException(String propertyName)

Implements abstract org.springframework.beans.AbstractNestablePropertyAccessor.createNotWritablePropertyException.

Doc from org.springframework.beans.AbstractNestablePropertyAccessor.createNotWritablePropertyException.

Create a NotWritablePropertyException for the specified property.

Annotations
@Override
getLocalPropertyHandlerback to summary
protected DirectFieldAccessor.FieldPropertyHandler getLocalPropertyHandler(String propertyName)

Implements abstract org.springframework.beans.AbstractNestablePropertyAccessor.getLocalPropertyHandler.

Doc from org.springframework.beans.AbstractNestablePropertyAccessor.getLocalPropertyHandler.

Return a PropertyHandler for the specified local propertyName. Only used to reach a property available in the current context.

Parameters
propertyName:String

the name of a local property

Returns:DirectFieldAccessor.FieldPropertyHandler

the handler for that property, or null if it has not been found

Annotations
@Override
@Nullable
newNestedPropertyAccessorback to summary
protected DirectFieldAccessor newNestedPropertyAccessor(Object object, String nestedPath)

Implements abstract org.springframework.beans.AbstractNestablePropertyAccessor.newNestedPropertyAccessor.

Doc from org.springframework.beans.AbstractNestablePropertyAccessor.newNestedPropertyAccessor.

Create a new nested property accessor instance. Can be overridden in subclasses to create a PropertyAccessor subclass.

Parameters
object:Object

the object wrapped by this PropertyAccessor

nestedPath:String

the nested path of the object

Returns:DirectFieldAccessor

the nested PropertyAccessor instance

Annotations
@Override
org.springframework.beans back to summary

private Class DirectFieldAccessor.FieldPropertyHandler

extends PropertyHandler
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Field
private final ResolvableType

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public TypeDescriptor
public TypeDescriptor
public ResolvableType
public Object
public TypeDescriptor
public void
public TypeDescriptor
Inherited from org.springframework.beans.AbstractNestablePropertyAccessor.PropertyHandler:
getMapKeyTypegetPropertyTypeisReadableisWritablesetValueFallbackIfPossible

Field Detail

fieldback to summary
private final Field field
resolvableTypeback to summary
private final ResolvableType resolvableType

Constructor Detail

FieldPropertyHandlerback to summary
public FieldPropertyHandler(Field field)

Method Detail

getCollectionTypeback to summary
public TypeDescriptor getCollectionType(int nestingLevel)

Overrides org.springframework.beans.AbstractNestablePropertyAccessor.PropertyHandler.getCollectionType.

Annotations
@Override
getMapValueTypeback to summary
public TypeDescriptor getMapValueType(int nestingLevel)

Overrides org.springframework.beans.AbstractNestablePropertyAccessor.PropertyHandler.getMapValueType.

Annotations
@Override
getResolvableTypeback to summary
public ResolvableType getResolvableType()

Implements abstract org.springframework.beans.AbstractNestablePropertyAccessor.PropertyHandler.getResolvableType.

Annotations
@Override
getValueback to summary
public Object getValue() throws Exception

Implements abstract org.springframework.beans.AbstractNestablePropertyAccessor.PropertyHandler.getValue.

Annotations
@Override
@Nullable
nestedback to summary
public TypeDescriptor nested(int level)

Implements abstract org.springframework.beans.AbstractNestablePropertyAccessor.PropertyHandler.nested.

Annotations
@Override
@Nullable
setValueback to summary
public void setValue(Object value) throws Exception

Implements abstract org.springframework.beans.AbstractNestablePropertyAccessor.PropertyHandler.setValue.

Annotations
@Override
toTypeDescriptorback to summary
public TypeDescriptor toTypeDescriptor()

Implements abstract org.springframework.beans.AbstractNestablePropertyAccessor.PropertyHandler.toTypeDescriptor.

Annotations
@Override