01: package com.mockrunner.mock.web;
02:
03: import java.util.HashMap;
04: import java.util.Map;
05:
06: import javax.servlet.jsp.el.ELException;
07: import javax.servlet.jsp.el.VariableResolver;
08:
09: /**
10: * Mock implementation of <code>VariableResolver</code>.
11: * This implementation cannot be used for real EL
12: * expressions. Real EL expression support is only
13: * available for the <b>Unified Expression Language</b> API
14: * using the {@link JasperJspFactory}.
15: */
16: public class MockVariableResolver implements VariableResolver {
17: private Map variables = new HashMap();
18:
19: /**
20: * Adds a variable that resolves to the specified object.
21: * @param name the variable name
22: * @param value the variable value
23: */
24: public void addVariable(String name, Object value) {
25: variables.put(name, value);
26: }
27:
28: /**
29: * Clears all variables.
30: */
31: public void clearVariables() {
32: variables.clear();
33: }
34:
35: public Object resolveVariable(String name) throws ELException {
36: return variables.get(name);
37: }
38: }
|