KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > strutsel > taglib > logic > ELNotMatchTag


1 /*
2  * $Id: ELNotMatchTag.java 54933 2004-10-16 17:04:52Z germuska $
3  *
4  * Copyright 1999-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 package org.apache.strutsel.taglib.logic;
20
21 import org.apache.struts.taglib.logic.NotMatchTag;
22 import javax.servlet.jsp.JspException JavaDoc;
23 import org.apache.strutsel.taglib.utils.EvalHelper;
24
25 /**
26  * Evalute the nested body content of this tag if the specified value
27  * is a substring of the specified variable.
28  *<p>
29  * This class is a subclass of the class
30  * <code>org.apache.struts.taglib.logic.NotMatchTag</code> which provides most
31  * of the described functionality. This subclass allows all attribute values
32  * to be specified as expressions utilizing the JavaServer Pages Standard
33  * Library expression language.
34  *
35  * @version $Rev: 54933 $
36  */

37 public class ELNotMatchTag extends NotMatchTag {
38
39     /**
40      * Instance variable mapped to "cookie" tag attribute.
41      * (Mapping set in associated BeanInfo class.)
42      */

43     private String JavaDoc cookieExpr;
44     /**
45      * Instance variable mapped to "header" tag attribute.
46      * (Mapping set in associated BeanInfo class.)
47      */

48     private String JavaDoc headerExpr;
49     /**
50      * Instance variable mapped to "location" tag attribute.
51      * (Mapping set in associated BeanInfo class.)
52      */

53     private String JavaDoc locationExpr;
54     /**
55      * Instance variable mapped to "name" tag attribute.
56      * (Mapping set in associated BeanInfo class.)
57      */

58     private String JavaDoc nameExpr;
59     /**
60      * Instance variable mapped to "parameter" tag attribute.
61      * (Mapping set in associated BeanInfo class.)
62      */

63     private String JavaDoc parameterExpr;
64     /**
65      * Instance variable mapped to "property" tag attribute.
66      * (Mapping set in associated BeanInfo class.)
67      */

68     private String JavaDoc propertyExpr;
69     /**
70      * Instance variable mapped to "scope" tag attribute.
71      * (Mapping set in associated BeanInfo class.)
72      */

73     private String JavaDoc scopeExpr;
74     /**
75      * Instance variable mapped to "value" tag attribute.
76      * (Mapping set in associated BeanInfo class.)
77      */

78     private String JavaDoc valueExpr;
79
80     /**
81      * Getter method for "cookie" tag attribute.
82      * (Mapping set in associated BeanInfo class.)
83      */

84     public String JavaDoc getCookieExpr() { return (cookieExpr); }
85     /**
86      * Getter method for "header" tag attribute.
87      * (Mapping set in associated BeanInfo class.)
88      */

89     public String JavaDoc getHeaderExpr() { return (headerExpr); }
90     /**
91      * Getter method for "location" tag attribute.
92      * (Mapping set in associated BeanInfo class.)
93      */

94     public String JavaDoc getLocationExpr() { return (locationExpr); }
95     /**
96      * Getter method for "name" tag attribute.
97      * (Mapping set in associated BeanInfo class.)
98      */

99     public String JavaDoc getNameExpr() { return (nameExpr); }
100     /**
101      * Getter method for "parameter" tag attribute.
102      * (Mapping set in associated BeanInfo class.)
103      */

104     public String JavaDoc getParameterExpr() { return (parameterExpr); }
105     /**
106      * Getter method for "property" tag attribute.
107      * (Mapping set in associated BeanInfo class.)
108      */

109     public String JavaDoc getPropertyExpr() { return (propertyExpr); }
110     /**
111      * Getter method for "scope" tag attribute.
112      * (Mapping set in associated BeanInfo class.)
113      */

114     public String JavaDoc getScopeExpr() { return (scopeExpr); }
115     /**
116      * Getter method for "value" tag attribute.
117      * (Mapping set in associated BeanInfo class.)
118      */

119     public String JavaDoc getValueExpr() { return (valueExpr); }
120
121     /**
122      * Setter method for "cookie" tag attribute.
123      * (Mapping set in associated BeanInfo class.)
124      */

125     public void setCookieExpr(String JavaDoc cookieExpr) { this.cookieExpr = cookieExpr; }
126     /**
127      * Setter method for "header" tag attribute.
128      * (Mapping set in associated BeanInfo class.)
129      */

130     public void setHeaderExpr(String JavaDoc headerExpr) { this.headerExpr = headerExpr; }
131     /**
132      * Setter method for "location" tag attribute.
133      * (Mapping set in associated BeanInfo class.)
134      */

135     public void setLocationExpr(String JavaDoc locationExpr) { this.locationExpr = locationExpr; }
136     /**
137      * Setter method for "name" tag attribute.
138      * (Mapping set in associated BeanInfo class.)
139      */

140     public void setNameExpr(String JavaDoc nameExpr) { this.nameExpr = nameExpr; }
141     /**
142      * Setter method for "parameter" tag attribute.
143      * (Mapping set in associated BeanInfo class.)
144      */

145     public void setParameterExpr(String JavaDoc parameterExpr) { this.parameterExpr = parameterExpr; }
146     /**
147      * Setter method for "property" tag attribute.
148      * (Mapping set in associated BeanInfo class.)
149      */

150     public void setPropertyExpr(String JavaDoc propertyExpr) { this.propertyExpr = propertyExpr; }
151     /**
152      * Setter method for "scope" tag attribute.
153      * (Mapping set in associated BeanInfo class.)
154      */

155     public void setScopeExpr(String JavaDoc scopeExpr) { this.scopeExpr = scopeExpr; }
156     /**
157      * Setter method for "value" tag attribute.
158      * (Mapping set in associated BeanInfo class.)
159      */

160     public void setValueExpr(String JavaDoc valueExpr) { this.valueExpr = valueExpr; }
161
162     /**
163      * String value of expression to be evaluated.
164      */

165     private String JavaDoc expr;
166
167     /**
168      * Returns the string value of the expression. This value will be
169      * evaluated by the JSTL EL engine.
170      */

171     public String JavaDoc getExpr() {
172         return (expr);
173     }
174     
175     /**
176      * Sets the string value of the expression. This expression will be
177      * evaluated by the JSTL EL engine.
178      */

179     public void setExpr(String JavaDoc expr) {
180         this.expr = expr;
181     }
182
183     /**
184      * Evaluated value of expression.
185      */

186     private String JavaDoc exprValue;
187
188     /**
189      * Returns the evaluated expression.
190      */

191     public String JavaDoc getExprValue() {
192         return (exprValue);
193     }
194
195     /**
196      * Sets the evaluated expression.
197      */

198     public void setExprValue(String JavaDoc exprValue) {
199         this.exprValue = exprValue;
200     }
201
202     /**
203      * Releases state of custom tag so this instance can be reused.
204      */

205     public void release()
206     {
207         super.release();
208         setCookieExpr(null);
209         setHeaderExpr(null);
210         setLocationExpr(null);
211         setNameExpr(null);
212         setParameterExpr(null);
213         setPropertyExpr(null);
214         setScopeExpr(null);
215         setValueExpr(null);
216         setExpr(null);
217         setExprValue(null);
218     }
219     
220     /**
221      * Process the start tag.
222      *
223      * @exception JspException if a JSP exception has occurred
224      */

225     public int doStartTag() throws JspException JavaDoc {
226         evaluateExpressions();
227         return (super.doStartTag());
228     }
229
230     /**
231      * Evaluates the condition that is being tested by this particular tag,
232      * and returns <code>true</code> if the nested body content of this tag
233      * should be evaluated, or <code>false</code> if it should be skipped.
234      *
235      * @param desired Desired value for a true result
236      * @exception JspException if a JSP exception occurs
237      */

238     protected boolean condition(boolean desired) throws JspException JavaDoc {
239         boolean result = false;
240         if (getExprValue() != null) {
241             result =
242                 ELMatchSupport.condition(desired, getExprValue(), value,
243                                          location, messages, pageContext);
244         }
245         else {
246             result = super.condition(desired);
247         }
248         return (result);
249     }
250
251     /**
252      * Processes all attribute values which use the JSTL expression evaluation
253      * engine to determine their values.
254      *
255      * @exception JspException if a JSP exception has occurred
256      */

257     private void evaluateExpressions() throws JspException JavaDoc {
258         String JavaDoc string = null;
259
260         if ((string = EvalHelper.evalString("cookie", getCookieExpr(),
261                                             this, pageContext)) != null)
262             setCookie(string);
263
264         if ((string = EvalHelper.evalString("expr", getExpr(),
265                                             this, pageContext)) != null)
266             setExprValue(string);
267
268         if ((string = EvalHelper.evalString("header", getHeaderExpr(),
269                                             this, pageContext)) != null)
270             setHeader(string);
271
272         if ((string = EvalHelper.evalString("location", getLocationExpr(),
273                                             this, pageContext)) != null)
274             setLocation(string);
275
276         if ((string = EvalHelper.evalString("name", getNameExpr(),
277                                             this, pageContext)) != null)
278             setName(string);
279
280         if ((string = EvalHelper.evalString("parameter", getParameterExpr(),
281                                             this, pageContext)) != null)
282             setParameter(string);
283
284         if ((string = EvalHelper.evalString("property", getPropertyExpr(),
285                                             this, pageContext)) != null)
286             setProperty(string);
287
288         if ((string = EvalHelper.evalString("scope", getScopeExpr(),
289                                             this, pageContext)) != null)
290             setScope(string);
291
292         if ((string = EvalHelper.evalString("value", getValueExpr(),
293                                             this, pageContext)) != null)
294             setValue(string);
295     }
296 }
297
Popular Tags