View Javadoc
1   /*
2    * Copyright 2002-2013 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.springframework.expression;
18  
19  import java.util.List;
20  
21  /**
22   * Expressions are executed in an evaluation context. It is in this context that
23   * references are resolved when encountered during expression evaluation.
24   *
25   * <p>There is a default implementation of the EvaluationContext,
26   * {@link org.springframework.expression.spel.support.StandardEvaluationContext} that can
27   * be extended, rather than having to implement everything.
28   *
29   * @author Andy Clement
30   * @author Juergen Hoeller
31   * @since 3.0
32   */
33  public interface EvaluationContext {
34  
35  	/**
36  	 * Return the default root context object against which unqualified
37  	 * properties/methods/etc should be resolved. This can be overridden
38  	 * when evaluating an expression.
39  	 */
40  	TypedValue getRootObject();
41  
42  	/**
43  	 * Return a list of resolvers that will be asked in turn to locate a constructor.
44  	 */
45  	List<ConstructorResolver> getConstructorResolvers();
46  
47  	/**
48  	 * Return a list of resolvers that will be asked in turn to locate a method.
49  	 */
50  	List<MethodResolver> getMethodResolvers();
51  
52  	/**
53  	 * Return a list of accessors that will be asked in turn to read/write a property.
54  	 */
55  	List<PropertyAccessor> getPropertyAccessors();
56  
57  	/**
58  	 * Return a type locator that can be used to find types, either by short or
59  	 * fully qualified name.
60  	 */
61  	TypeLocator getTypeLocator();
62  
63  	/**
64  	 * Return a type converter that can convert (or coerce) a value from one type to another.
65  	 */
66  	TypeConverter getTypeConverter();
67  
68  	/**
69  	 * Return a type comparator for comparing pairs of objects for equality.
70  	 */
71  	TypeComparator getTypeComparator();
72  
73  	/**
74  	 * Return an operator overloader that may support mathematical operations
75  	 * between more than the standard set of types.
76  	 */
77  	OperatorOverloader getOperatorOverloader();
78  
79  	/**
80  	 * Return a bean resolver that can look up beans by name.
81  	 */
82  	BeanResolver getBeanResolver();
83  
84  	/**
85  	 * Set a named variable within this evaluation context to a specified value.
86  	 * @param name variable to set
87  	 * @param value value to be placed in the variable
88  	 */
89  	void setVariable(String name, Object value);
90  
91  	/**
92  	 * Look up a named variable within this evaluation context.
93  	 * @param name variable to lookup
94  	 * @return the value of the variable
95  	 */
96  	Object lookupVariable(String name);
97  
98  }