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

public Class ExpressionState

extends Object
Class Inheritance
Imports
java.util.ArrayDeque, .Collections, .Deque, .HashMap, .List, .Map, .NoSuchElementException, java.util.function.Supplier, org.springframework.core.convert.TypeDescriptor, org.springframework.expression.EvaluationContext, .EvaluationException, .Operation, .OperatorOverloader, .PropertyAccessor, .TypeComparator, .TypeConverter, .TypedValue, org.springframework.lang.Nullable, org.springframework.util.Assert, .CollectionUtils

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.

Authors
Andy Clement, Juergen Hoeller, Sam Brannen
Since
3.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
ExpressionState.VariableScope

A new scope is entered when a function is called and it is used to hold the parameters to the function call.

Field Summary

Modifier and TypeField and Description
private final SpelParserConfiguration
private Deque<TypedValue>
private final EvaluationContext
private final TypedValue
private ArrayDeque<TypedValue>
private Deque<ExpressionState.VariableScope>

Constructor Summary

AccessConstructor and Description
public
public
public
public

Method Summary

Modifier and TypeMethod and Description
public TypedValue

Returns:

a TypedValue wrapping the assigned value
assignVariable
(String
the name of the variable to assign
name
,
Supplier<TypedValue>
the supplier of the value to be assigned to the variable
valueSupplier
)

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

public Object
convertValue(Object value, TypeDescriptor targetTypeDescriptor)

public Object
convertValue(TypedValue value, TypeDescriptor targetTypeDescriptor)

public void
public void
public void
enterScope(String name, Object value)

public void
public Class<?>
public TypedValue
getActiveContextObject()

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

public SpelParserConfiguration
public EvaluationContext
public List<PropertyAccessor>
public TypedValue
public TypedValue
public TypeComparator
public TypeConverter
private Deque<TypedValue>
private Deque<ExpressionState.VariableScope>
public Object
public TypedValue
public TypedValue
operate(Operation op, Object left, Object right)

public void
public void
public void
public void
setVariable(String
the name of the variable to set
name
,
Object
the value to be placed in the variable
value
)

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

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

configurationback to summary
private final SpelParserConfiguration configuration
contextObjectsback to summary
private Deque<TypedValue> contextObjects
Annotations
@Nullable
relatedContextback to summary
private final EvaluationContext relatedContext
rootObjectback to summary
private final TypedValue rootObject
scopeRootObjectsback to summary
private ArrayDeque<TypedValue> scopeRootObjects
Annotations
@Nullable
variableScopesback to summary
private Deque<ExpressionState.VariableScope> variableScopes
Annotations
@Nullable

Constructor Detail

ExpressionStateback to summary
public ExpressionState(EvaluationContext context)
ExpressionStateback to summary
public ExpressionState(EvaluationContext context, SpelParserConfiguration configuration)
ExpressionStateback to summary
public ExpressionState(EvaluationContext context, TypedValue rootObject)
ExpressionStateback to summary
public ExpressionState(EvaluationContext context, TypedValue rootObject, SpelParserConfiguration configuration)

Method Detail

assignVariableback to summary
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:String

the name of the variable to assign

valueSupplier:Supplier<TypedValue>

the supplier of the value to be assigned to the variable

Returns:TypedValue

a TypedValue wrapping the assigned value

Since
5.2.24
See Also
EvaluationContext#assignVariable(String, Supplier)
convertValueback to summary
public Object convertValue(Object value, TypeDescriptor targetTypeDescriptor) throws EvaluationException
convertValueback to summary
public Object convertValue(TypedValue value, TypeDescriptor targetTypeDescriptor) throws EvaluationException
Annotations
@Nullable
enterScopeback to summary
public void enterScope(Map<String, Object> argMap)
enterScopeback to summary
public void enterScope()
enterScopeback to summary
public void enterScope(String name, Object value)
exitScopeback to summary
public void exitScope()
findTypeback to summary
public Class<?> findType(String type) throws EvaluationException
getActiveContextObjectback to summary
public TypedValue getActiveContextObject()

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

getConfigurationback to summary
public SpelParserConfiguration getConfiguration()
getEvaluationContextback to summary
public EvaluationContext getEvaluationContext()
getPropertyAccessorsback to summary
public List<PropertyAccessor> getPropertyAccessors()
getRootContextObjectback to summary
public TypedValue getRootContextObject()
getScopeRootContextObjectback to summary
public TypedValue getScopeRootContextObject()
getTypeComparatorback to summary
public TypeComparator getTypeComparator()
getTypeConverterback to summary
public TypeConverter getTypeConverter()
initScopeRootObjectsback to summary
private Deque<TypedValue> initScopeRootObjects()
initVariableScopesback to summary
private Deque<ExpressionState.VariableScope> initVariableScopes()
lookupLocalVariableback to summary
public Object lookupLocalVariable(String name)
Annotations
@Nullable
lookupVariableback to summary
public TypedValue lookupVariable(String name)
operateback to summary
public TypedValue operate(Operation op, Object left, Object right) throws EvaluationException
popActiveContextObjectback to summary
public void popActiveContextObject()
pushActiveContextObjectback to summary
public void pushActiveContextObject(TypedValue obj)
setLocalVariableback to summary
public void setLocalVariable(String name, Object value)
setVariableback to summary
public void setVariable(String name, 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:String

the name of the variable to set

value:Object

the value to be placed in the variable

See Also
EvaluationContext#setVariable(String, Object)
org.springframework.expression.spel back to summary

private Class ExpressionState.VariableScope

extends Object
Class Inheritance
  • java.lang.Object
  • org.springframework.expression.spel.ExpressionState.VariableScope

A new scope is entered when a function is called and it is used to hold the parameters to the function call. If the names of the parameters clash with those in a higher level scope, those in the higher level scope will not be accessible whilst the function is executing. When the function returns, the scope is exited.

Field Summary

Modifier and TypeField and Description
private final Map<String, Object>

Constructor Summary

AccessConstructor and Description
public
public
public

Method Summary

Modifier and TypeMethod and Description
public boolean
public Object
public void
setVariable(String name, Object value)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

varsback to summary
private final Map<String, Object> vars

Constructor Detail

VariableScopeback to summary
public VariableScope()
VariableScopeback to summary
public VariableScope(Map<String, Object> arguments)
VariableScopeback to summary
public VariableScope(String name, Object value)

Method Detail

definesVariableback to summary
public boolean definesVariable(String name)
lookupVariableback to summary
public Object lookupVariable(String name)
Annotations
@Nullable
setVariableback to summary
public void setVariable(String name, Object value)