This project has retired. For details please refer to its
Attic page.
ELContextImpl xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.tiles.el;
23
24 import java.lang.reflect.Method;
25 import java.util.HashMap;
26 import java.util.Map;
27
28 import javax.el.ELContext;
29 import javax.el.ELResolver;
30 import javax.el.FunctionMapper;
31 import javax.el.ValueExpression;
32 import javax.el.VariableMapper;
33
34
35
36
37
38
39
40 public class ELContextImpl extends ELContext {
41
42
43
44
45 private static final FunctionMapper NULL_FUNCTION_MAPPER = new FunctionMapper() {
46 @Override
47 public Method resolveFunction(String prefix, String localName) {
48 return null;
49 }
50 };
51
52
53
54
55 private static final class VariableMapperImpl extends VariableMapper {
56
57
58
59
60 private Map<String, ValueExpression> vars;
61
62
63 @Override
64 public ValueExpression resolveVariable(String variable) {
65 if (vars == null) {
66 return null;
67 }
68 return vars.get(variable);
69 }
70
71
72 @Override
73 public ValueExpression setVariable(String variable,
74 ValueExpression expression) {
75 if (vars == null) {
76 vars = new HashMap<String, ValueExpression>();
77 }
78 return vars.put(variable, expression);
79 }
80
81 }
82
83
84
85
86 private final ELResolver resolver;
87
88
89
90
91 private FunctionMapper functionMapper = NULL_FUNCTION_MAPPER;
92
93
94
95
96 private VariableMapper variableMapper;
97
98
99
100
101
102
103 public ELContextImpl(ELResolver resolver) {
104 this.resolver = resolver;
105 }
106
107
108 @Override
109 public ELResolver getELResolver() {
110 return this.resolver;
111 }
112
113
114 @Override
115 public FunctionMapper getFunctionMapper() {
116 return this.functionMapper;
117 }
118
119
120 @Override
121 public VariableMapper getVariableMapper() {
122 if (this.variableMapper == null) {
123 this.variableMapper = new VariableMapperImpl();
124 }
125 return this.variableMapper;
126 }
127
128
129
130
131
132
133
134 public void setFunctionMapper(FunctionMapper functionMapper) {
135 this.functionMapper = functionMapper;
136 }
137
138
139
140
141
142
143
144 public void setVariableMapper(VariableMapper variableMapper) {
145 this.variableMapper = variableMapper;
146 }
147 }