SpelNodeImpl (Spring Framework 3.2.1.RELEASE API)
Date: 2013-01-24

org.springframework.expression.spel.ast

## Class SpelNodeImpl

- java.lang.Object
- - org.springframework.expression.spel.ast.SpelNodeImpl

- All Implemented Interfaces:
    SpelNode
  Direct Known Subclasses:
    Assign, BeanReference, CompoundExpression, ConstructorReference, Elvis, FunctionReference, Identifier, Indexer, InlineList, Literal, MethodReference, Operator, OperatorNot, Projection, PropertyOrFieldReference, QualifiedIdentifier, Selection, Ternary, TypeReference, VariableReference

      public abstract class SpelNodeImpl
      extends Object
      implements SpelNode

  The common supertype of all AST nodes in a parsed Spring Expression Language format expression.
  Since:
    3.0
  Author:
    Andy Clement

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected SpelNodeImpl[]` | `children`
    `protected int` | `pos`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SpelNodeImpl(int pos, SpelNodeImpl... operands)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `SpelNode` | `getChild(int index)` Helper method that returns a SpelNode rather than an Antlr Tree node.
    `int` | `getChildCount()`
    `int` | `getEndPosition()`
    `Class<?>` | `getObjectClass(Object obj)` Determine the class of the object passed in, unless it is already a class object.
    `protected SpelNodeImpl` | `getPreviousChild()`
    `int` | `getStartPosition()`
    `TypedValue` | `getTypedValue(ExpressionState expressionState)` Evaluate the expression node in the context of the supplied expression state and return the typed value.
    `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, Class<T> desiredReturnType)`
    `abstract TypedValue` | `getValueInternal(ExpressionState expressionState)`
    `protected ValueRef` | `getValueRef(ExpressionState state)`
    `boolean` | `isWritable(ExpressionState expressionState)` Determine if this expression node will support a setValue() call.
    `protected boolean` | `nextChildIs(Class... clazzes)`
    `void` | `setValue(ExpressionState expressionState, Object newValue)` Evaluate the expression to a node and then set the new value on that node.
    `abstract String` | `toStringAST()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### pos

          protected int pos

    - #### children

          protected SpelNodeImpl[] children

  - ### Constructor Detail

    - #### SpelNodeImpl

          public SpelNodeImpl(int pos,
                      SpelNodeImpl... operands)

  - ### Method Detail

    - #### getPreviousChild

          protected SpelNodeImpl getPreviousChild()

    - #### nextChildIs

          protected boolean nextChildIs(Class... clazzes)

      Returns:
        true if the next child is one of the specified classes

    - #### getValue

          public final 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`

    - #### getTypedValue

          public final TypedValue getTypedValue(ExpressionState expressionState)
                                         throws EvaluationException

      Description copied from interface: `SpelNode`
      Evaluate the expression node in the context of the supplied expression state and return the typed value.
      Specified by:
        `getTypedValue` in interface `SpelNode`
      Parameters:
        `expressionState` - the current expression state (includes the context)
      Returns:
        the type 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,
                      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

    - #### getChild

          public SpelNode 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 `SpelNode`
      Returns:
        the child node cast to a SpelNode

    - #### getChildCount

          public int getChildCount()

      Specified by:
        `getChildCount` in interface `SpelNode`
      Returns:
        the number of children under this node

    - #### getObjectClass

          public Class<?> getObjectClass(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`
      Parameters:
        `obj` - the object that the caller wants the class of
      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,
                       Class<T> desiredReturnType)
                              throws EvaluationException

      Throws:
        `EvaluationException`

    - #### getValueInternal

          public abstract TypedValue getValueInternal(ExpressionState expressionState)
                                               throws EvaluationException

      Throws:
        `EvaluationException`

    - #### toStringAST

          public abstract String toStringAST()

      Specified by:
        `toStringAST` in interface `SpelNode`
      Returns:
        the string form of this AST node

    - #### getStartPosition

          public int getStartPosition()

      Specified by:
        `getStartPosition` in interface `SpelNode`
      Returns:
        the start position of this Ast node in the expression string

    - #### getEndPosition

          public int getEndPosition()

      Specified by:
        `getEndPosition` in interface `SpelNode`
      Returns:
        the end position of this Ast node in the expression string

    - #### getValueRef

          protected ValueRef getValueRef(ExpressionState state)
                                  throws EvaluationException

      Throws:
        `EvaluationException`