Top Description Inners Fields Constructors Methods
org.springframework.expression.spel.ast

public Class PropertyOrFieldReference

extends SpelNodeImpl
Class Inheritance
Imports
java.lang.reflect.InvocationTargetException, java.util.ArrayList, .HashMap, .List, .Map, java.util.function.Supplier, org.springframework.asm.Label, .MethodVisitor, org.springframework.core.convert.TypeDescriptor, org.springframework.expression.AccessException, .EvaluationContext, .EvaluationException, .PropertyAccessor, .TypedValue, org.springframework.expression.spel.CodeFlow, .CompilablePropertyAccessor, .ExpressionState, .SpelEvaluationException, .SpelMessage, org.springframework.expression.spel.support.ReflectivePropertyAccessor, org.springframework.lang.Nullable, org.springframework.util.Assert, .ReflectionUtils

Represents a simple property or field reference.
Authors
Andy Clement, Juergen Hoeller, Clark Duplichien, Sam Brannen
Since
3.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private volatile PropertyAccessor
private volatile PropertyAccessor
private final String
private final boolean
private String
Inherited from org.springframework.expression.spel.ast.SpelNodeImpl:
childrenexitTypeDescriptor

Constructor Summary

AccessConstructor and Description
public
PropertyOrFieldReference(boolean nullSafe, String propertyOrFieldName, int startPos, int endPos)

Method Summary

Modifier and TypeMethod and Description
public void
generateCode(MethodVisitor
the ASM MethodVisitor into which code should be generated
mv
,
CodeFlow
a context object with info about what is on the stack
cf
)

Overrides org.springframework.expression.spel.ast.SpelNodeImpl.generateCode.

Generate the bytecode for this node into the supplied visitor.
public String
getName()

Get the name of the referenced property or field.

private List<PropertyAccessor>

Returns:

a list of resolvers that should be tried in order to access the property
getPropertyAccessorsToTry
(Object
the object upon which property access is being attempted
contextObject
,
List<PropertyAccessor> propertyAccessors)

Determines the set of property resolvers that should be used to try and access a property on the specified target type.

public TypedValue
private TypedValue
getValueInternal(TypedValue contextObject, EvaluationContext evalContext, boolean isAutoGrowNullReferences)

public ValueRef
public boolean
isCompilable()

Overrides org.springframework.expression.spel.ast.SpelNodeImpl.isCompilable.

Check whether a node can be compiled to bytecode.
public boolean
isNullSafe()

Does this node represent a null-safe property or field reference?

public boolean
isWritable(ExpressionState
the current expression state (includes the context)
state
)

Overrides org.springframework.expression.spel.ast.SpelNodeImpl.isWritable.

Implements org.springframework.expression.spel.SpelNode.isWritable.

Determine if this expression node will support a setValue() call.
public boolean
isWritableProperty(String name, TypedValue contextObject, EvaluationContext evalContext)

private TypedValue

Returns:

the value of the property
readProperty
(TypedValue contextObject, EvaluationContext evalContext, String name)

Attempt to read the named property from the current context object.

pack-priv void
public TypedValue
setValueInternal(ExpressionState
the current expression state (includes the context)
state
,
Supplier<TypedValue>
a supplier of the new value
valueSupplier
)

Overrides org.springframework.expression.spel.ast.SpelNodeImpl.setValueInternal.

Evaluate the expression to a node and then set the new value created by the specified Supplier on that node.
public String
toStringAST()

Implements org.springframework.expression.spel.SpelNode.toStringAST.

Return the string form of this AST node.
private void
writeProperty(TypedValue contextObject, EvaluationContext evalContext, String name, Object newValue)

Inherited from org.springframework.expression.spel.ast.SpelNodeImpl:
generateCodeForArgumentgenerateCodeForArgumentsgetChildgetChildCountgetEndPositiongetExitDescriptorgetObjectClassgetStartPositiongetTypedValuegetValuegetValuenextChildIssetValue

Field Detail

