org.springframework.expression.spel

## Class ExpressionState

- java.lang.Object
- - org.springframework.expression.spel.ExpressionState

-     public class ExpressionState
      extends Object

  ExpressionState is for maintaining per-expression-evaluation state: any changes to it are not seen by other expressions, but it gives a place to hold local variables and for component expressions in a compound expression to communicate state. This is in contrast to the EvaluationContext, which is shared amongst expression evaluations, and any changes to it will be seen by other expressions or any code that chooses to ask questions of the context.

  It also acts as a place to define common utility routines that the various AST nodes might need.

  Since:
    3.0
  Author:
    Andy Clement, Juergen Hoeller, Sam Brannen

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ExpressionState(EvaluationContext context)`
    `ExpressionState(EvaluationContext context, SpelParserConfiguration configuration)`
    `ExpressionState(EvaluationContext context, TypedValue rootObject)`
    `ExpressionState(EvaluationContext context, TypedValue rootObject, SpelParserConfiguration configuration)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `TypedValue` | `assignVariable(String name, Supplier<TypedValue> valueSupplier)` Assign the value created by the specified `Supplier` to a named variable within the evaluation context.
    `Object` | `convertValue(Object value, TypeDescriptor targetTypeDescriptor)`
    `Object` | `convertValue(TypedValue value, TypeDescriptor targetTypeDescriptor)`
    `void` | `enterScope()`
    `void` | `enterScope(Map<String,Object> argMap)`
    `void` | `enterScope(String name, Object value)`
    `void` | `exitScope()`
    `Class<?>` | `findType(String type)`
    `TypedValue` | `getActiveContextObject()` The active context object is what unqualified references to properties/etc are resolved against.
    `SpelParserConfiguration` | `getConfiguration()`
    `EvaluationContext` | `getEvaluationContext()`
    `List<PropertyAccessor>` | `getPropertyAccessors()`
    `TypedValue` | `getRootContextObject()`
    `TypedValue` | `getScopeRootContextObject()`
    `TypeComparator` | `getTypeComparator()`
    `TypeConverter` | `getTypeConverter()`
    `Object` | `lookupLocalVariable(String name)`
    `TypedValue` | `lookupVariable(String name)`
    `TypedValue` | `operate(Operation op, Object left, Object right)`
    `void` | `popActiveContextObject()`
    `void` | `pushActiveContextObject(TypedValue obj)`
    `void` | `setLocalVariable(String name, Object value)`
    `void` | `setVariable(String name, Object value)` Set a named variable in the evaluation context to a specified value.

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

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

- - ### Constructor Detail

    - #### ExpressionState

          public ExpressionState(EvaluationContext context)

    - #### ExpressionState

          public ExpressionState(EvaluationContext context,
                                 SpelParserConfiguration configuration)

    - #### ExpressionState

          public ExpressionState(EvaluationContext context,
                                 TypedValue rootObject)

    - #### ExpressionState

          public ExpressionState(EvaluationContext context,
                                 TypedValue rootObject,
                                 SpelParserConfiguration configuration)

  - ### Method Detail

    - #### getActiveContextObject

          public TypedValue getActiveContextObject()

      The active context object is what unqualified references to properties/etc are resolved against.

    - #### pushActiveContextObject

          public void pushActiveContextObject(TypedValue obj)

    - #### popActiveContextObject

          public void popActiveContextObject()

    - #### getRootContextObject

          public TypedValue getRootContextObject()

    - #### getScopeRootContextObject

          public TypedValue getScopeRootContextObject()

    - #### assignVariable

          public TypedValue assignVariable(String name,
                                           Supplier<TypedValue> valueSupplier)

      Assign the value created by the specified `Supplier` to a named variable within the evaluation context.

      In contrast to `setVariable(String, Object)`, this method should only be invoked to support assignment within an expression.

      Parameters:
        `name` - the name of the variable to assign
        `valueSupplier` - the supplier of the value to be assigned to the variable
      Returns:
        a `TypedValue` wrapping the assigned value
      Since:
        5.2.24
      See Also:
        `EvaluationContext.assignVariable(String, Supplier)`

    - #### setVariable

          public void setVariable(String name,
                                  @Nullable
                                  Object value)

      Set a named variable in the evaluation context to a specified value.

      In contrast to `assignVariable(String, Supplier)`, this method should only be invoked programmatically.

      Parameters:
        `name` - the name of the variable to set
        `value` - the value to be placed in the variable
      See Also:
        `EvaluationContext.setVariable(String, Object)`

    - #### lookupVariable

          public TypedValue lookupVariable(String name)

    - #### getTypeComparator

          public TypeComparator getTypeComparator()

    - #### findType

          public Class<?> findType(String type)
                            throws EvaluationException

      Throws:
        `EvaluationException`

    - #### convertValue

          public Object convertValue(Object value,
                                     TypeDescriptor targetTypeDescriptor)
                              throws EvaluationException

      Throws:
        `EvaluationException`

    - #### getTypeConverter

          public TypeConverter getTypeConverter()

    - #### convertValue

          @Nullable
          public Object convertValue(TypedValue value,
                                               TypeDescriptor targetTypeDescriptor)
                                        throws EvaluationException

      Throws:
        `EvaluationException`

    - #### enterScope

          public void enterScope(Map<String,Object> argMap)

    - #### enterScope

          public void enterScope()

    - #### enterScope

          public void enterScope(String name,
                                 Object value)

    - #### exitScope

          public void exitScope()

    - #### setLocalVariable

          public void setLocalVariable(String name,
                                       Object value)

    - #### lookupLocalVariable

          @Nullable
          public Object lookupLocalVariable(String name)

    - #### operate

          public TypedValue operate(Operation op,
                                    @Nullable
                                    Object left,
                                    @Nullable
                                    Object right)
                             throws EvaluationException

      Throws:
        `EvaluationException`

    - #### getPropertyAccessors

          public List<PropertyAccessor> getPropertyAccessors()

    - #### getEvaluationContext

          public EvaluationContext getEvaluationContext()

    - #### getConfiguration

          public SpelParserConfiguration getConfiguration()