Top Description Inners Constructors Methods
org.springframework.context.expression

public Class MapAccessor

extends Object
implements CompilablePropertyAccessor
Class Inheritance
All Implemented Interfaces
org.springframework.expression.spel.CompilablePropertyAccessor, org.springframework.asm.Opcodes, org.springframework.expression.PropertyAccessor
Imports
java.util.Map, org.springframework.asm.MethodVisitor, org.springframework.expression.AccessException, .EvaluationContext, .TypedValue, org.springframework.expression.spel.CodeFlow, .CompilablePropertyAccessor, org.springframework.lang.Nullable, org.springframework.util.Assert

EL property accessor that knows how to traverse the keys of a standard java.util.Map.
Authors
Juergen Hoeller, Andy Clement
Since
3.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
MapAccessor.MapAccessException

Exception thrown from read in order to reset a cached PropertyAccessor, allowing other accessors to have a try.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
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
)

Implements org.springframework.expression.PropertyAccessor.canRead.

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

public boolean
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
)

Implements org.springframework.expression.PropertyAccessor.canWrite.

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

public void
generateCode(String
the name of the property
propertyName
,
MethodVisitor
the ASM method visitor into which code should be generated
mv
,
CodeFlow
the current state of the expression compiler
cf
)

Implements org.springframework.expression.spel.CompilablePropertyAccessor.generateCode.

Generate the bytecode the performs the access operation into the specified MethodVisitor using context information from the CodeFlow where necessary.

public Class<?>
getPropertyType()

Implements org.springframework.expression.spel.CompilablePropertyAccessor.getPropertyType.

Return the type of the accessed property - may only be known once an access has occurred.

public Class<?>[]
getSpecificTargetClasses()

Implements org.springframework.expression.PropertyAccessor.getSpecificTargetClasses.

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

public boolean
isCompilable()

Implements org.springframework.expression.spel.CompilablePropertyAccessor.isCompilable.

Return true if this property accessor is currently suitable for compilation.

public TypedValue
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
)

Implements org.springframework.expression.PropertyAccessor.read.

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
)

Implements org.springframework.expression.PropertyAccessor.write.

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

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

MapAccessorback to summary
public MapAccessor()

Method Detail

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

Implements org.springframework.expression.PropertyAccessor.canRead.

Doc from org.springframework.expression.PropertyAccessor.canRead.

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

Annotations
@Override
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

Implements org.springframework.expression.PropertyAccessor.canWrite.

Doc from org.springframework.expression.PropertyAccessor.canWrite.

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

Annotations
@Override
Exceptions
AccessException:
if there is any problem determining whether the property can be written to
generateCodeback to summary
public void generateCode(String propertyName, MethodVisitor mv, CodeFlow cf)

Implements org.springframework.expression.spel.CompilablePropertyAccessor.generateCode.

Doc from org.springframework.expression.spel.CompilablePropertyAccessor.generateCode.

Generate the bytecode the performs the access operation into the specified MethodVisitor using context information from the CodeFlow where necessary.

Parameters
propertyName:String

the name of the property

mv:MethodVisitor

the ASM method visitor into which code should be generated

cf:CodeFlow

the current state of the expression compiler

Annotations
@Override
getPropertyTypeback to summary
public Class<?> getPropertyType()

Implements org.springframework.expression.spel.CompilablePropertyAccessor.getPropertyType.

Doc from org.springframework.expression.spel.CompilablePropertyAccessor.getPropertyType.

Return the type of the accessed property - may only be known once an access has occurred.

Annotations
@Override
getSpecificTargetClassesback to summary
public Class<?>[] getSpecificTargetClasses()

Implements org.springframework.expression.PropertyAccessor.getSpecificTargetClasses.

Doc from org.springframework.expression.PropertyAccessor.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
@Override
isCompilableback to summary
public boolean isCompilable()

Implements org.springframework.expression.spel.CompilablePropertyAccessor.isCompilable.

Doc from org.springframework.expression.spel.CompilablePropertyAccessor.isCompilable.

Return true if this property accessor is currently suitable for compilation.

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

Implements org.springframework.expression.PropertyAccessor.read.

Doc from org.springframework.expression.PropertyAccessor.read.

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

Annotations
@Override
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

Implements org.springframework.expression.PropertyAccessor.write.

Doc from org.springframework.expression.PropertyAccessor.write.

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

Annotations
@Override
@SuppressWarnings:unchecked
Exceptions
AccessException:
if there is any problem writing to the property value
org.springframework.context.expression back to summary

private Class MapAccessor.MapAccessException

extends AccessException
Class Inheritance
Annotations
@SuppressWarnings:serial

Exception thrown from read in order to reset a cached PropertyAccessor, allowing other accessors to have a try.

Field Summary

Modifier and TypeField and Description
private final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public String
getMessage()

Overrides java.lang.Throwable.getMessage.

Returns the detail message string of this throwable.

Field Detail

keyback to summary
private final String key

Constructor Detail

MapAccessExceptionback to summary
public MapAccessException(String key)

Method Detail

getMessageback to summary
public String getMessage()

Overrides java.lang.Throwable.getMessage.

Doc from java.lang.Throwable.getMessage.

Returns the detail message string of this throwable.

Returns:String

the detail message string of this Throwable instance (which may be null).

Annotations
@Override