KickJava   Java API By Example, From Geeks To Geeks.

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


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.util.*;
22
23
24 /**
25  * Class TemplateTreeItem
26  *
27  *
28  * @author Wendel D. de Witte
29  * @version %I%, %G%
30  */

31 public class TemplateTreeItem extends TreeItem {
32
33    /** Field tag */
34    public TemplateTag tag = null;
35
36    /** Field textBlock */
37    public TemplateTextBlock textBlock = null;
38
39
40    /**
41     * Constructor TemplateTreeItem
42     *
43     *
44     */

45    public TemplateTreeItem() {
46       textBlock = new TemplateTextBlock("");
47    }
48
49
50    /**
51     * Constructor TemplateTreeItem
52     *
53     *
54     * @param root
55     *
56     */

57    public TemplateTreeItem(TemplateTreeItem root) {
58
59       // Copy the textBlocks
60
textBlock = new TemplateTextBlock(root.textBlock);
61
62       // Copy the Tag and set the textbuffers.
63
if (root.tag != null) {
64          tag = new TemplateTag(root.tag);
65
66          tag.setTextBuffer(textBlock);
67          tag.setClosingTextBuffer(null);
68       }
69
70       TreeItem childItem = root.getFirstChild();
71
72       while (childItem != null) {
73          addChild(new TemplateTreeItem((TemplateTreeItem) childItem));
74
75          childItem = childItem.getNextSibling();
76       }
77
78       if ((tag != null) && (getLastChild() != null)) {
79          TemplateTreeItem closingBlock =
80             (TemplateTreeItem) getLastChild();
81          TemplateTextBlock closingText = closingBlock.getTextBlock();
82
83          tag.setClosingTextBuffer(closingText);
84       }
85    }
86
87
88    /**
89     * Method setTag
90     *
91     *
92     * @param tag
93     *
94     */

95    public void setTag(TemplateTag tag) {
96       this.tag = tag;
97    }
98
99
100    /**
101     * Method setTextBlock
102     *
103     *
104     * @param textBlock
105     *
106     */

107    public void setTextBlock(TemplateTextBlock textBlock) {
108       this.textBlock = textBlock;
109    }
110
111
112    /**
113     * Method getTag
114     *
115     *
116     * @return
117     *
118     */

119    public TemplateTag getTag() {
120       return (this.tag);
121    }
122
123
124    /**
125     * Method getTextBlock
126     *
127     *
128     * @return
129     *
130     */

131    public TemplateTextBlock getTextBlock() {
132       return (this.textBlock);
133    }
134 }
135
136 ;
Popular Tags