org.springframework.expression.spel.ast
Class SpelNodeImpl

java.lang.Object
  extended by org.antlr.runtime.tree.BaseTree
      extended by org.antlr.runtime.tree.CommonTree
          extended by org.springframework.expression.spel.ast.SpelNodeImpl
All Implemented Interfaces:
java.io.Serializable, org.antlr.runtime.tree.Tree, CommonTypeDescriptors, SpelNode
Direct Known Subclasses:
Assign, CompoundExpression, ConstructorReference, Dot, EmptySpelNode, FunctionReference, Identifier, Indexer, Literal, MethodReference, Operator, OperatorNot, Projection, PropertyOrFieldReference, QualifiedIdentifier, Selection, Ternary, TypeReference, VariableReference

public abstract class SpelNodeImpl
extends org.antlr.runtime.tree.CommonTree
implements SpelNode, java.io.Serializable, CommonTypeDescriptors

The common supertype of all AST nodes in a parsed Spring Expression Language format expression.

Since:
3.0
Author:
Andy Clement
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.antlr.runtime.tree.CommonTree
startIndex, stopIndex, token
 
Fields inherited from class org.antlr.runtime.tree.BaseTree
children
 
Fields inherited from interface org.springframework.expression.spel.ast.CommonTypeDescriptors
BOOLEAN_TYPE_DESCRIPTOR, BYTE_TYPE_DESCRIPTOR, CHARACTER_TYPE_DESCRIPTOR, CLASS_TYPE_DESCRIPTOR, DOUBLE_TYPE_DESCRIPTOR, FLOAT_TYPE_DESCRIPTOR, INTEGER_TYPE_DESCRIPTOR, LONG_TYPE_DESCRIPTOR, OBJECT_TYPE_DESCRIPTOR, SHORT_TYPE_DESCRIPTOR, STRING_TYPE_DESCRIPTOR
 
Fields inherited from interface org.antlr.runtime.tree.Tree
INVALID_NODE
 
Constructor Summary
protected SpelNodeImpl(org.antlr.runtime.Token payload)
          The Antlr parser uses this constructor to build SpelNodes.
 
Method Summary
 SpelNodeImpl getChild(int index)
          Helper method that returns a SpelNode rather than an Antlr Tree node.
 java.lang.Class<?> getObjectClass(java.lang.Object obj)
          Determine the class of the object passed in, unless it is already a class object.
 int getStartPosition()
           
protected  java.lang.String getTokenName()
           
 java.lang.Object getValue(ExpressionState expressionState)
          Evaluate the expression node in the context of the supplied expression state and return the value.
protected
<T> T
getValue(ExpressionState state, java.lang.Class<T> desiredReturnType)
           
abstract  TypedValue getValueInternal(ExpressionState expressionState)
           
 boolean isWritable(ExpressionState expressionState)
          Determine if this expression node will support a setValue() call.
 void setValue(ExpressionState expressionState, java.lang.Object newValue)
          Evaluate the expression to a node and then set the new value on that node.
abstract  java.lang.String toStringAST()
           
 
Methods inherited from class org.antlr.runtime.tree.CommonTree
dupNode, getCharPositionInLine, getLine, getText, getToken, getTokenStartIndex, getTokenStopIndex, getType, isNil, setTokenStartIndex, setTokenStopIndex, toString
 
Methods inherited from class org.antlr.runtime.tree.BaseTree
addChild, addChildren, createChildrenList, deleteChild, dupTree, getChildCount, getFirstChildWithType, setChild, toStringTree
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.springframework.expression.spel.SpelNode
getChildCount
 

Constructor Detail

SpelNodeImpl

protected SpelNodeImpl(org.antlr.runtime.Token payload)
The Antlr parser uses this constructor to build SpelNodes.

Parameters:
payload - the token for the node that has been parsed
Method Detail

getValue

public final java.lang.Object getValue(ExpressionState expressionState)
                                throws EvaluationException
Description copied from interface: SpelNode
Evaluate the expression node in the context of the supplied expression state and return the value.

Specified by:
getValue in interface SpelNode
Parameters:
expressionState - the current expression state (includes the context)
Returns:
the value of this node evaluated against the specified state
Throws:
EvaluationException

isWritable

public boolean isWritable(ExpressionState expressionState)
                   throws EvaluationException
Description copied from interface: SpelNode
Determine if this expression node will support a setValue() call.

Specified by:
isWritable in interface SpelNode
Parameters:
expressionState - the current expression state (includes the context)
Returns:
true if the expression node will allow setValue()
Throws:
EvaluationException - if something went wrong trying to determine if the node supports writing

setValue

public void setValue(ExpressionState expressionState,
                     java.lang.Object newValue)
              throws EvaluationException
Description copied from interface: SpelNode
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.

Specified by:
setValue in interface SpelNode
Parameters:
expressionState - the current expression state (includes the context)
newValue - the new value
Throws:
EvaluationException - if any problem occurs evaluating the expression or setting the new value

getTokenName

protected java.lang.String getTokenName()

getChild

public SpelNodeImpl getChild(int index)
Description copied from interface: SpelNode
Helper method that returns a SpelNode rather than an Antlr Tree node.

Specified by:
getChild in interface org.antlr.runtime.tree.Tree
Specified by:
getChild in interface SpelNode
Overrides:
getChild in class org.antlr.runtime.tree.BaseTree
Returns:
the child node cast to a SpelNode

getObjectClass

public java.lang.Class<?> getObjectClass(java.lang.Object obj)
Description copied from interface: SpelNode
Determine the class of the object passed in, unless it is already a class object.

Specified by:
getObjectClass in interface SpelNode
Returns:
the class of the object if it is not already a class object, or null if the object is null

getValue

protected final <T> T getValue(ExpressionState state,
                               java.lang.Class<T> desiredReturnType)
                    throws EvaluationException
Throws:
EvaluationException

getStartPosition

public int getStartPosition()
Specified by:
getStartPosition in interface SpelNode
Returns:
the start position of this Ast node in the expression string

getValueInternal

public abstract TypedValue getValueInternal(ExpressionState expressionState)
                                     throws EvaluationException
Throws:
EvaluationException

toStringAST

public abstract java.lang.String toStringAST()
Specified by:
toStringAST in interface SpelNode
Returns:
the string form of this AST node