KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ecs > XhtmlFrameSetDocument


1 /*
2  * ====================================================================
3  *
4  * The Apache Software License, Version 1.1
5  *
6  * Copyright (c) 1999-2003 The Apache Software Foundation. All rights
7  * reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above copyright
17  * notice, this list of conditions and the following disclaimer in
18  * the documentation and/or other materials provided with the
19  * distribution.
20  *
21  * 3. The end-user documentation included with the redistribution, if
22  * any, must include the following acknowlegement:
23  * "This product includes software developed by the
24  * Apache Software Foundation (http://www.apache.org/)."
25  * Alternately, this acknowlegement may appear in the software itself,
26  * if and wherever such third-party acknowlegements normally appear.
27  *
28  * 4. The names "The Jakarta Project", "Jakarta Element Construction Set",
29  * "Jakarta ECS" , and "Apache Software Foundation" must not be used
30  * to endorse or promote products derived
31  * from this software without prior written permission. For written
32  * permission, please contact apache@apache.org.
33  *
34  * 5. Products derived from this software may not be called "Apache",
35  * "Jakarta Element Construction Set" nor "Jakarta ECS" nor may "Apache"
36  * appear in their names without prior written permission of the Apache Group.
37  *
38  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
39  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
40  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
42  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
44  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
45  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
46  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
48  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
49  * SUCH DAMAGE.
50  * ====================================================================
51  *
52  * This software consists of voluntary contributions made by many
53  * individuals on behalf of the Apache Software Foundation. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  *
57  */

58 package org.apache.ecs;
59
60 import java.io.OutputStream JavaDoc;
61 import java.io.PrintWriter JavaDoc;
62 import java.io.Serializable JavaDoc;
63 import org.apache.ecs.xhtml.html;
64 import org.apache.ecs.xhtml.body;
65 import org.apache.ecs.xhtml.title;
66 import org.apache.ecs.xhtml.head;
67 import org.apache.ecs.xhtml.frameset;
68 import org.apache.ecs.xhtml.noframes;
69
70 /**
71     This class creates a XhtmlFrameSetDocument container, for convience.
72     Make sure that you add elements from org.apache.ecs.xhtml and not from org.apache.ecs.html!
73
74     @version $Id: XhtmlFrameSetDocument.java,v 1.3 2003/04/27 09:42:34 rdonkin Exp $
75     @author <a HREF="mailto:snagy@servletapi.com">Stephan Nagy</a>
76     @author <a HREF="mailto:jon@clearink.com">Jon S. Stevens</a>
77     @author <a HREF="mailto:bojan@binarix.com">Bojan Smojver</a>
78 */