cachedReadAccessorback to summary
private volatile PropertyAccessor cachedReadAccessor
Annotations
@Nullable
cachedWriteAccessorback to summary
private volatile PropertyAccessor cachedWriteAccessor
Annotations
@Nullable
nameback to summary
private final String name
nullSafeback to summary
private final boolean nullSafe
originalPrimitiveExitTypeDescriptorback to summary
private String originalPrimitiveExitTypeDescriptor
Annotations
@Nullable

Constructor Detail

PropertyOrFieldReferenceback to summary
public PropertyOrFieldReference(boolean nullSafe, String propertyOrFieldName, int startPos, int endPos)

Method Detail

generateCodeback to summary
public void generateCode(MethodVisitor mv, CodeFlow cf)

Overrides org.springframework.expression.spel.ast.SpelNodeImpl.generateCode.

Doc from org.springframework.expression.spel.ast.SpelNodeImpl.generateCode.

Generate the bytecode for this node into the supplied visitor. Context info about the current expression being compiled is available in the codeflow object, e.g. including information about the type of the object currently on the stack.

Parameters
mv:MethodVisitor

the ASM MethodVisitor into which code should be generated

cf:CodeFlow

a context object with info about what is on the stack

Annotations
@Override
getNameback to summary
public String getName()

Get the name of the referenced property or field.

getPropertyAccessorsToTryback to summary
private List<PropertyAccessor> getPropertyAccessorsToTry(Object contextObject, List<PropertyAccessor> propertyAccessors)

Determines the set of property resolvers that should be used to try and access a property on the specified target type. The resolvers are considered to be in an ordered list, however in the returned list any that are exact matches for the input target type (as opposed to 'general' resolvers that could work for any type) are placed at the start of the list. In addition, there are specific resolvers that exactly name the class in question and resolvers that name a specific class but it is a supertype of the class we have. These are put at the end of the specific resolvers set and will be tried after exactly matching accessors but before generic accessors.

Parameters
contextObject:Object

the object upon which property access is being attempted

Returns:List<PropertyAccessor>

a list of resolvers that should be tried in order to access the property

getValueInternalback to summary
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException

Implements abstract org.springframework.expression.spel.ast.SpelNodeImpl.getValueInternal.

Annotations
@Override
getValueInternalback to summary
private TypedValue getValueInternal(TypedValue contextObject, EvaluationContext evalContext, boolean isAutoGrowNullReferences) throws EvaluationException
getValueRefback to summary
public ValueRef getValueRef(ExpressionState state) throws EvaluationException

Overrides org.springframework.expression.spel.ast.SpelNodeImpl.getValueRef.

Annotations
@Override
isCompilableback to summary
public boolean isCompilable()

Overrides org.springframework.expression.spel.ast.SpelNodeImpl.isCompilable.

Doc from org.springframework.expression.spel.ast.SpelNodeImpl.isCompilable.

Check whether a node can be compiled to bytecode. The reasoning in each node may be different but will typically involve checking whether the exit type descriptor of the node is known and any relevant child nodes are compilable.

Returns:boolean

true if this node can be compiled to bytecode

Annotations
@Override
isNullSafeback to summary
public boolean isNullSafe()

Does this node represent a null-safe property or field reference?

isWritableback to summary
public boolean isWritable(ExpressionState state) throws EvaluationException

Overrides org.springframework.expression.spel.ast.SpelNodeImpl.isWritable.

Implements org.springframework.expression.spel.SpelNode.isWritable.

Doc from org.springframework.expression.spel.SpelNode.isWritable.

Determine if this expression node will support a setValue() call.

Parameters
state:ExpressionState

the current expression state (includes the context)

Returns:boolean

true if the expression node will allow setValue()

Annotations
@Override
Exceptions
EvaluationException:
if something went wrong trying to determine if the node supports writing
isWritablePropertyback to summary
public boolean isWritableProperty(String name, TypedValue contextObject, EvaluationContext evalContext) throws EvaluationException
readPropertyback to summary
private TypedValue readProperty(TypedValue contextObject, EvaluationContext evalContext, String name) throws EvaluationException

Attempt to read the named property from the current context object.

Returns:TypedValue

the value of the property

Exceptions
EvaluationException:
if any problem accessing the property, or if it cannot be found
setExitTypeDescriptorback to summary
pack-priv void setExitTypeDescriptor(String descriptor)
setValueInternalback to summary
public TypedValue setValueInternal(ExpressionState state, Supplier<TypedValue> valueSupplier) throws EvaluationException

