KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > finalist > jag > template > TemplateTag


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.template;
19
20
21 import com.finalist.jag.template.parser.*;
22 import com.finalist.jag.taglib.*;
23 import com.finalist.jag.*;
24
25 /**
26  * Class TemplateTag
27  *
28  *
29  * @author Wendel D. de Witte
30  * @version %I%, %G%
31  */

32 public class TemplateTag {
33    /** TemplateTag definition retrieved from the tag librariy file */
34    private TagDef tagDef = null;
35
36    /** The pageContext which contains this TemplateTag */
37    private PageContext pageContext = null;
38
39    /** Field tagLib */
40    private String JavaDoc tagLib;
41
42    /** Field tagName */
43    private String JavaDoc tagName;
44
45    /** Field paramArray */
46    private JagParameter[] paramArray = new JagParameter[0];
47
48    /** Field textBuffer */
49    private TemplateTextBlock textBuffer = null;
50
51    /** Field closing textBuffer */
52    private TemplateTextBlock closeTagBuffer = null;
53
54    /** Field processed */
55    private boolean processed = false;
56
57
58    /**
59     * Constructor TemplateTag
60     *
61     *
62     * @param tagLib
63     * @param tagName
64     * @param textBuffer
65     *
66     */

67    public TemplateTag(String JavaDoc tagLib, String JavaDoc tagName, TemplateTextBlock textBuffer) {
68
69       this.tagLib = tagLib;
70       this.tagName = tagName;
71       this.textBuffer = textBuffer;
72    }
73
74
75    /**
76     * Constructor TemplateTag
77     *
78     * Creates a copy of the references, except for the field 'pageContext'.
79     * The field 'processed' is set to false.
80     *
81     * @param n
82     *
83     */

84    public TemplateTag(TemplateTag n) {
85       clone(n);
86
87       this.textBuffer = new TemplateTextBlock(n.textBuffer);
88       this.closeTagBuffer = new TemplateTextBlock(n.closeTagBuffer);
89       this.tagDef = (n.tagDef != null) ? new TagDef(n.tagDef) : null;
90       this.paramArray = new JagParameter[n.paramArray.length];
91
92       for (int i = 0; i < paramArray.length; i++) {
93          this.paramArray[i] = new JagParameter(n.paramArray[i]);
94       }
95    }
96
97
98    /**
99     * Method getTextBuffer
100     *
101     *
102     * @return
103     *
104     */

105    public TemplateTextBlock getTextBuffer() {
106       return textBuffer;
107    }
108
109
110    /**
111     * Constructor TemplateTag
112     *
113     *
114     * @param tagLib
115     * @param tagName
116     * @param paramArray
117     * @param textBuffer
118     *
119     */

120    public TemplateTag(String JavaDoc tagLib, String JavaDoc tagName, JagParameter[] paramArray,
121       TemplateTextBlock textBuffer) {
122
123       this(tagLib, tagName, textBuffer);
124
125       this.paramArray = paramArray;
126    }
127
128
129    /**
130     * Method clone
131     *
132     * Clones all the references.
133     *
134     * @param other
135     *
136     */

137    public void clone(TemplateTag other) {
138
139       this.tagDef = other.tagDef;
140       this.tagLib = other.tagLib;
141       this.tagName = other.tagName;
142       this.paramArray = other.paramArray;
143       this.textBuffer = other.textBuffer;
144       this.closeTagBuffer = other.closeTagBuffer;
145       this.pageContext = other.pageContext;
146    }
147
148
149    /**
150     * Method setTagDefinition
151     *
152     *
153     * @param tagDef
154     *
155     */

156    public void setTagDefinition(TagDef tagDef) {
157       this.tagDef = tagDef;
158    }
159
160
161    /**
162     * Method setPageContext
163     *
164     *
165     * @param pageContext
166     *
167     */

168    public void setPageContext(PageContext pageContext) {
169       this.pageContext = pageContext;
170    }
171
172
173    /**
174     * Method setTagLib
175     *
176     *
177     * @param tagLib
178     *
179     */

180    public void setTagLib(String JavaDoc tagLib) {
181       this.tagLib = tagLib;
182    }
183
184
185    /**
186     * Method setTagName
187     *
188     *
189     * @param tagName
190     *
191     */

192    public void setTagName(String JavaDoc tagName) {
193       this.tagName = tagName;
194    }
195
196
197    /**
198     * Method setParamArray
199     *
200     *
201     * @param paramArray
202     *
203     */

204    public void setParamArray(JagParameter[] paramArray) {
205       this.paramArray = paramArray;
206    }
207
208
209    /**
210     * Method setTextBuffer
211     *
212     *
213     * @param textBuffer
214     *
215     */

216    public void setTextBuffer(TemplateTextBlock textBuffer) {
217       this.textBuffer = textBuffer;
218    }
219
220
221    /**
222     * Method getTagDefinition
223     *
224     *
225     * @return
226     *
227     */

228    public TagDef getTagDefinition() {
229       return (this.tagDef);
230    }
231
232
233    /**
234     * Method getTagLib
235     *
236     *
237     * @return
238     *
239     */

240    public String JavaDoc getTagLib() {
241       return (this.tagLib);
242    }
243
244
245    /**
246     * Method getTagName
247     *
248     *
249     * @return
250     *
251     */

252    public String JavaDoc getTagName() {
253       return (this.tagName);
254    }
255
256
257    /**
258     * Method getParamArray
259     *
260     *
261     * @return
262     *
263     */

264    public JagParameter[] getParamArray() {
265       return (this.paramArray);
266    }
267
268
269    /**
270     * Method getPageContext
271     *
272     *
273     * @return
274     *
275     */

276    public PageContext getPageContext() {
277       return (this.pageContext);
278    }
279
280
281    /**
282     * Method setClosingTextBuffer
283     *
284     *
285     * @param endBuffer
286     *
287     */

288    public void setClosingTextBuffer(TemplateTextBlock endBuffer) {
289       closeTagBuffer = endBuffer;
290    }
291
292
293    /**
294     * Method clearCloseTag
295     *
296     *
297     */

298    public void clearCloseTag() {
299
300       if (closeTagBuffer != null) {
301          closeTagBuffer.set();
302       }
303    }
304
305
306    /**
307     * Method clearTag
308     *
309     *
310     */

311    public void clearTag() {
312
313       if (textBuffer != null) {
314          textBuffer.set();
315       }
316    }
317
318
319    /**
320     * Method setProcessed
321     *
322     *
323     * @param b
324     *
325     */

326    public void setProcessed(boolean b) {
327       processed = b;
328    }
329
330
331    /**
332     * Method isProcessed
333     *
334     *
335     * @return
336     *
337     */

338    public boolean isProcessed() {
339       return (this.processed);
340    }
341
342
343    /**
344     * Method getClosingTextBuffer
345     *
346     *
347     * @return
348     *
349     */

350    public TemplateTextBlock getClosingTextBuffer() {
351       return (this.closeTagBuffer);
352    }
353 }
354
355 ;
Popular Tags