79 public class XhtmlFrameSetDocument implements Serializable JavaDoc,Cloneable JavaDoc
80 {
81     /** @serial html html */
82     private html html; // this is the actual container for head and body
83
/** @serial head head */
84     private head head;
85     /** @serial body body */
86     private body body;
87     /** @serial title title */
88     private title title;
89     /** @serial frameset frameset */
90     private frameset frameset;
91     /** @serial noframes frameset */
92     private noframes noframes;
93
94     /** @serial codeset codeset */
95     private String JavaDoc codeset = null;
96     /** @serial doctype doctype */
97     private Doctype doctype = null;
98     
99     {
100         html = new html();
101         head = new head();
102         title = new title();
103         frameset = new frameset();
104         noframes = new noframes();
105         body = new body();
106         
107         head.addElement(title);
108         html.addElement(head);
109         html.addElement(frameset);
110         html.addElement(noframes);
111         noframes.addElement(body);
112     }
113     
114     /**
115         Basic constructor.
116     */

117     public XhtmlFrameSetDocument()
118     {
119     }
120
121     /**
122         Basic constructor. Sets the codeset for the page output.
123     */

124     public XhtmlFrameSetDocument(String JavaDoc codeset)
125     {
126         setCodeset(codeset);
127     }
128
129     /**
130         Get the html element for this document container.
131     */

132     public html getHtml()
133     {
134         return(html);
135     }
136     
137     /**
138         Set the html element for this XhtmlFrameSetDocument container.
139     */

140     public XhtmlFrameSetDocument setHtml(html set_html)
141     {
142         this.html = set_html;
143         return(this);
144     }
145     
146     /**
147         Get the head element for this XhtmlFrameSetDocument container.
148     */

149     public head getHead()
150     {
151         return(head);
152     }
153
154     /**
155         Set the head element for this XhtmlFrameSetDocument container.
156     */

157     public XhtmlFrameSetDocument setHead(head set_head)
158     {
159         this.head = set_head;
160         return(this);
161     }
162
163     /**
164         Append to the head element for this XhtmlFrameSetDocument container.
165         @param value adds to the value between the head tags
166     */

167     public XhtmlFrameSetDocument appendHead(Element value)
168     {
169         head.addElement(value);
170         return(this);
171     }
172
173     /**
174         Append to the head element for this XhtmlFrameSetDocument container.
175         @param value adds to the value between the head tags
176     */

177     public XhtmlFrameSetDocument appendHead(String JavaDoc value)
178     {
179         head.addElement(value);
180         return(this);
181     }
182
183     /**
184         Get the frameset element for this XhtmlFrameSetDocument container.
185     */

186     public frameset getFrameSet()
187     {
188         return(frameset);
189     }
190
191     /**
192         Set the frameset element for this XhtmlFrameSetDocument container.
193     */

194     public XhtmlFrameSetDocument setHead(frameset set_frameset)
195     {
196         this.frameset = set_frameset;
197         return(this);
198     }
199
200     /**
201         Append to the head element for this XhtmlFrameSetDocument container.
202         @param value adds to the value between the head tags
203     */

204     public XhtmlFrameSetDocument appendFrameSet(Element value)
205     {
206         frameset.addElement(value);
207         return(this);
208     }
209
210     /**
211         Append to the head element for this XhtmlFrameSetDocument container.
212         @param value adds to the value between the head tags
213     */

214     public XhtmlFrameSetDocument appendFrameSet(String JavaDoc value)
215     {
216         frameset.addElement(value);
217         return(this);
218     }
219     /**
220         Get the body element for this XhtmlFrameSetDocument container.
221     */

222     public body getBody()
223     {
224         return(body);
225     }
226
227     /**
228         Set the body element for this XhtmlFrameSetDocument container.
229     */

230     public XhtmlFrameSetDocument setBody(body set_body)
231     {
232         this.body = set_body;
233         return(this);
234     }
235     
236     /**
237         Append to the body element for this XhtmlFrameSetDocument container.
238         @param value adds to the value between the body tags
239     */

240     public XhtmlFrameSetDocument appendBody(Element value)
241     {
242         body.addElement(value);
243         return(this);
244     }
245
246     /**
247         Append to the body element for this XhtmlFrameSetDocument container.
248         @param value adds to the value between the body tags
249     */

250     public XhtmlFrameSetDocument appendBody(String JavaDoc value)
251     {
252         body.addElement(value);
253         return(this);
254     }
255
256     /**
257         Get the title element for this XhtmlFrameSetDocument container.
258     */

259     public title getTitle()
260     {
261         return(title);
262     }
263
264     /**
265         Set the title element for this XhtmlFrameSetDocument container.
266     */

267     public XhtmlFrameSetDocument setTitle(title set_title)
268     {
269         this.title = set_title;
270         return(this);
271     }
272     
273     /**
274         Append to the title element for this XhtmlFrameSetDocument container.
275         @param value adds to the value between the title tags
276     */

277     public XhtmlFrameSetDocument appendTitle(Element value)
278     {
279         title.addElement(value);
280         return(this);
281     }
282
283     /**
284         Append to the title element for this XhtmlFrameSetDocument container.
285         @param value adds to the value between the title tags
286     */

287     public XhtmlFrameSetDocument appendTitle(String JavaDoc value)
288     {
289         title.addElement(value);
290         return(this);
291     }
292
293     /**
294      * Sets the codeset for this XhtmlFrameSetDocument
295      */

296     public void setCodeset ( String JavaDoc codeset )
297     {
298         this.codeset = codeset;
299     }
300
301     /**
302      * Gets the codeset for this XhtmlFrameSetDocument
303      *
304      * @return the codeset
305      */

306     public String JavaDoc getCodeset()
307     {
308         return this.codeset;
309     }
310     
311     /**
312         Write the container to the OutputStream
313     */

314     public void output(OutputStream JavaDoc out)
315     {
316         if (doctype != null)
317         {
318             doctype.output(out);
319             try
320             {
321                 out.write('\n');
322             }
323             catch ( Exception JavaDoc e)
324             {}
325         }
326         // XhtmlFrameSetDocument is just a convient wrapper for html call html.output
327
html.output(out);
328     }
329
330     /**
331         Write the container to the PrintWriter
332     */

333     public void output(PrintWriter JavaDoc out)
334     {
335         if (doctype != null)
336         {
337             doctype.output(out);
338             try
339             {
340                 out.write('\n');
341             }
342             catch ( Exception JavaDoc e)
343             {}
344         }
345         // XhtmlFrameSetDocument is just a convient wrapper for html call html.output
346
html.output(out);
347     }
348
349     /**
350         Override the toString() method so that it prints something meaningful.
351     */

352     public final String JavaDoc toString()
353     {
354         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
355         if ( getCodeset() != null )
356         {
357             if (doctype != null)
358                 sb.append (doctype.toString(getCodeset()));
359             sb.append (html.toString(getCodeset()));
360             return (sb.toString());
361         }
362         else
363         {
364             if (doctype != null)
365                 sb.append (doctype.toString());
366             sb.append (html.toString());
367             return(sb.toString());
368         }
369     }
370
371     /**
372         Override the toString() method so that it prints something meaningful.
373     */

374     public final String JavaDoc toString(String JavaDoc codeset)
375     {
376         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
377         if (doctype != null)
378             sb.append (doctype.toString(getCodeset()));
379         sb.append (html.toString(getCodeset()));
380         return(sb.toString());
381     }
382
383     /**
384         Allows the XhtmlFrameSetDocument to be cloned. Doesn't return an instanceof XhtmlFrameSetDocument returns instance of html.
385     */

386     public Object JavaDoc clone()
387     {
388         return(html.clone());
389     }
390
391     /**
392         Get the doctype element for this XhtmlFrameSetDocument container.
393     */

394     public Doctype getDoctype()
395     {
396         return(doctype);
397     }
398     
399     /**
400         Set the doctype element for this XhtmlFrameSetDocument container.
401     */

402     public XhtmlFrameSetDocument setDoctype(Doctype set_doctype)
403     {
404         this.doctype = set_doctype;
405         return(this);
406     }
407
408 }
409
Popular Tags