Overrides org.springframework.expression.spel.ast.SpelNodeImpl.setValueInternal.

Doc from org.springframework.expression.spel.ast.SpelNodeImpl.setValueInternal.

Evaluate the expression to a node and then set the new value created by the specified Supplier on that node.

For example, if the expression evaluates to a property reference, then the property will be set to the new value.

Favor this method over setValue(ExpressionState, Object) when the value should be lazily computed.

By default, this method throws a SpelEvaluationException, effectively disabling this feature. Subclasses may override this method to provide an actual implementation.

Parameters
state:ExpressionState

the current expression state (includes the context)

valueSupplier:Supplier<TypedValue>

a supplier of the new value

Annotations
@Override
Exceptions
EvaluationException:
if any problem occurs evaluating the expression or setting the new value
toStringASTback to summary
public String toStringAST()

Implements org.springframework.expression.spel.SpelNode.toStringAST.

Doc from org.springframework.expression.spel.SpelNode.toStringAST.

Return the string form of this AST node.

Returns:String

the string form

Annotations
@Override
writePropertyback to summary
private void writeProperty(TypedValue contextObject, EvaluationContext evalContext, String name, Object newValue) throws EvaluationException
org.springframework.expression.spel.ast back to summary

private Class PropertyOrFieldReference.AccessorValueRef

extends Object
implements ValueRef
Class Inheritance
  • java.lang.Object
  • org.springframework.expression.spel.ast.PropertyOrFieldReference.AccessorValueRef
All Implemented Interfaces
org.springframework.expression.spel.ast.ValueRef

Field Summary

Modifier and TypeField and Description
private final boolean
private final TypedValue
private final EvaluationContext
private final PropertyOrFieldReference

Constructor Summary

AccessConstructor and Description
public
AccessorValueRef(PropertyOrFieldReference propertyOrFieldReference, TypedValue activeContextObject, EvaluationContext evalContext, boolean autoGrowNullReferences)

Method Summary

Modifier and TypeMethod and Description
public TypedValue
getValue()

Implements org.springframework.expression.spel.ast.ValueRef.getValue.

Returns the value this ValueRef points to, it should not require expression component re-evaluation.
public boolean
isWritable()

Implements org.springframework.expression.spel.ast.ValueRef.isWritable.

Indicates whether calling setValue(Object) is supported.
public void
setValue(Object
the new value
newValue
)

Implements org.springframework.expression.spel.ast.ValueRef.setValue.

Sets the value this ValueRef points to, it should not require expression component re-evaluation.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

autoGrowNullReferencesback to summary
private final boolean autoGrowNullReferences
contextObjectback to summary
private final TypedValue contextObject
evalContextback to summary
private final EvaluationContext evalContext
refback to summary
private final PropertyOrFieldReference ref

Constructor Detail

AccessorValueRefback to summary
public AccessorValueRef(PropertyOrFieldReference propertyOrFieldReference, TypedValue activeContextObject, EvaluationContext evalContext, boolean autoGrowNullReferences)

Method Detail

getValueback to summary
public TypedValue getValue()

Implements org.springframework.expression.spel.ast.ValueRef.getValue.

Doc from org.springframework.expression.spel.ast.ValueRef.getValue.

Returns the value this ValueRef points to, it should not require expression component re-evaluation.

Returns:TypedValue

the value

Annotations
@Override
isWritableback to summary
public boolean isWritable()

Implements org.springframework.expression.spel.ast.ValueRef.isWritable.

Doc from org.springframework.expression.spel.ast.ValueRef.isWritable.

Indicates whether calling setValue(Object) is supported.

Returns:boolean

true if setValue() is supported for this value reference.

Annotations
@Override
setValueback to summary
public void setValue(Object newValue)

Implements org.springframework.expression.spel.ast.ValueRef.setValue.

Doc from org.springframework.expression.spel.ast.ValueRef.setValue.

Sets the value this ValueRef points to, it should not require expression component re-evaluation.

Parameters
newValue:Object

the new value

Annotations
@Override