public class StandardEvaluationContext extends java.lang.Object implements EvaluationContext
To resolve properties/methods/fields this context uses a reflection mechanism.
Constructor and Description |
---|
StandardEvaluationContext() |
StandardEvaluationContext(java.lang.Object rootObject) |
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.
|
java.util.List<ConstructorResolver> |
getConstructorResolvers()
Return a list of resolvers that will be asked in turn to locate a constructor.
|
java.util.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.
|
java.util.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.
|
java.lang.Object |
lookupVariable(java.lang.String name)
Look up a named variable within this evaluation context.
|
void |
registerFunction(java.lang.String name,
java.lang.reflect.Method method) |
void |
registerMethodFilter(java.lang.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(java.util.List<ConstructorResolver> constructorResolvers) |
void |
setMethodResolvers(java.util.List<MethodResolver> methodResolvers) |
void |
setOperatorOverloader(OperatorOverloader operatorOverloader) |
void |
setPropertyAccessors(java.util.List<PropertyAccessor> propertyAccessors) |
void |
setRootObject(java.lang.Object rootObject) |
void |
setRootObject(java.lang.Object rootObject,
TypeDescriptor typeDescriptor) |
void |
setTypeComparator(TypeComparator typeComparator) |
void |
setTypeConverter(TypeConverter typeConverter) |
void |
setTypeLocator(TypeLocator typeLocator) |
void |
setVariable(java.lang.String name,
java.lang.Object value)
Set a named variable within this evaluation context to a specified value.
|
void |
setVariables(java.util.Map<java.lang.String,java.lang.Object> variables) |
public StandardEvaluationContext()
public StandardEvaluationContext(java.lang.Object rootObject)
public void setRootObject(java.lang.Object rootObject, TypeDescriptor typeDescriptor)
public void setRootObject(@Nullable java.lang.Object rootObject)
public TypedValue getRootObject()
EvaluationContext
getRootObject
in interface EvaluationContext
public void setPropertyAccessors(java.util.List<PropertyAccessor> propertyAccessors)
public java.util.List<PropertyAccessor> getPropertyAccessors()
EvaluationContext
getPropertyAccessors
in interface EvaluationContext
public void addPropertyAccessor(PropertyAccessor accessor)
public boolean removePropertyAccessor(PropertyAccessor accessor)
public void setConstructorResolvers(java.util.List<ConstructorResolver> constructorResolvers)
public java.util.List<ConstructorResolver> getConstructorResolvers()
EvaluationContext
getConstructorResolvers
in interface EvaluationContext
public void addConstructorResolver(ConstructorResolver resolver)
public boolean removeConstructorResolver(ConstructorResolver resolver)
public void setMethodResolvers(java.util.List<MethodResolver> methodResolvers)
public java.util.List<MethodResolver> getMethodResolvers()
EvaluationContext
getMethodResolvers
in interface EvaluationContext
public void addMethodResolver(MethodResolver resolver)
public boolean removeMethodResolver(MethodResolver methodResolver)
public void setBeanResolver(BeanResolver beanResolver)
@Nullable public BeanResolver getBeanResolver()
EvaluationContext
getBeanResolver
in interface EvaluationContext
public void setTypeLocator(TypeLocator typeLocator)
public TypeLocator getTypeLocator()
EvaluationContext
getTypeLocator
in interface EvaluationContext
public void setTypeConverter(TypeConverter typeConverter)
public TypeConverter getTypeConverter()
EvaluationContext
getTypeConverter
in interface EvaluationContext
public void setTypeComparator(TypeComparator typeComparator)
public TypeComparator getTypeComparator()
EvaluationContext
getTypeComparator
in interface EvaluationContext
public void setOperatorOverloader(OperatorOverloader operatorOverloader)
public OperatorOverloader getOperatorOverloader()
EvaluationContext
getOperatorOverloader
in interface EvaluationContext
public void setVariable(java.lang.String name, @Nullable java.lang.Object value)
EvaluationContext
setVariable
in interface EvaluationContext
name
- variable to setvalue
- value to be placed in the variablepublic void setVariables(java.util.Map<java.lang.String,java.lang.Object> variables)
public void registerFunction(java.lang.String name, java.lang.reflect.Method method)
@Nullable public java.lang.Object lookupVariable(java.lang.String name)
EvaluationContext
lookupVariable
in interface EvaluationContext
name
- variable to lookupnull
if not foundpublic void registerMethodFilter(java.lang.Class<?> type, MethodFilter filter) throws java.lang.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 typejava.lang.IllegalStateException
- if the ReflectiveMethodResolver
is not in use