KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.util.Collection JavaDoc;
21
22 import com.finalist.jag.JagException;
23 import com.finalist.jag.template.*;
24
25 /**
26  * Class TagLibrary
27  *
28  *
29  * @author Wendel D. de Witte
30  * @version %I%, %G%
31  */

32 public class TagLibrary {
33    /** Field libVersion */
34    private String JavaDoc libVersion = null;
35
36    /** Field jagVersion */
37    private String JavaDoc jagVersion = null;
38
39    /** Field shortName */
40    private String JavaDoc shortName = null;
41
42    /** Field info */
43    private String JavaDoc info = null;
44
45    /** Field tagDefs */
46    private Collection JavaDoc tagDefs = null;
47
48
49    /**
50     * Method setLibVersion
51     *
52     *
53     * @param libVersion
54     *
55     */

56    public void setLibVersion(String JavaDoc libVersion) {
57       this.libVersion = libVersion;
58    }
59
60
61    /**
62     * Method setJagVersion
63     *
64     * @param jagVersion
65     *
66     */

67    public void setJagVersion(String JavaDoc jagVersion) {
68       this.jagVersion = jagVersion;
69    }
70
71
72    /**
73     * Method setShortName
74     *
75     *
76     * @param shortName
77     *
78     */

79    public void setShortName(String JavaDoc shortName) {
80       this.shortName = shortName;
81    }
82
83
84    /**
85     * Method setInfo
86     *
87     *
88     * @param info
89     *
90     */

91    public void setInfo(String JavaDoc info) {
92       this.info = info;
93    }
94
95
96    /**
97     * Method setTagDefs
98     *
99     *
100     * @param tagDefs
101     *
102     */

103    public void setTagDefs(Collection JavaDoc tagDefs) {
104       this.tagDefs = tagDefs;
105    }
106
107
108    /**
109     * Method getLibVersion
110     *
111     *
112     * @return
113     *
114     */

115    public String JavaDoc getLibVersion() {
116       return (this.libVersion);
117    }
118
119
120    /**
121     * Method getJagVersion
122     *
123     *
124     * @return
125     *
126     */

127    public String JavaDoc getJagVersion() {
128       return (this.jagVersion);
129    }
130
131
132    /**
133     * Method getShortName
134     *
135     *
136     * @return
137     *
138     */

139    public String JavaDoc getShortName() {
140       return (this.shortName);
141    }
142
143
144    /**
145     * Method getInfo
146     *
147     *
148     * @return
149     *
150     */

151    public String JavaDoc getInfo() {
152       return (this.info);
153    }
154
155
156    /**
157     * Method getTagDefs
158     *
159     *
160     * @return
161     *
162     */

163    public Collection JavaDoc getTagDefs() {
164       if (tagDefs == null)
165          tagDefs = new java.util.ArrayList JavaDoc();
166
167       return (this.tagDefs);
168    }
169
170
171    /**
172     * Method getTagDef
173     *
174     *
175     * @param tagRef
176     *
177     * @return
178     *
179     * @throws JagException
180     *
181     */

182    public TagDef getTagDef(TemplateTag tagRef) throws JagException {
183       TagDef tagdef = findTagDef(tagRef);
184
185       if (tagdef == null) {
186          throw new JagException("" + tagRef.getTagName()
187             + " doesn't exist in the tag library "
188             + shortName);
189       }
190       return tagdef;
191    }
192
193
194    /**
195     * Method findTagDef
196     *
197     *
198     * @param tagRef
199     *
200     * @return
201     *
202     */

203    public TagDef findTagDef(TemplateTag tagRef) {
204       java.util.Iterator JavaDoc iterator = tagDefs.iterator();
205
206       while (iterator.hasNext()) {
207          TagDef tagDef = (TagDef) iterator.next();
208
209          if (!(getShortName().equals(tagRef.getTagLib())))
210             continue; // should be impossible
211

212          if (!(tagDef.getName().equals(tagRef.getTagName())))
213             continue;
214
215          return tagDef;
216       }
217
218       return null;
219    }
220
221
222    /**
223     * Method toString
224     *
225     *
226     * @return
227     *
228     */

229    public String JavaDoc toString() {
230       StringBuffer JavaDoc toString = new StringBuffer JavaDoc();
231       toString.append("\nlibVersion : ");
232       toString.append(libVersion);
233       toString.append("\njagVersion : ");
234       toString.append(jagVersion);
235       toString.append("\nshortName : ");
236       toString.append(shortName);
237       toString.append("\ninfo : ");
238       toString.append(info);
239       toString.append("\ntagDefs : ");
240       toString.append(tagDefs);
241
242       Collection JavaDoc col = getTagDefs();
243       java.util.Iterator JavaDoc iterator = col.iterator();
244
245       while (iterator.hasNext()) {
246          TagDef tagDef = (TagDef) iterator.next();
247          toString.append("[TagDef]" + tagDef.toString());
248       }
249       return new String JavaDoc(toString);
250    }
251 }
252
253
Popular Tags