KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > finalist > jag > taglib > EmptyTag


1 /* Copyright (C) 2003 Finalist IT Group
2  *
3  * This file is part of JAG - the Java J2EE Application Generator
4  *
5  * JAG is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  * JAG is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  * You should have received a copy of the GNU General Public License
14  * along with JAG; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  */

17
18 package com.finalist.jag.taglib;
19
20
21
22 import com.finalist.jag.*;
23 import com.finalist.jag.taglib.util.RequestUtil;
24
25 import java.util.*;
26
27
28 /**
29  * Class EmptyTag
30  *
31  *
32  * @author Wendel D. de Witte
33  * @version %I%, %G%
34  */

35 public class EmptyTag extends TagBodySupport {
36
37     /** Field name */
38     private String JavaDoc name = null;
39
40     /** Field property */
41     private String JavaDoc property = null;
42
43     /** Field equal */
44     protected boolean body = false;
45
46     /** Field sensitive */
47     protected int counter = 0;
48
49     /////////////////////////////////////
50

51     /**
52      * Method getName
53      *
54      *
55      * @return
56      *
57      */

58     public String JavaDoc getName() {
59         return (this.name);
60     }
61
62     /**
63      * Method setName
64      *
65      *
66      * @param name
67      *
68      */

69     public void setName(String JavaDoc name) {
70         this.name = name;
71     }
72
73     /**
74      * Method getValue
75      *
76      *
77      * @return
78      *
79      */

80     public String JavaDoc getProperty() {
81         return (this.property);
82     }
83
84     /**
85      * Method setValue
86      *
87      *
88      * @param property
89      *
90      */

91     public void setProperty(String JavaDoc property) {
92         this.property = property;
93     }
94
95     /**
96      * Method doStartTag
97      *
98      *
99      * @return
100      *
101      * @throws JagException
102      *
103      */

104     public int doStartTag() throws JagException {
105
106         String JavaDoc value = RequestUtil.lookupString(getPageContext(), name,
107                                                 property);
108
109         if ((value != null) && (value.length() < 1)) {
110             body = true;
111         }
112
113         if (value == null) {
114             Collection col = RequestUtil.lookupCollection(getPageContext(),
115                                  name, property);
116
117             body = (col != null) && (col.size() < 1);
118         }
119
120         return (EVAL_PAGE);
121     }
122
123     /**
124      * Method doAfterBodyTag
125      *
126      *
127      * @return
128      *
129      * @throws JagException
130      *
131      */

132     public int doAfterBodyTag() throws JagException {
133
134         return (body && (counter++ < 1))
135                ? (EVAL_BODY_TAG)
136                : (SKIP_BODY);
137     }
138 }
Popular Tags