public class StandardEvaluationContext extends Object implements EvaluationContext
EvaluationContext implementation.
This context uses standard implementations of all applicable strategies,
based on reflection to resolve properties, methods and fields.
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 evaluation cases.
| Constructor and Description |
|---|
StandardEvaluationContext()
Create a
StandardEvaluationContext with a null root object. |
StandardEvaluationContext(Object rootObject)
Create a
StandardEvaluationContext with the given root object. |
| Modifier and Type | Method and Description |
|---|---|
void |
addConstructorResolver(ConstructorResolver resolver) |
void |
addMethodResolver(MethodResolver resolver) |
void |
addPropertyAccessor(PropertyAccessor accessor) |
BeanResolver |
getBeanResolver()
Return a bean resolver that can look up beans by name.
|
List<ConstructorResolver> |
getConstructorResolvers()
Return a list of resolvers that will be asked in turn to locate a constructor.
|
List<MethodResolver> |
getMethodResolvers()
Return a list of resolvers that will be asked in turn to locate a method.
|
OperatorOverloader |
getOperatorOverloader()
Return an operator overloader that may support mathematical operations
between more than the standard set of types.
|
List<PropertyAccessor> |
getPropertyAccessors()
Return a list of accessors that will be asked in turn to read/write a property.
|
TypedValue |
getRootObject()
Return the default root context object against which unqualified
properties/methods/etc should be resolved.
|
TypeComparator |
getTypeComparator()
Return a type comparator for comparing pairs of objects for equality.
|
TypeConverter |
getTypeConverter()
Return a type converter that can convert (or coerce) a value from one type to another.
|
TypeLocator |
getTypeLocator()
Return a type locator that can be used to find types, either by short or
fully qualified name.
|
Object |
lookupVariable(String name)
Look up a named variable within this evaluation context.
|
void |
registerFunction(String name,
Method method) |
void |
registerMethodFilter(Class<?> type,
MethodFilter filter)
Register a
MethodFilter which will be called during method resolution
for the specified type. |
boolean |
removeConstructorResolver(ConstructorResolver resolver) |
boolean |
removeMethodResolver(MethodResolver methodResolver) |
boolean |
removePropertyAccessor(PropertyAccessor accessor) |
void |
setBeanResolver(BeanResolver beanResolver) |
void |
setConstructorResolvers(List<ConstructorResolver> constructorResolvers) |
void |
setMethodResolvers(List<MethodResolver> methodResolvers) |
void |
setOperatorOverloader(OperatorOverloader operatorOverloader) |
void |
setPropertyAccessors(List<PropertyAccessor> propertyAccessors) |
void |
setRootObject(Object rootObject) |
void |
setRootObject(Object rootObject,
TypeDescriptor typeDescriptor) |
void |
setTypeComparator(TypeComparator typeComparator) |
void |
setTypeConverter(TypeConverter typeConverter) |
void |
setTypeLocator(TypeLocator typeLocator) |
void |
setVariable(String name,
Object value)
Set a named variable within this evaluation context to a specified value.
|
void |
setVariables(Map<String,Object> variables) |
public StandardEvaluationContext()
StandardEvaluationContext with a null root object.public StandardEvaluationContext(Object rootObject)
StandardEvaluationContext with the given root object.rootObject - the root object to usesetRootObject(java.lang.Object, org.springframework.core.convert.TypeDescriptor)public void setRootObject(Object rootObject, TypeDescriptor typeDescriptor)
public void setRootObject(Object rootObject)
public TypedValue getRootObject()
EvaluationContextgetRootObject in interface EvaluationContextpublic void setPropertyAccessors(List<PropertyAccessor> propertyAccessors)
public List<PropertyAccessor> getPropertyAccessors()
EvaluationContextgetPropertyAccessors in interface EvaluationContextpublic void addPropertyAccessor(PropertyAccessor accessor)
public boolean removePropertyAccessor(PropertyAccessor accessor)
public void setConstructorResolvers(List<ConstructorResolver> constructorResolvers)
public List<ConstructorResolver> getConstructorResolvers()
EvaluationContextgetConstructorResolvers in interface EvaluationContextpublic void addConstructorResolver(ConstructorResolver resolver)
public boolean removeConstructorResolver(ConstructorResolver resolver)
public void setMethodResolvers(List<MethodResolver> methodResolvers)
public List<MethodResolver> getMethodResolvers()
EvaluationContextgetMethodResolvers in interface EvaluationContextpublic void addMethodResolver(MethodResolver resolver)
public boolean removeMethodResolver(MethodResolver methodResolver)
public void setBeanResolver(BeanResolver beanResolver)
public BeanResolver getBeanResolver()
EvaluationContextgetBeanResolver in interface EvaluationContextpublic void setTypeLocator(TypeLocator typeLocator)
public TypeLocator getTypeLocator()
EvaluationContextgetTypeLocator in interface EvaluationContextpublic void setTypeConverter(TypeConverter typeConverter)
public TypeConverter getTypeConverter()
EvaluationContextgetTypeConverter in interface EvaluationContextpublic void setTypeComparator(TypeComparator typeComparator)
public TypeComparator getTypeComparator()
EvaluationContextgetTypeComparator in interface EvaluationContextpublic void setOperatorOverloader(OperatorOverloader operatorOverloader)
public OperatorOverloader getOperatorOverloader()
EvaluationContextgetOperatorOverloader in interface EvaluationContextpublic void setVariable(String name, Object value)
EvaluationContextsetVariable in interface EvaluationContextname - variable to setvalue - value to be placed in the variablepublic Object lookupVariable(String name)
EvaluationContextlookupVariable in interface EvaluationContextname - variable to lookupnull if not foundpublic void registerMethodFilter(Class<?> type, MethodFilter filter) throws IllegalStateException
MethodFilter which will be called during method resolution
for the specified type.
The MethodFilter may remove methods and/or sort the methods which
will then be used by SpEL as the candidates to look through for a match.
type - the type for which the filter should be calledfilter - a MethodFilter, or null to unregister a filter for the typeIllegalStateException - if the ReflectiveMethodResolver is not in use