1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.strutsel.taglib.logic;
22
23 import org.apache.struts.taglib.logic.MatchTag;
24 import org.apache.strutsel.taglib.utils.EvalHelper;
25
26 import javax.servlet.jsp.JspException;
27
28
29
30
31
32
33
34
35
36
37
38 public class ELMatchTag extends MatchTag {
39
40
41
42
43 private String cookieExpr;
44
45
46
47
48
49 private String headerExpr;
50
51
52
53
54
55 private String locationExpr;
56
57
58
59
60
61 private String nameExpr;
62
63
64
65
66
67 private String parameterExpr;
68
69
70
71
72
73 private String propertyExpr;
74
75
76
77
78
79 private String scopeExpr;
80
81
82
83
84
85 private String valueExpr;
86
87
88
89
90 private String expr;
91
92
93
94
95 private String exprValue;
96
97
98
99
100
101 public String getCookieExpr() {
102 return (cookieExpr);
103 }
104
105
106
107
108
109 public String getHeaderExpr() {
110 return (headerExpr);
111 }
112
113
114
115
116
117 public String getLocationExpr() {
118 return (locationExpr);
119 }
120
121
122
123
124
125 public String getNameExpr() {
126 return (nameExpr);
127 }
128
129
130
131
132
133 public String getParameterExpr() {
134 return (parameterExpr);
135 }
136
137
138
139
140
141 public String getPropertyExpr() {
142 return (propertyExpr);
143 }
144
145
146
147
148
149 public String getScopeExpr() {
150 return (scopeExpr);
151 }
152
153
154
155
156
157 public String getValueExpr() {
158 return (valueExpr);
159 }
160
161
162
163
164
165 public void setCookieExpr(String cookieExpr) {
166 this.cookieExpr = cookieExpr;
167 }
168
169
170
171
172
173 public void setHeaderExpr(String headerExpr) {
174 this.headerExpr = headerExpr;
175 }
176
177
178
179
180
181 public void setLocationExpr(String locationExpr) {
182 this.locationExpr = locationExpr;
183 }
184
185
186
187
188
189 public void setNameExpr(String nameExpr) {
190 this.nameExpr = nameExpr;
191 }
192
193
194
195
196
197 public void setParameterExpr(String parameterExpr) {
198 this.parameterExpr = parameterExpr;
199 }
200
201
202
203
204
205 public void setPropertyExpr(String propertyExpr) {
206 this.propertyExpr = propertyExpr;
207 }
208
209
210
211
212
213 public void setScopeExpr(String scopeExpr) {
214 this.scopeExpr = scopeExpr;
215 }
216
217
218
219
220
221 public void setValueExpr(String valueExpr) {
222 this.valueExpr = valueExpr;
223 }
224
225
226
227
228
229 public String getExpr() {
230 return (expr);
231 }
232
233
234
235
236
237 public void setExpr(String expr) {
238 this.expr = expr;
239 }
240
241
242
243
244 public String getExprValue() {
245 return (exprValue);
246 }
247
248
249
250
251 public void setExprValue(String exprValue) {
252 this.exprValue = exprValue;
253 }
254
255
256
257
258 public void release() {
259 super.release();
260 setCookieExpr(null);
261 setHeaderExpr(null);
262 setLocationExpr(null);
263 setNameExpr(null);
264 setParameterExpr(null);
265 setPropertyExpr(null);
266 setScopeExpr(null);
267 setValueExpr(null);
268 setExpr(null);
269 setExprValue(null);
270 }
271
272
273
274
275
276
277 public int doStartTag() throws JspException {
278 evaluateExpressions();
279
280 return (super.doStartTag());
281 }
282
283
284
285
286
287
288
289
290
291 protected boolean condition(boolean desired)
292 throws JspException {
293 boolean result = false;
294
295 if (getExprValue() != null) {
296 result =
297 ELMatchSupport.condition(desired, getExprValue(), value,
298 location, messages, pageContext);
299 } else {
300 result = super.condition(desired);
301 }
302
303 return (result);
304 }
305
306
307
308
309
310
311
312 private void evaluateExpressions()
313 throws JspException {
314 String string = null;
315
316 if ((string =
317 EvalHelper.evalString("cookie", getCookieExpr(), this,
318 pageContext)) != null) {
319 setCookie(string);
320 }
321
322 if ((string =
323 EvalHelper.evalString("expr", getExpr(), this, pageContext)) != null) {
324 setExprValue(string);
325 }
326
327 if ((string =
328 EvalHelper.evalString("header", getHeaderExpr(), this,
329 pageContext)) != null) {
330 setHeader(string);
331 }
332
333 if ((string =
334 EvalHelper.evalString("location", getLocationExpr(), this,
335 pageContext)) != null) {
336 setLocation(string);
337 }
338
339 if ((string =
340 EvalHelper.evalString("name", getNameExpr(), this, pageContext)) != null) {
341 setName(string);
342 }
343
344 if ((string =
345 EvalHelper.evalString("parameter", getParameterExpr(), this,
346 pageContext)) != null) {
347 setParameter(string);
348 }
349
350 if ((string =
351 EvalHelper.evalString("property", getPropertyExpr(), this,
352 pageContext)) != null) {
353 setProperty(string);
354 }
355
356 if ((string =
357 EvalHelper.evalString("scope", getScopeExpr(), this, pageContext)) != null) {
358 setScope(string);
359 }
360
361 if ((string =
362 EvalHelper.evalString("value", getValueExpr(), this, pageContext)) != null) {
363 setValue(string);
364 }
365 }
366 }