org.springframework.expression.spel.support

## Class StandardEvaluationContext

- java.lang.Object
- - org.springframework.expression.spel.support.StandardEvaluationContext

- All Implemented Interfaces:
    EvaluationContext

      public class StandardEvaluationContext
      extends 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, Sam Brannen

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `StandardEvaluationContext()`
    `StandardEvaluationContext(Object rootObject)`

  - ### Method Summary

    Methods
    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)`

    - ### 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(Object rootObject)

  - ### Method Detail

    - #### setRootObject

          public void setRootObject(Object rootObject,
                           TypeDescriptor typeDescriptor)

    - #### setRootObject

          public void setRootObject(Object rootObject)

    - #### getRootObject

          public TypedValue getRootObject()

      Description copied from interface: `EvaluationContext`
      Return the default root context object against which unqualified properties/methods/etc should be resolved. This can be overridden when evaluating an expression.
      Specified by:
        `getRootObject` in interface `EvaluationContext`

    - #### addConstructorResolver

          public void addConstructorResolver(ConstructorResolver resolver)

    - #### removeConstructorResolver

          public boolean removeConstructorResolver(ConstructorResolver resolver)

    - #### setConstructorResolvers

          public void setConstructorResolvers(List<ConstructorResolver> constructorResolvers)

    - #### getConstructorResolvers

          public List<ConstructorResolver> getConstructorResolvers()

      Description copied from interface: `EvaluationContext`
      Return a list of resolvers that will be asked in turn to locate a constructor.
      Specified by:
        `getConstructorResolvers` in interface `EvaluationContext`

    - #### addMethodResolver

          public void addMethodResolver(MethodResolver resolver)

    - #### removeMethodResolver

          public boolean removeMethodResolver(MethodResolver methodResolver)

    - #### setMethodResolvers

          public void setMethodResolvers(List<MethodResolver> methodResolvers)

    - #### getMethodResolvers

          public List<MethodResolver> getMethodResolvers()

      Description copied from interface: `EvaluationContext`
      Return a list of resolvers that will be asked in turn to locate a method.
      Specified by:
        `getMethodResolvers` in interface `EvaluationContext`

    - #### setBeanResolver

          public void setBeanResolver(BeanResolver beanResolver)

    - #### getBeanResolver

          public BeanResolver getBeanResolver()

      Description copied from interface: `EvaluationContext`
      Return a bean resolver that can look up beans by name.
      Specified by:
        `getBeanResolver` in interface `EvaluationContext`

    - #### addPropertyAccessor

          public void addPropertyAccessor(PropertyAccessor accessor)

    - #### removePropertyAccessor

          public boolean removePropertyAccessor(PropertyAccessor accessor)

    - #### setPropertyAccessors

          public void setPropertyAccessors(List<PropertyAccessor> propertyAccessors)

    - #### getPropertyAccessors

          public List<PropertyAccessor> getPropertyAccessors()

      Description copied from interface: `EvaluationContext`
      Return a list of accessors that will be asked in turn to read/write a property.
      Specified by:
        `getPropertyAccessors` in interface `EvaluationContext`

    - #### setTypeLocator

          public void setTypeLocator(TypeLocator typeLocator)

    - #### getTypeLocator

          public TypeLocator getTypeLocator()

      Description copied from interface: `EvaluationContext`
      Return a type locator that can be used to find types, either by short or fully qualified name.
      Specified by:
        `getTypeLocator` in interface `EvaluationContext`

    - #### setTypeConverter

          public void setTypeConverter(TypeConverter typeConverter)

    - #### getTypeConverter

          public TypeConverter getTypeConverter()

      Description copied from interface: `EvaluationContext`
      Return a type converter that can convert (or coerce) a value from one type to another.
      Specified by:
        `getTypeConverter` in interface `EvaluationContext`

    - #### setTypeComparator

          public void setTypeComparator(TypeComparator typeComparator)

    - #### getTypeComparator

          public TypeComparator getTypeComparator()

      Description copied from interface: `EvaluationContext`
      Return a type comparator for comparing pairs of objects for equality.
      Specified by:
        `getTypeComparator` in interface `EvaluationContext`

    - #### setOperatorOverloader

          public void setOperatorOverloader(OperatorOverloader operatorOverloader)

    - #### getOperatorOverloader

          public OperatorOverloader getOperatorOverloader()

      Description copied from interface: `EvaluationContext`
      Return an operator overloader that may support mathematical operations between more than the standard set of types.
      Specified by:
        `getOperatorOverloader` in interface `EvaluationContext`

    - #### setVariable

          public void setVariable(String name,
                         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(Map<String,Object> variables)

    - #### registerFunction

          public void registerFunction(String name,
                              Method method)

    - #### lookupVariable

          public Object lookupVariable(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(Class<?> type,
                                  MethodFilter filter)
                                    throws IllegalStateException

      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 unregister a filter for the type
      Throws:
        `IllegalStateException` - if the `ReflectiveMethodResolver` is not in use