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

public abstract Class SpelNodeImpl

extends Object
implements SpelNode, Opcodes
Class Inheritance
All Implemented Interfaces
org.springframework.asm.Opcodes, org.springframework.expression.spel.SpelNode
Known Direct Subclasses
org.springframework.expression.spel.ast.Ternary, org.springframework.expression.spel.ast.TypeReference, org.springframework.expression.spel.ast.VariableReference, org.springframework.expression.spel.ast.Assign, org.springframework.expression.spel.ast.BeanReference, org.springframework.expression.spel.ast.CompoundExpression, org.springframework.expression.spel.ast.ConstructorReference, org.springframework.expression.spel.ast.Elvis, org.springframework.expression.spel.ast.FunctionReference, org.springframework.expression.spel.ast.Identifier, org.springframework.expression.spel.ast.Indexer, org.springframework.expression.spel.ast.InlineList, org.springframework.expression.spel.ast.InlineMap, org.springframework.expression.spel.ast.Literal, org.springframework.expression.spel.ast.MethodReference, org.springframework.expression.spel.ast.Operator, org.springframework.expression.spel.ast.OperatorNot, org.springframework.expression.spel.ast.Projection, org.springframework.expression.spel.ast.PropertyOrFieldReference, org.springframework.expression.spel.ast.QualifiedIdentifier, org.springframework.expression.spel.ast.Selection
Imports
java.lang.reflect.Constructor, .Member, .Method, java.util.function.Supplier, org.springframework.asm.MethodVisitor, .Opcodes, org.springframework.expression.EvaluationException, .TypedValue, org.springframework.expression.common.ExpressionUtils, org.springframework.expression.spel.CodeFlow, .ExpressionState, .SpelEvaluationException, .SpelMessage, .SpelNode, org.springframework.lang.Nullable, org.springframework.util.Assert, .ObjectUtils

The common supertype of all AST nodes in a parsed Spring Expression Language format expression.
Authors
Andy Clement, Juergen Hoeller, Sam Brannen
Since
3.0

Field Summary

Modifier and TypeField and Description
protected SpelNodeImpl[]
private final int
protected volatile String
exitTypeDescriptor

Indicates the type descriptor for the result of this expression node.

private static final SpelNodeImpl[]
private SpelNodeImpl
private final int

Constructor Summary

AccessConstructor and Description
public
SpelNodeImpl(int startPos, int endPos, SpelNodeImpl... operands)

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
)

Generate the bytecode for this node into the supplied visitor.

protected static void
generateCodeForArgument(MethodVisitor mv, CodeFlow cf, SpelNodeImpl argument, String paramDesc)

Ask an argument to generate its bytecode and then follow it up with any boxing/unboxing/checkcasting to ensure it matches the expected parameter descriptor.

protected static void
generateCodeForArguments(MethodVisitor
the method visitor where code should be generated
mv
,
CodeFlow
the current codeflow
cf
,
Member
the method or constructor for which arguments are being setup
member
,
SpelNodeImpl[]
the expression nodes for the expression supplied argument values
arguments
)

Generate code that handles building the argument values for the specified method.

public SpelNode
getChild(int index)

Implements org.springframework.expression.spel.SpelNode.getChild.

Helper method that returns a SpelNode rather than an Antlr Tree node.
public int
getChildCount()

Implements org.springframework.expression.spel.SpelNode.getChildCount.

Return the number of children under this node.
public int
getEndPosition()

Implements org.springframework.expression.spel.SpelNode.getEndPosition.

Return the end position of this AST node in the expression string.
public String
public Class<?>
getObjectClass(Object
the object that the caller wants the class of
obj
)

Implements org.springframework.expression.spel.SpelNode.getObjectClass.

Determine the class of the object passed in, unless it is already a class object.
public int
getStartPosition()

Implements org.springframework.expression.spel.SpelNode.getStartPosition.

Return the start position of this AST node in the expression string.
public final TypedValue
getTypedValue(ExpressionState
the current expression state (includes the context)
expressionState
)

Implements org.springframework.expression.spel.SpelNode.getTypedValue.

Evaluate the expression node in the context of the supplied expression state and return the typed value.
public final Object
getValue(ExpressionState
the current expression state (includes the context)
expressionState
)

Implements org.springframework.expression.spel.SpelNode.getValue.

Evaluate the expression node in the context of the supplied expression state and return the value.
protected final <T> T
getValue(ExpressionState state, Class<T> desiredReturnType)

public abstract TypedValue
protected ValueRef
public boolean

Returns:

true if this node can be compiled to bytecode
isCompilable
()

Check whether a node can be compiled to bytecode.

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

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

Determine if this expression node will support a setValue() call.
protected boolean
nextChildIs(Class<?>... classes)

Return true if the next child is one of the specified classes.

public void
setValue(ExpressionState
the current expression state (includes the context)
expressionState
,
Object
the new value
newValue
)

Implements org.springframework.expression.spel.SpelNode.setValue.

Evaluate the expression to a node and then set the new value on that node.
public TypedValue
setValueInternal(ExpressionState
the current expression state (includes the context)
expressionState
,
Supplier<TypedValue>
a supplier of the new value
valueSupplier
)

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

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

childrenback to summary
protected SpelNodeImpl[] children
endPosback to summary
private final int endPos
exitTypeDescriptorback to summary
protected volatile String exitTypeDescriptor

