Package org.springframework.expression
Interface IndexAccessor
- All Superinterfaces:
TargetedAccessor
- All Known Subinterfaces:
CompilableIndexAccessor
- All Known Implementing Classes:
ReflectiveIndexAccessor
An index accessor is able to read from and possibly write to an indexed
structure of a target object.
This interface places no restrictions on what constitutes an indexed structure. Implementors are therefore free to access indexed values any way they deem appropriate.
An index accessor can specify an array of
target classes for which it should be
called. See TargetedAccessor
for details.
- Since:
- 6.2
- Author:
- Jackmiking Lee, Sam Brannen
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionboolean
canRead
(EvaluationContext context, Object target, Object index) Determine if this index accessor is able to read a specified index on a specified target object.boolean
canWrite
(EvaluationContext context, Object target, Object index) Determine if this index accessor is able to write to a specified index on a specified target object.read
(EvaluationContext context, Object target, Object index) Read an index from a specified target object.void
write
(EvaluationContext context, Object target, Object index, Object newValue) Write to an index on a specified target object.Methods inherited from interface org.springframework.expression.TargetedAccessor
getSpecificTargetClasses
-
Method Details
-
canRead
Determine if this index accessor is able to read a specified index on a specified target object.- Parameters:
context
- the evaluation context in which the access is being attemptedtarget
- the target object upon which the index is being accessedindex
- the index being accessed- Returns:
true
if this index accessor is able to read the index- Throws:
AccessException
- if there is any problem determining whether the index can be read
-
read
Read an index from a specified target object.Should only be invoked if
canRead(org.springframework.expression.EvaluationContext, java.lang.Object, java.lang.Object)
returnstrue
for the same arguments.- Parameters:
context
- the evaluation context in which the access is being attemptedtarget
- the target object upon which the index is being accessedindex
- the index being accessed- Returns:
- a TypedValue object wrapping the index value read and a type descriptor for the value
- Throws:
AccessException
- if there is any problem reading the index
-
canWrite
Determine if this index accessor is able to write to a specified index on a specified target object.- Parameters:
context
- the evaluation context in which the access is being attemptedtarget
- the target object upon which the index is being accessedindex
- the index being accessed- Returns:
true
if this index accessor is able to write to the index- Throws:
AccessException
- if there is any problem determining whether the index can be written to
-
write
void write(EvaluationContext context, Object target, Object index, @Nullable Object newValue) throws AccessException Write to an index on a specified target object.Should only be invoked if
canWrite(org.springframework.expression.EvaluationContext, java.lang.Object, java.lang.Object)
returnstrue
for the same arguments.- Parameters:
context
- the evaluation context in which the access is being attemptedtarget
- the target object upon which the index is being accessedindex
- the index being accessednewValue
- the new value for the index- Throws:
AccessException
- if there is any problem writing to the index
-