Top Description Methods
org.springframework.expression

public Interface PropertyAccessor

Known Direct Subinterfaces
org.springframework.expression.spel.CompilablePropertyAccessor
Known Direct Implementers
org.springframework.expression.spel.support.ReflectivePropertyAccessor
Imports
org.springframework.lang.Nullable

A property accessor is able to read from (and possibly write to) an object's properties.

This interface places no restrictions, and so implementors are free to access properties directly as fields or through getters or in any other way they see as appropriate.

A resolver can optionally specify an array of target classes for which it should be called. However, if it returns null from getSpecificTargetClasses(), it will be called for all property references and given a chance to determine if it can read or write them.

Property resolvers are considered to be ordered, and each will be called in turn. The only rule that affects the call order is that any resolver naming the target class directly in getSpecificTargetClasses() will be called first, before the general resolvers.

Author
Andy Clement
Since
3.0

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if this resolver is able to read the property
canRead
(EvaluationContext
the evaluation context in which the access is being attempted
context
,
Object
the target object upon which the property is being accessed
target
,
String
the name of the property being accessed
name
)

Called to determine if a resolver instance is able to access a specified property on a specified target object.

public boolean

Returns:

true if this resolver is able to write to the property
canWrite
(EvaluationContext
the evaluation context in which the access is being attempted
context
,
Object
the target object upon which the property is being accessed
target
,
String
the name of the property being accessed
name
)

Called to determine if a resolver instance is able to write to a specified property on a specified target object.

public Class<?>[]

Returns:

an array of classes that this resolver is suitable for (or null if a general resolver)
getSpecificTargetClasses
()

Return an array of classes for which this resolver should be called.

public TypedValue

Returns:

a TypedValue object wrapping the property value read and a type descriptor for it
read
(EvaluationContext
the evaluation context in which the access is being attempted
context
,
Object
the target object upon which the property is being accessed
target
,
String
the name of the property being accessed
name
)

Called to read a property from a specified target object.

public void
write(EvaluationContext
the evaluation context in which the access is being attempted
context
,
Object
the target object upon which the property is being accessed
target
,
String
the name of the property being accessed
name
,
Object
the new value for the property
newValue
)

Called to write to a property on a specified target object.

Method Detail

canReadback to summary
public boolean canRead(EvaluationContext context, Object target, String name) throws AccessException

Called to determine if a resolver instance is able to access a specified property on a specified target object.

Parameters
context:EvaluationContext

the evaluation context in which the access is being attempted

target:Object

the target object upon which the property is being accessed

name:String

the name of the property being accessed

Returns:boolean

true if this resolver is able to read the property

Exceptions
AccessException:
if there is any problem determining whether the property can be read
canWriteback to summary
public boolean canWrite(EvaluationContext context, Object target, String name) throws AccessException

Called to determine if a resolver instance is able to write to a specified property on a specified target object.

Parameters
context:EvaluationContext

the evaluation context in which the access is being attempted

target:Object

the target object upon which the property is being accessed

name:String

the name of the property being accessed

Returns:boolean

true if this resolver is able to write to the property

Exceptions
AccessException:
if there is any problem determining whether the property can be written to
getSpecificTargetClassesback to summary
public Class<?>[] getSpecificTargetClasses()

Return an array of classes for which this resolver should be called.

Returning null indicates this is a general resolver that can be called in an attempt to resolve a property on any type.

Returns:Class<?>[]

an array of classes that this resolver is suitable for (or null if a general resolver)

Annotations
@Nullable
readback to summary
public TypedValue read(EvaluationContext context, Object target, String name) throws AccessException

Called to read a property from a specified target object. Should only succeed if canRead also returns true.

Parameters
context:EvaluationContext

the evaluation context in which the access is being attempted

target:Object

the target object upon which the property is being accessed

name:String

the name of the property being accessed

Returns:TypedValue

a TypedValue object wrapping the property value read and a type descriptor for it

Exceptions
AccessException:
if there is any problem accessing the property value
writeback to summary
public void write(EvaluationContext context, Object target, String name, Object newValue) throws AccessException

Called to write to a property on a specified target object. Should only succeed if canWrite also returns true.

Parameters
context:EvaluationContext

the evaluation context in which the access is being attempted

target:Object

the target object upon which the property is being accessed

name:String

the name of the property being accessed

newValue:Object

the new value for the property

Exceptions
AccessException:
if there is any problem writing to the property value