Indicates the type descriptor for the result of this expression node. This is set as soon as it is known. For a literal node it is known immediately. For a property access or method invocation it is known after one evaluation of that node.

The descriptor is like the bytecode form but is slightly easier to work with. It does not include the trailing semicolon (for non array reference types). Some examples: Ljava/lang/String, I, [I

Annotations
@Nullable
NO_CHILDRENback to summary
private static final SpelNodeImpl[] NO_CHILDREN
parentback to summary
private SpelNodeImpl parent
Annotations
@Nullable
startPosback to summary
private final int startPos

Constructor Detail

SpelNodeImplback to summary
public SpelNodeImpl(int startPos, int endPos, SpelNodeImpl... operands)

Method Detail

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

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

generateCodeForArgumentback to summary
protected static void generateCodeForArgument(MethodVisitor mv, CodeFlow cf, SpelNodeImpl argument, String paramDesc)

Ask an argument to generate its bytecode and then follow it up with any boxing/unboxing/checkcasting to ensure it matches the expected parameter descriptor.

generateCodeForArgumentsback to summary
protected static void generateCodeForArguments(MethodVisitor mv, CodeFlow cf, Member member, SpelNodeImpl[] arguments)

Generate code that handles building the argument values for the specified method. This method will take account of whether the invoked method is a varargs method and if it is then the argument values will be appropriately packaged into an array.

Parameters
mv:MethodVisitor

the method visitor where code should be generated

cf:CodeFlow

the current codeflow

member:Member

the method or constructor for which arguments are being setup

arguments:SpelNodeImpl[]

the expression nodes for the expression supplied argument values

getChildback to summary
public SpelNode getChild(int index)

Implements org.springframework.expression.spel.SpelNode.getChild.

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

Helper method that returns a SpelNode rather than an Antlr Tree node.

Returns:SpelNode

the child node cast to a SpelNode

Annotations
@Override
getChildCountback to summary
public int getChildCount()

Implements org.springframework.expression.spel.SpelNode.getChildCount.

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

Return the number of children under this node.

Returns:int

the child count

Annotations
@Override
getEndPositionback to summary
public int getEndPosition()

Implements org.springframework.expression.spel.SpelNode.getEndPosition.

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

Return the end position of this AST node in the expression string.

Returns:int

the end position

Annotations
@Override
getExitDescriptorback to summary
public String getExitDescriptor()
Annotations
@Nullable
getObjectClassback to summary
public Class<?> getObjectClass(Object obj)

Implements org.springframework.expression.spel.SpelNode.getObjectClass.

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

Determine the class of the object passed in, unless it is already a class object.

Parameters
obj:Object

the object that the caller wants the class of

Returns:Class<?>

the class of the object if it is not already a class object, or null if the object is null

Annotations
@Override
@Nullable
getStartPositionback to summary
public int getStartPosition()

Implements org.springframework.expression.spel.SpelNode.getStartPosition.

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

Return the start position of this AST node in the expression string.

Returns:int

the start position

Annotations
@Override
getTypedValueback to summary
public final TypedValue getTypedValue(ExpressionState expressionState) throws EvaluationException

Implements org.springframework.expression.spel.SpelNode.getTypedValue.

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

Evaluate the expression node in the context of the supplied expression state and return the typed value.

Parameters
expressionState:ExpressionState

the current expression state (includes the context)

Returns:TypedValue

the type value of this node evaluated against the specified state

Annotations
@Override
getValueback to summary
public final Object getValue(ExpressionState expressionState) throws EvaluationException

Implements org.springframework.expression.spel.SpelNode.getValue.

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

Evaluate the expression node in the context of the supplied expression state and return the value.

Parameters
expressionState:ExpressionState

the current expression state (includes the context)

Returns:Object

the value of this node evaluated against the specified state

Annotations
@Override
@Nullable
getValueback to summary
protected final <T> T getValue(ExpressionState state, Class<T> desiredReturnType) throws EvaluationException
Annotations
@Nullable
getValueInternalback to summary
public abstract TypedValue getValueInternal(ExpressionState expressionState) throws EvaluationException
getValueRefback to summary
protected ValueRef getValueRef(ExpressionState state) throws EvaluationException
isCompilableback to summary
public boolean 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

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

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
expressionState: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
nextChildIsback to summary
protected boolean nextChildIs(Class<?>... classes)

Return true if the next child is one of the specified classes.

setValueback to summary
public void setValue(ExpressionState expressionState, Object newValue) throws EvaluationException

Implements org.springframework.expression.spel.SpelNode.setValue.

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

Evaluate the expression to a node and then set the new value on that node. For example, if the expression evaluates to a property reference, then the property will be set to the new value.

Parameters
expressionState:ExpressionState

the current expression state (includes the context)

newValue:Object

the new value

Annotations
@Override
Exceptions
EvaluationException:
if any problem occurs evaluating the expression or setting the new value
setValueInternalback to summary
public TypedValue setValueInternal(ExpressionState expressionState, Supplier<TypedValue> valueSupplier) throws EvaluationException

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
expressionState:ExpressionState

the current expression state (includes the context)

valueSupplier:Supplier<TypedValue>

a supplier of the new value

Exceptions
EvaluationException:
if any problem occurs evaluating the expression or setting the new value
Since
5.2.24