Spring Framework

org.springframework.expression.spel.support
Class StandardEvaluationContext

java.lang.Object
  extended by org.springframework.expression.spel.support.StandardEvaluationContext
All Implemented Interfaces:
EvaluationContext

public class StandardEvaluationContext
extends java.lang.Object
implements EvaluationContext

Provides a default EvaluationContext implementation.

To resolve properties/methods/fields this context uses a reflection mechanism.

Since:
3.0
Author:
Andy Clement, Juergen Hoeller

Constructor Summary
StandardEvaluationContext()
           
StandardEvaluationContext(java.lang.Object rootObject)
           
 
Method Summary
 void addConstructorResolver(ConstructorResolver resolver)
           
 void addMethodResolver(MethodResolver resolver)
           
 void addPropertyAccessor(PropertyAccessor accessor)
           
 BeanResolver getBeanResolver()
           
 java.util.List<ConstructorResolver> getConstructorResolvers()
           
 java.util.List<MethodResolver> getMethodResolvers()
           
 OperatorOverloader getOperatorOverloader()
           
 java.util.List<PropertyAccessor> getPropertyAccessors()
           
 TypedValue getRootObject()
           
 TypeComparator getTypeComparator()
           
 TypeConverter getTypeConverter()
           
 TypeLocator getTypeLocator()
           
 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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StandardEvaluationContext

public StandardEvaluationContext()

StandardEvaluationContext

public StandardEvaluationContext(java.lang.Object rootObject)
Method Detail

setRootObject

public void setRootObject(java.lang.Object rootObject,
                          TypeDescriptor typeDescriptor)

setRootObject

public void setRootObject(java.lang.Object rootObject)

getRootObject

public TypedValue getRootObject()
Specified by:
getRootObject in interface EvaluationContext
Returns:
the default root context object against which unqualified properties/methods/etc should be resolved. This can be overridden when evaluating an expression.

addConstructorResolver

public void addConstructorResolver(ConstructorResolver resolver)

removeConstructorResolver

public boolean removeConstructorResolver(ConstructorResolver resolver)

getConstructorResolvers

public java.util.List<ConstructorResolver> getConstructorResolvers()
Specified by:
getConstructorResolvers in interface EvaluationContext
Returns:
a list of resolvers that will be asked in turn to locate a constructor

setConstructorResolvers

public void setConstructorResolvers(java.util.List<ConstructorResolver> constructorResolvers)

addMethodResolver

public void addMethodResolver(MethodResolver resolver)

removeMethodResolver

public boolean removeMethodResolver(MethodResolver methodResolver)

getMethodResolvers

public java.util.List<MethodResolver> getMethodResolvers()
Specified by:
getMethodResolvers in interface EvaluationContext
Returns:
a list of resolvers that will be asked in turn to locate a method

setBeanResolver

public void setBeanResolver(BeanResolver beanResolver)

getBeanResolver

public BeanResolver getBeanResolver()
Specified by:
getBeanResolver in interface EvaluationContext
Returns:
a bean resolver that can look up beans by name

setMethodResolvers

public void setMethodResolvers(java.util.List<MethodResolver> methodResolvers)

addPropertyAccessor

public void addPropertyAccessor(PropertyAccessor accessor)

removePropertyAccessor

public boolean removePropertyAccessor(PropertyAccessor accessor)

getPropertyAccessors

public java.util.List<PropertyAccessor> getPropertyAccessors()
Specified by:
getPropertyAccessors in interface EvaluationContext
Returns:
a list of accessors that will be asked in turn to read/write a property

setPropertyAccessors

public void setPropertyAccessors(java.util.List<PropertyAccessor> propertyAccessors)

setTypeLocator

public void setTypeLocator(TypeLocator typeLocator)

getTypeLocator

public TypeLocator getTypeLocator()
Specified by:
getTypeLocator in interface EvaluationContext
Returns:
a type locator that can be used to find types, either by short or fully qualified name.

setTypeConverter

public void setTypeConverter(TypeConverter typeConverter)

getTypeConverter

public TypeConverter getTypeConverter()
Specified by:
getTypeConverter in interface EvaluationContext
Returns:
a type converter that can convert (or coerce) a value from one type to another.

setTypeComparator

public void setTypeComparator(TypeComparator typeComparator)

getTypeComparator

public TypeComparator getTypeComparator()
Specified by:
getTypeComparator in interface EvaluationContext
Returns:
a type comparator for comparing pairs of objects for equality.

setOperatorOverloader

public void setOperatorOverloader(OperatorOverloader operatorOverloader)

getOperatorOverloader

public OperatorOverloader getOperatorOverloader()
Specified by:
getOperatorOverloader in interface EvaluationContext
Returns:
an operator overloader that may support mathematical operations between more than the standard set of types

setVariable

public void setVariable(java.lang.String name,
                        java.lang.Object value)
Description copied from interface: EvaluationContext
Set a named variable within this evaluation context to a specified value.

Specified by:
setVariable in interface EvaluationContext
Parameters:
name - variable to set
value - value to be placed in the variable

setVariables

public void setVariables(java.util.Map<java.lang.String,java.lang.Object> variables)

registerFunction

public void registerFunction(java.lang.String name,
                             java.lang.reflect.Method method)

lookupVariable

public java.lang.Object lookupVariable(java.lang.String name)
Description copied from interface: EvaluationContext
Look up a named variable within this evaluation context.

Specified by:
lookupVariable in interface EvaluationContext
Parameters:
name - variable to lookup
Returns:
the value of the variable

registerMethodFilter

public void registerMethodFilter(java.lang.Class<?> type,
                                 MethodFilter filter)
Register a 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.

Parameters:
type - the type for which the filter should be called
filter - a MethodFilter, or NULL to deregister a filter for the type

Spring Framework