2009/05/20 - Apache Shale has been retired.
For more information, please explore the Attic.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.shale.test.el;
19
20 import java.util.HashMap;
21 import java.util.Map;
22 import javax.el.ValueExpression;
23 import javax.el.VariableMapper;
24
25 /***
26 * <p>Mock implementation of <code>VariableMapper</code>.</p>
27 *
28 * @since 1.0.4
29 */
30
31 public class MockVariableMapper extends VariableMapper {
32
33
34
35
36
37 /*** Creates a new instance of MockVariableMapper */
38 public MockVariableMapper() {
39 }
40
41
42
43
44
45 /***
46 * <p>Map of <code>ValueExpression</code>s, keyed by variable name.</p>
47 */
48 private Map expressions = new HashMap();
49
50
51
52
53
54
55
56
57 /*** {@inheritDoc} */
58 public ValueExpression resolveVariable(String variable) {
59
60 return (ValueExpression) expressions.get(variable);
61
62 }
63
64
65 /*** {@inheritDoc} */
66 public ValueExpression setVariable(String variable, ValueExpression expression) {
67
68 ValueExpression original = (ValueExpression) expressions.get(variable);
69 if (expression == null) {
70 expressions.remove(variable);
71 } else {
72 expressions.put(variable, expression);
73 }
74 return original;
75
76 }
77
78
79 }