SpelNode class abstract

One node of a parsed expression's syntax tree: a literal, a property reference, an operator, a method call, ...

SpelExpressionParser builds the tree and SpelExpression.ast exposes its root. Applications evaluate expressions, not nodes; the tree is for tools that inspect how an expression was read (its toString() prints it fully parenthesized). The concrete node classes are internal. Nodes evaluate against an ExpressionState and keep no state between evaluations that matters to callers.

// How the parser read `a + 1`.
final expression =
    SpelExpressionParser().parseExpression('a + 1') as SpelExpression;
final SpelNode ast = expression.ast; // BinaryOperator(add)
ast.toString(); // (a + 1), like Spring's toStringAST

Spring (Java):

SpelExpression expression =
    (SpelExpression) parser.parseExpression("a + 1");
SpelNode ast = expression.getAST(); // OpPlus
String text = ast.toStringAST();

Constructors

SpelNode(int start)
Creates a node whose text starts at offset start.

Properties

hashCode → int
The hash code for this object.
no setterinherited
isAssignable → bool
Whether this node can be the target of an assignment (a property, a variable other than #this / #root, an indexed element, or a chain ending in one).
no setter
isNullSafe → bool
Whether this node is a safe-navigation step (?.), which gives null on a null target instead of failing.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
start → int
The offset of the node in the expression text; error messages report it as the position.
final

Methods

assign(ExpressionState state, Object? valueSupplier()) → Object?
Assigns the value from valueSupplier to this node and returns it (Spring's setValueInternal): = and Expression.setValue.
getValue(ExpressionState state) → Object?
The value of this node in state.
getValueRef(ExpressionState state) → ValueRef
A handle to read and write the place this node names, used by ++/-- and assignment; throws SpelMessage.notAssignable unless isAssignable.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited