KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Class TemplateTextBlock
22  *
23  *
24  * @author Wendel D. de Witte
25  * @version %I%, %G%
26  */

27 public class TemplateTextBlock {
28
29    /** Field buffer */
30    private StringBuffer JavaDoc buffer;
31
32    /** Field filePath */
33    private String JavaDoc filePath;
34
35
36    /**
37     * Constructor TemplateTextBlock
38     *
39     *
40     * @param s
41     *
42     */

43    public TemplateTextBlock(String JavaDoc s) {
44       set(s);
45    }
46
47    /**
48     * Constructor TemplateTextBlock
49     *
50     *
51     * @param c
52     *
53     */

54    public TemplateTextBlock(TemplateTextBlock c) {
55
56       if ((c != null) && (c.buffer != null)) {
57          this.buffer = new StringBuffer JavaDoc(new String JavaDoc(c.buffer));
58       }
59    }
60
61    /**
62     * Method set
63     *
64     *
65     */

66    public void set() {
67       buffer = new StringBuffer JavaDoc();
68    }
69
70    /**
71     * Method set
72     *
73     *
74     * @param s
75     *
76     */

77    public void set(String JavaDoc s) {
78       buffer = new StringBuffer JavaDoc(s);
79    }
80
81    /**
82     * Method append
83     *
84     *
85     * @param s
86     *
87     */

88    public void append(String JavaDoc s) {
89       buffer.append(s);
90    }
91
92    /**
93     * Method append
94     *
95     *
96     * @param s
97     *
98     */

99    public void append(StringBuffer JavaDoc s) {
100       buffer.append(s.toString());
101    }
102
103    /**
104     * Method getText
105     *
106     *
107     * @return
108     *
109     */

110    public String JavaDoc getText() {
111       return new String JavaDoc(buffer);
112    }
113
114    /**
115     * Method toString
116     *
117     *
118     * @return
119     *
120     */

121    public String JavaDoc toString() {
122       return buffer.toString();
123    }
124
125    /**
126     * Method isEmpty
127     *
128     *
129     * @return
130     *
131     */

132    public boolean isEmpty() {
133       return buffer.length() < 1;
134    }
135
136    /**
137     * Method setFile
138     *
139     *
140     * @param path
141     *
142     */

143    public void setFile(String JavaDoc path) {
144       this.filePath = path;
145    }
146
147    /**
148     * Method getFile
149     *
150     *
151     * @return
152     *
153     */

154    public String JavaDoc getFile() {
155       return filePath;
156    }
157
158    /**
159     * Method newFile
160     *
161     *
162     * @return
163     *
164     */

165    public boolean newFile() {
166       return (filePath != null) && (filePath.length() > 0);
167    }
168 }
Popular Tags