Class StandardEvaluationContext
- All Implemented Interfaces:
- EvaluationContext
- Direct Known Subclasses:
- MethodBasedEvaluationContext
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.
 
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.
- Since:
- 3.0
- Author:
- Andy Clement, Juergen Hoeller, Sam Brannen
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionCreate aStandardEvaluationContextwith a null root object.StandardEvaluationContext(Object rootObject) Create aStandardEvaluationContextwith the given root object.
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddConstructorResolver(ConstructorResolver resolver) voidaddMethodResolver(MethodResolver resolver) voidaddPropertyAccessor(PropertyAccessor accessor) Return a bean resolver that can look up beans by name.Return a list of resolvers that will be asked in turn to locate a constructor.Return a list of resolvers that will be asked in turn to locate a method.Return an operator overloader that may support mathematical operations between more than the standard set of types.Return a list of accessors that will be asked in turn to read/write a property.Return the default root context object against which unqualified properties/methods/etc should be resolved.Return a type comparator for comparing pairs of objects for equality.Return a type converter that can convert (or coerce) a value from one type to another.Get the configuredTypeLocatorthat will be used to find types, either by short or fully-qualified name.lookupVariable(String name) Look up a named variable within this evaluation context.voidregisterFunction(String name, Method method) voidregisterMethodFilter(Class<?> type, MethodFilter filter) Register aMethodFilterwhich will be called during method resolution for the specified type.booleanremoveConstructorResolver(ConstructorResolver resolver) booleanremoveMethodResolver(MethodResolver methodResolver) booleanremovePropertyAccessor(PropertyAccessor accessor) voidsetBeanResolver(BeanResolver beanResolver) voidsetConstructorResolvers(List<ConstructorResolver> constructorResolvers) voidsetMethodResolvers(List<MethodResolver> methodResolvers) voidsetOperatorOverloader(OperatorOverloader operatorOverloader) voidsetPropertyAccessors(List<PropertyAccessor> propertyAccessors) voidsetRootObject(Object rootObject) voidsetRootObject(Object rootObject, TypeDescriptor typeDescriptor) voidsetTypeComparator(TypeComparator typeComparator) voidsetTypeConverter(TypeConverter typeConverter) voidsetTypeLocator(TypeLocator typeLocator) Set theTypeLocatorto use to find types, either by short or fully-qualified name.voidsetVariable(String name, Object value) Set a named variable in this evaluation context to a specified value.voidsetVariables(Map<String, Object> variables) Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.expression.EvaluationContextassignVariable, isAssignmentEnabled
- 
Constructor Details- 
StandardEvaluationContextpublic StandardEvaluationContext()Create aStandardEvaluationContextwith a null root object.
- 
StandardEvaluationContextCreate aStandardEvaluationContextwith the given root object.- Parameters:
- rootObject- the root object to use
- See Also:
 
 
- 
- 
Method Details- 
setRootObject
- 
setRootObject
- 
getRootObjectDescription copied from interface:EvaluationContextReturn the default root context object against which unqualified properties/methods/etc should be resolved. This can be overridden when evaluating an expression.- Specified by:
- getRootObjectin interface- EvaluationContext
 
- 
setPropertyAccessors
- 
getPropertyAccessorsDescription copied from interface:EvaluationContextReturn a list of accessors that will be asked in turn to read/write a property.- Specified by:
- getPropertyAccessorsin interface- EvaluationContext
 
- 
addPropertyAccessor
- 
removePropertyAccessor
- 
setConstructorResolvers
- 
getConstructorResolversDescription copied from interface:EvaluationContextReturn a list of resolvers that will be asked in turn to locate a constructor.- Specified by:
- getConstructorResolversin interface- EvaluationContext
 
- 
addConstructorResolver
- 
removeConstructorResolver
- 
setMethodResolvers
- 
getMethodResolversDescription copied from interface:EvaluationContextReturn a list of resolvers that will be asked in turn to locate a method.- Specified by:
- getMethodResolversin interface- EvaluationContext
 
- 
addMethodResolver
- 
removeMethodResolver
- 
setBeanResolver
- 
getBeanResolverDescription copied from interface:EvaluationContextReturn a bean resolver that can look up beans by name.- Specified by:
- getBeanResolverin interface- EvaluationContext
 
- 
setTypeLocatorSet theTypeLocatorto use to find types, either by short or fully-qualified name.By default, a StandardTypeLocatorwill be used.NOTE: Even if a StandardTypeLocatoris sufficient, you may need to manually configure aStandardTypeLocatorwith a specificClassLoaderto ensure that the SpEL expression parser is able to reliably locate user types.- Parameters:
- typeLocator- the- TypeLocatorto use
- See Also:
 
- 
getTypeLocatorGet the configuredTypeLocatorthat will be used to find types, either by short or fully-qualified name.See setTypeLocator(TypeLocator)for further details.- Specified by:
- getTypeLocatorin interface- EvaluationContext
- See Also:
 
- 
setTypeConverter
- 
getTypeConverterDescription copied from interface:EvaluationContextReturn a type converter that can convert (or coerce) a value from one type to another.- Specified by:
- getTypeConverterin interface- EvaluationContext
 
- 
setTypeComparator
- 
getTypeComparatorDescription copied from interface:EvaluationContextReturn a type comparator for comparing pairs of objects for equality.- Specified by:
- getTypeComparatorin interface- EvaluationContext
 
- 
setOperatorOverloader
- 
getOperatorOverloaderDescription copied from interface:EvaluationContextReturn an operator overloader that may support mathematical operations between more than the standard set of types.- Specified by:
- getOperatorOverloaderin interface- EvaluationContext
 
- 
setVariableDescription copied from interface:EvaluationContextSet a named variable in this evaluation context to a specified value.In contrast to EvaluationContext.assignVariable(String, Supplier), this method should only be invoked programmatically when interacting directly with theEvaluationContext— for example, to provide initial configuration for the context.- Specified by:
- setVariablein interface- EvaluationContext
- Parameters:
- name- the name of the variable to set
- value- the value to be placed in the variable
 
- 
setVariables
- 
registerFunction
- 
lookupVariableDescription copied from interface:EvaluationContextLook up a named variable within this evaluation context.- Specified by:
- lookupVariablein interface- EvaluationContext
- Parameters:
- name- the name of the variable to look up
- Returns:
- the value of the variable, or nullif not found
 
- 
registerMethodFilterRegister aMethodFilterwhich will be called during method resolution for the specified type.The MethodFiltermay remove methods and/or sort the methods which will then be used by SpEL as the candidates to look through for a match.- Parameters:
- type- the type for which the filter should be called
- filter- a- MethodFilter, or- nullto unregister a filter for the type
- Throws:
- IllegalStateException- if the- ReflectiveMethodResolveris not in use
 
 
-