EvaluationContext implementation.
This context uses standard implementations of all applicable strategies,
based on reflection to resolve properties, methods, and fields. Note, however,
that you may need to manually configure a StandardTypeLocator with a
specific ClassLoader to ensure that the SpEL expression parser is able
to reliably locate user types. See setTypeLocator(TypeLocator) for
details.
In addition to support for setting and looking up variables as defined in
the EvaluationContext API, StandardEvaluationContext also
provides support for registering and looking up functions. The
registerFunction(...) methods provide a convenient way to register a
function as a Method or a MethodHandle; however, a function
can also be registered via setVariable(String, Object) or
setVariables(Map). Since functions share a namespace with the variables
in this evaluation context, care must be taken to ensure that function names
and variable names do not overlap.
For a simpler, builder-style context variant for data-binding purposes,
consider using SimpleEvaluationContext instead which allows for
opting into several SpEL features as needed by specific use cases.
SimpleEvaluationContext, ReflectivePropertyAccessor, ReflectiveConstructorResolver, ReflectiveMethodResolver, StandardTypeLocator, StandardTypeConverter, StandardTypeComparator, StandardOperatorOverloader
| Modifier and Type | Field and Description |
|---|---|
| private BeanResolver | |
| private volatile List | |
| private volatile List | |
| private OperatorOverloader | |
| private volatile List | |
| private volatile ReflectiveMethodResolver | |
| private TypedValue | |
| private TypeComparator | |
| private TypeConverter | |
| private TypeLocator | |
| private final Map |
| Access | Constructor and Description |
|---|---|
| public | |
| public | StandardEvaluationContext(Object
the root object to use rootObject)Create a |
| Modifier and Type | Method and Description |
|---|---|
| private static <T> void | |
| public void | |
| public void | |
| public void | |
| public void | applyDelegatesTo(StandardEvaluationContext
the evaluation context to update evaluationContext)Apply the internal delegates of this instance to the specified
|
| public BeanResolver | getBeanResolver()
Implements org. Return a bean resolver that can look up beans by name. |
| public List | getConstructorResolvers()
Implements org. Return a list of resolvers that will be asked in turn to locate a constructor. |
| public List | getMethodResolvers()
Implements org. Return a list of resolvers that will be asked in turn to locate a method. |
| public OperatorOverloader | getOperatorOverloader()
Implements org. Return an operator overloader that may support mathematical operations between more than the standard set of types. |
| public List | getPropertyAccessors()
Implements org. Return a list of accessors that will be asked in turn to read/write a property. |
| public TypedValue | getRootObject()
Implements org. Return the default root context object against which unqualified properties/methods/etc should be resolved. |
| public TypeComparator | getTypeComparator()
Implements org. Return a type comparator for comparing pairs of objects for equality. |
| public TypeConverter | getTypeConverter()
Implements org. Return a type converter that can convert (or coerce) a value from one type to another. |
| public TypeLocator | getTypeLocator()
Implements org. Get the configured |
| private List | |
| private List | |
| private List | |
| public Object | Returns: the value of the variable or function, ornull if not foundthe name of the variable or function to look up name)Implements org. Look up a named variable or function within this evaluation context. |
| public void | registerFunction(String
the name of the function name, Method the method)Method to registerRegister the specified |
| public void | registerFunction(String
the name of the function name, MethodHandle the methodHandle)MethodHandle to registerRegister the specified |
| public void | registerMethodFilter(Class<?>
the type for which the filter should be called type, MethodFilter a filter)MethodFilter, or null to unregister a filter for the typeRegister a |
| public boolean | |
| public boolean | |
| public boolean | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | setTypeLocator(TypeLocator
the typeLocator)TypeLocator to useSet the |
| public void | setVariable(String
the name of the variable to set name, Object the value to be placed in the variable value)Implements org. Set a named variable in this evaluation context to a specified value. |
| public void | setVariables(Map<String, Object>
the names and values of the variables to set variables)Set multiple named variables in this evaluation context to the specified values. |
| beanResolver | back to summary |
|---|---|
| private BeanResolver beanResolver
| |
| constructorResolvers | back to summary |
|---|---|
| private volatile List<ConstructorResolver> constructorResolvers
| |
| methodResolvers | back to summary |
|---|---|
| private volatile List<MethodResolver> methodResolvers
| |
| operatorOverloader | back to summary |
|---|---|
| private OperatorOverloader operatorOverloader | |
| propertyAccessors | back to summary |
|---|---|
| private volatile List<PropertyAccessor> propertyAccessors
| |
| reflectiveMethodResolver | back to summary |
|---|---|
| private volatile ReflectiveMethodResolver reflectiveMethodResolver
| |
| rootObject | back to summary |
|---|---|
| private TypedValue rootObject | |
| typeComparator | back to summary |
|---|---|
| private TypeComparator typeComparator | |
| typeConverter | back to summary |
|---|---|
| private TypeConverter typeConverter
| |
| typeLocator | back to summary |
|---|---|
| private TypeLocator typeLocator
| |
| variables | back to summary |
|---|---|
| private final Map<String, Object> variables | |
| StandardEvaluationContext | back to summary |
|---|---|
| public StandardEvaluationContext() Create a | |
| StandardEvaluationContext | back to summary |
|---|---|
| public StandardEvaluationContext(Object rootObject) Create a
| |
| addBeforeDefault | back to summary |
|---|---|
| private static <T> void addBeforeDefault(List<T> resolvers, T resolver) | |
| addConstructorResolver | back to summary |
|---|---|
| public void addConstructorResolver(ConstructorResolver resolver) | |
| addMethodResolver | back to summary |
|---|---|
| public void addMethodResolver(MethodResolver resolver) | |
| addPropertyAccessor | back to summary |
|---|---|
| public void addPropertyAccessor(PropertyAccessor accessor) | |
| applyDelegatesTo | back to summary |
|---|---|
| public void applyDelegatesTo(StandardEvaluationContext evaluationContext) Apply the internal delegates of this instance to the specified
| |
| getBeanResolver | back to summary |
|---|---|
| public BeanResolver getBeanResolver() Implements org. Doc from org. Return a bean resolver that can look up beans by name. | |
| getConstructorResolvers | back to summary |
|---|---|
| public List Implements org. Doc from org. Return a list of resolvers that will be asked in turn to locate a constructor.
| |
| getMethodResolvers | back to summary |
|---|---|
| public List Implements org. Doc from org. Return a list of resolvers that will be asked in turn to locate a method.
| |
| getOperatorOverloader | back to summary |
|---|---|
| public OperatorOverloader getOperatorOverloader() Implements org. Doc from org. Return an operator overloader that may support mathematical operations between more than the standard set of types.
| |
| getPropertyAccessors | back to summary |
|---|---|
| public List Implements org. Doc from org. Return a list of accessors that will be asked in turn to read/write a property.
| |
| getRootObject | back to summary |
|---|---|
| public TypedValue getRootObject() Implements org. Doc from org. Return the default root context object against which unqualified properties/methods/etc should be resolved. This can be overridden when evaluating an expression.
| |
| getTypeComparator | back to summary |
|---|---|
| public TypeComparator getTypeComparator() Implements org. Doc from org. Return a type comparator for comparing pairs of objects for equality.
| |
| getTypeConverter | back to summary |
|---|---|
| public TypeConverter getTypeConverter() Implements org. Doc from org. Return a type converter that can convert (or coerce) a value from one type to another.
| |
| getTypeLocator | back to summary |
|---|---|
| public TypeLocator getTypeLocator() Implements org. Get the configured See
| |
| initConstructorResolvers | back to summary |
|---|---|
| private List | |
| initMethodResolvers | back to summary |
|---|---|
| private List | |
| initPropertyAccessors | back to summary |
|---|---|
| private List | |
| lookupVariable | back to summary |
|---|---|
| public Object lookupVariable(String name) Implements org. Look up a named variable or function within this evaluation context. Note that variables and functions share a common namespace in this evaluation context. See the class-level documentation for details. | |
| registerFunction | back to summary |
|---|---|
| public void registerFunction(String name, Method method) Register the specified Note that variables and functions share a common namespace in this evaluation context. See the class-level documentation for details.
| |
| registerFunction | back to summary |
|---|---|
| public void registerFunction(String name, MethodHandle methodHandle) Register the specified Note that variables and functions share a common namespace in this evaluation context. See the class-level documentation for details.
| |
| registerMethodFilter | back to summary |
|---|---|
| public void registerMethodFilter(Class<?> type, MethodFilter filter) throws IllegalStateException Register a The
| |
| removeConstructorResolver | back to summary |
|---|---|
| public boolean removeConstructorResolver(ConstructorResolver resolver) | |
| removeMethodResolver | back to summary |
|---|---|
| public boolean removeMethodResolver(MethodResolver methodResolver) | |
| removePropertyAccessor | back to summary |
|---|---|
| public boolean removePropertyAccessor(PropertyAccessor accessor) | |
| setBeanResolver | back to summary |
|---|---|
| public void setBeanResolver(BeanResolver beanResolver) | |
| setConstructorResolvers | back to summary |
|---|---|
| public void setConstructorResolvers(List<ConstructorResolver> constructorResolvers) | |
| setMethodResolvers | back to summary |
|---|---|
| public void setMethodResolvers(List<MethodResolver> methodResolvers) | |
| setOperatorOverloader | back to summary |
|---|---|
| public void setOperatorOverloader(OperatorOverloader operatorOverloader) | |
| setPropertyAccessors | back to summary |
|---|---|
| public void setPropertyAccessors(List<PropertyAccessor> propertyAccessors) | |
| setRootObject | back to summary |
|---|---|
| public void setRootObject(Object rootObject, TypeDescriptor typeDescriptor) | |
| setRootObject | back to summary |
|---|---|
| public void setRootObject(Object rootObject) | |
| setTypeComparator | back to summary |
|---|---|
| public void setTypeComparator(TypeComparator typeComparator) | |
| setTypeConverter | back to summary |
|---|---|
| public void setTypeConverter(TypeConverter typeConverter) | |
| setTypeLocator | back to summary |
|---|---|
| public void setTypeLocator(TypeLocator typeLocator) Set the By default, a Note Even if a
| |
| setVariable | back to summary |
|---|---|
| public void setVariable(String name, Object value) Implements org. Set a named variable in this evaluation context to a specified value. If the specified In contrast to Note that variables and functions share a common namespace in this evaluation context. See the class-level documentation for details.
| |
| setVariables | back to summary |
|---|---|
| public void setVariables(Map<String, Object> variables) Set multiple named variables in this evaluation context to the specified values. This is a convenience variant of Note that variables and functions share a common namespace in this evaluation context. See the class-level documentation for details.
| |