类 StandardEvaluationContext
- java.lang.Object
- org.springframework.expression.spel.support.StandardEvaluationContext
- 所有已实现的接口:
EvaluationContext
- 直接已知子类:
MethodBasedEvaluationContext
public class StandardEvaluationContext extends Object implements EvaluationContext
A powerful and highly configurableEvaluationContext
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.- 从以下版本开始:
- 3.0
- 作者:
- Andy Clement, Juergen Hoeller, Sam Brannen
- 另请参阅:
SimpleEvaluationContext
,ReflectivePropertyAccessor
,ReflectiveConstructorResolver
,ReflectiveMethodResolver
,StandardTypeLocator
,StandardTypeConverter
,StandardTypeComparator
,StandardOperatorOverloader
构造器概要
构造器 构造器 说明 StandardEvaluationContext()
Create aStandardEvaluationContext
with a null root object.StandardEvaluationContext(Object rootObject)
Create aStandardEvaluationContext
with the given root object.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 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 aMethodFilter
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)
构造器详细资料
StandardEvaluationContext
public StandardEvaluationContext()
Create aStandardEvaluationContext
with a null root object.
StandardEvaluationContext
public StandardEvaluationContext(@Nullable Object rootObject)
Create aStandardEvaluationContext
with the given root object.- 参数:
rootObject
- the root object to use- 另请参阅:
setRootObject(java.lang.Object, org.springframework.core.convert.TypeDescriptor)
方法详细资料
setRootObject
public void setRootObject(@Nullable Object rootObject, TypeDescriptor typeDescriptor)
setRootObject
public void setRootObject(@Nullable Object rootObject)
getRootObject
public TypedValue getRootObject()
从接口复制的说明:EvaluationContext
Return the default root context object against which unqualified properties/methods/etc should be resolved. This can be overridden when evaluating an expression.- 指定者:
getRootObject
在接口中EvaluationContext
setPropertyAccessors
public void setPropertyAccessors(List<PropertyAccessor> propertyAccessors)
getPropertyAccessors
public List<PropertyAccessor> getPropertyAccessors()
从接口复制的说明:EvaluationContext
Return a list of accessors that will be asked in turn to read/write a property.- 指定者:
getPropertyAccessors
在接口中EvaluationContext
addPropertyAccessor
public void addPropertyAccessor(PropertyAccessor accessor)
removePropertyAccessor
public boolean removePropertyAccessor(PropertyAccessor accessor)
setConstructorResolvers
public void setConstructorResolvers(List<ConstructorResolver> constructorResolvers)
getConstructorResolvers
public List<ConstructorResolver> getConstructorResolvers()
从接口复制的说明:EvaluationContext
Return a list of resolvers that will be asked in turn to locate a constructor.- 指定者:
getConstructorResolvers
在接口中EvaluationContext
addConstructorResolver
public void addConstructorResolver(ConstructorResolver resolver)
removeConstructorResolver
public boolean removeConstructorResolver(ConstructorResolver resolver)
setMethodResolvers
public void setMethodResolvers(List<MethodResolver> methodResolvers)
getMethodResolvers
public List<MethodResolver> getMethodResolvers()
从接口复制的说明:EvaluationContext
Return a list of resolvers that will be asked in turn to locate a method.- 指定者:
getMethodResolvers
在接口中EvaluationContext
addMethodResolver
public void addMethodResolver(MethodResolver resolver)
removeMethodResolver
public boolean removeMethodResolver(MethodResolver methodResolver)
setBeanResolver
public void setBeanResolver(BeanResolver beanResolver)
getBeanResolver
@Nullable public BeanResolver getBeanResolver()
从接口复制的说明:EvaluationContext
Return a bean resolver that can look up beans by name.- 指定者:
getBeanResolver
在接口中EvaluationContext
setTypeLocator
public void setTypeLocator(TypeLocator typeLocator)
getTypeLocator
public TypeLocator getTypeLocator()
从接口复制的说明:EvaluationContext
Return a type locator that can be used to find types, either by short or fully qualified name.- 指定者:
getTypeLocator
在接口中EvaluationContext
setTypeConverter
public void setTypeConverter(TypeConverter typeConverter)
getTypeConverter
public TypeConverter getTypeConverter()
从接口复制的说明:EvaluationContext
Return a type converter that can convert (or coerce) a value from one type to another.- 指定者:
getTypeConverter
在接口中EvaluationContext
setTypeComparator
public void setTypeComparator(TypeComparator typeComparator)
getTypeComparator
public TypeComparator getTypeComparator()
从接口复制的说明:EvaluationContext
Return a type comparator for comparing pairs of objects for equality.- 指定者:
getTypeComparator
在接口中EvaluationContext
setOperatorOverloader
public void setOperatorOverloader(OperatorOverloader operatorOverloader)
getOperatorOverloader
public OperatorOverloader getOperatorOverloader()
从接口复制的说明:EvaluationContext
Return an operator overloader that may support mathematical operations between more than the standard set of types.- 指定者:
getOperatorOverloader
在接口中EvaluationContext
setVariable
public void setVariable(@Nullable String name, @Nullable Object value)
从接口复制的说明:EvaluationContext
Set a named variable within this evaluation context to a specified value.- 指定者:
setVariable
在接口中EvaluationContext
- 参数:
name
- the name of the variable to setvalue
- the value to be placed in the variable
setVariables
public void setVariables(Map<String,Object> variables)
registerFunction
public void registerFunction(String name, Method method)
lookupVariable
@Nullable public Object lookupVariable(String name)
从接口复制的说明:EvaluationContext
Look up a named variable within this evaluation context.- 指定者:
lookupVariable
在接口中EvaluationContext
- 参数:
name
- variable to lookup- 返回:
- the value of the variable, or
null
if not found
registerMethodFilter
public void registerMethodFilter(Class<?> type, MethodFilter filter) throws IllegalStateException
Register aMethodFilter
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
- aMethodFilter
, ornull
to unregister a filter for the type- 抛出:
IllegalStateException
- if theReflectiveMethodResolver
is not in use