Hi , I posted a question to the ecs-user mailing list asking why FrameSetDocument doesn't extend Document. Martin ( [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> ) suggested that it was an oversight and that I submit a patch. I've hacked out a change to the code to make FrameSetDocument extend Document which - removed code referring to html, title, head doctype elements - removed code referring to OutputStream, PrintWriter and Serializable - removed most of code referring to body elements, with the exception of setBody method. I've tested it and it appears to work for me, but YMMV. Following this email is a diff of my changes with version 1.3 in cvs and the complete source file. As this is the first ever contribution to an open-source project, I hope it is okay. Regards, Mathew -- Mathew Pole Web Developer, Custom Press email: [EMAIL PROTECTED] phone: 08 8269 0511 ext 313, fax: 08 8340 1212, mobile: 0403 164 617 --- --- Diff --- cvs diff FrameSetDocument.java (in directory C:\TEMP\jakarta-ecs\src\java\org\apache\ecs\) Index: FrameSetDocument.java =================================================================== RCS file: /home/cvspublic/jakarta-ecs/src/java/org/apache/ecs/FrameSetDocument.java,v retrieving revision 1.3 diff -r1.3 FrameSetDocument.java 55,58d54 < import java.io.OutputStream; < import java.io.PrintWriter; < import java.io.Serializable; < import org.apache.ecs.html.Html; 60,61d55 < import org.apache.ecs.html.Title; < import org.apache.ecs.html.Head; 66c60,62 < This class creates a FrameSetDocument container, for convience. --- > This class creates a FrameSetDocument container, for convience, > by adding frameset and noframes elements. In addition it moves the > body element down into the noframes element from the head element. 72c68 < public class FrameSetDocument implements Serializable,Cloneable --- > public class FrameSetDocument extends Document 74,81d69 < /** @serial html html */ < private Html html; // this is the actual container for head and body < /** @serial head head */ < private Head head; < /** @serial body body */ < private Body body; < /** @serial title title */ < private Title title; 86,90d73 < /** @serial doctype doctype */ < private Doctype doctype = null; < < /** @serial codeset codeset */ < private String codeset = null; 93,95d75 < html = new Html(); < head = new Head(); < title = new Title(); 98d77 < body = new Body(); 100,104c79,84 < head.addElement("title",title); < html.addElement("head",head); < html.addElement("frameset",frameset); < html.addElement("noframes",noframes); < noframes.addElement("body",body); --- > getHtml ().addElement("frameset",frameset); > getHtml ().addElement("noframes",noframes); > > // remove body from main html element and add into the noframe element > noframes.addElement("body",getBody ()); > getHtml ().removeElement ("body"); 115,194d94 < Basic constructor. Sets the codeset for the page output. < */ < public FrameSetDocument(String codeset) < { < setCodeset(codeset); < } < < /** < Get the doctype element for this document container. < */ < public Doctype getDoctype() < { < return(doctype); < } < < /** < Set the doctype element for this document container. < */ < public FrameSetDocument setDoctype(Doctype set_doctype) < { < this.doctype = set_doctype; < return(this); < } < < /** < Get the html element for this document container. < */ < public Html getHtml() < { < return(html); < } < < /** < Set the html element for this FrameSetDocument container. < */ < public FrameSetDocument setHtml(Html set_html) < { < this.html = set_html; < return(this); < } < < /** < Get the head element for this FrameSetDocument container. < */ < public Head getHead() < { < return(head); < } < < /** < Set the head element for this FrameSetDocument container. < */ < public FrameSetDocument setHead(Head set_head) < { < html.addElement("head",set_head); < this.head = set_head; < return(this); < } < < /** < Append to the head element for this FrameSetDocument container. < @param value adds to the value between the head tags < */ < public FrameSetDocument appendHead(Element value) < { < head.addElement(value); < return(this); < } < < /** < Append to the head element for this FrameSetDocument container. < @param value adds to the value between the head tags < */ < public FrameSetDocument appendHead(String value) < { < head.addElement(value); < return(this); < } < < /** 207c107 < html.addElement("frameset",set_frameset); --- > getHtml ().addElement("frameset",set_frameset); 231,237c131 < /** < Get the body element for this FrameSetDocument container. < */ < public Body getBody() < { < return(body); < } --- > 241,295d134 < */ < public FrameSetDocument setBody(Body set_body) < { < noframes.addElement("body",set_body); < this.body = set_body; < return(this); < } < < /** < Append to the body element for this FrameSetDocument container. < @param value adds to the value between the body tags < */ < public FrameSetDocument appendBody(Element value) < { < body.addElement(value); < return(this); < } < < /** < Append to the body element for this FrameSetDocument container. < @param value adds to the value between the body tags < */ < public FrameSetDocument appendBody(String value) < { < body.addElement(value); < return(this); < } < < /** < Get the title element for this FrameSetDocument container. < */ < public Title getTitle() < { < return(title); < } < < /** < Set the Title element for this FrameSetDocument container. < */ < public FrameSetDocument setTitle(Title set_title) < { < head.addElement("title",set_title); < this.title = set_title; < return(this); < } < < /** < Append to the title element for this FrameSetDocument container. < @param value adds to the value between the title tags < */ < public FrameSetDocument appendTitle(Element value) < { < title.addElement(value); < return(this); < } 297,299c136,137 < /** < Append to the title element for this FrameSetDocument container. < @param value adds to the value between the title tags --- > <p>The Document#setBody method is overridden, because the Body > element is in the NoFrames element. 301c139 < public FrameSetDocument appendTitle(String value) --- > public Document setBody(Body set_body) 303c141,144 < title.addElement(value); --- > super.setBody (set_body); > > noframes.addElement("body",set_body); > getHtml ().removeElement ("body"); 306,323d146 < < /** < * Sets the codeset for this FrameSetDocument < */ < public void setCodeset ( String codeset ) < { < this.codeset = codeset; < } < < /** < * Gets the codeset for this FrameSetDocument < * < * @return the codeset < */ < public String getCodeset() < { < return this.codeset; < } 325,406c148 < /** < Write the container to the OutputStream < */ < public void output(OutputStream out) < { < if (doctype != null) < { < doctype.output(out); < try < { < out.write('\n'); < } < catch ( Exception e) < {} < } < // FrameSetDocument is just a convient wrapper for Html call Html.output < html.output(out); < } < < /** < Write the container to the PrintWriter < */ < public void output(PrintWriter out) < { < if (doctype != null) < { < doctype.output(out); < try < { < out.write('\n'); < } < catch ( Exception e) < {} < } < // FrameSetDocument is just a convient wrapper for Html call Html.output < html.output(out); < } < < /** < Override the toString() method so that it prints something meaningful. < */ < public final String toString() < { < StringBuffer sb = new StringBuffer(); < if ( getCodeset() != null ) < { < if (doctype != null) < sb.append (doctype.toString(getCodeset())); < sb.append (html.toString(getCodeset())); < return (sb.toString()); < } < else < { < if (doctype != null) < sb.append (doctype.toString()); < sb.append (html.toString()); < return(sb.toString()); < } < } < < /** < Override the toString() method so that it prints something meaningful. < */ < public final String toString(String codeset) < { < StringBuffer sb = new StringBuffer(); < if (doctype != null) < sb.append (doctype.toString(getCodeset())); < sb.append (html.toString(getCodeset())); < return(sb.toString()); < } < < /** < Allows the FrameSetDocument to be cloned. Doesn't return an instanceof FrameSetDocument returns instance of Html. < < */ < < public Object clone() < { < return(html.clone()); < } < } \ No newline at end of file --- > }
---------------------------------------------------------------------------- ------------- ---------------------------------------------------------------------------- ------------- -- -- Source Code -- /* * Copyright (c) 1999 The Java Apache Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. All advertising materials mentioning features or use of this * software must display the following acknowledgment: * "This product includes software developed by the Java Apache * Project. < http://java.apache.org/ <http://java.apache.org/> >" * * 4. The names "Java Apache Element Construction Set", "Java Apache ECS" and * "Java Apache Project" must not be used to endorse or promote products * derived from this software without prior written permission. * * 5. Products derived from this software may not be called * "Java Apache Element Construction Set" nor "Java Apache ECS" appear * in their names without prior written permission of the * Java Apache Project. * * 6. Redistributions of any form whatsoever must retain the following * acknowledgment: * "This product includes software developed by the Java Apache * Project. < http://java.apache.org/ <http://java.apache.org/> >" * * THIS SOFTWARE IS PROVIDED BY THE JAVA APACHE PROJECT "AS IS" AND ANY * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE JAVA APACHE PROJECT OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. * * This software consists of voluntary contributions made by many * individuals on behalf of the Java Apache Project. For more information * on the Java Apache Project please see < http://java.apache.org/ <http://java.apache.org/> >. * */ package org.apache.ecs; import org.apache.ecs.html.Body; import org.apache.ecs.html.FrameSet; import org.apache.ecs.html.NoFrames; /** This class creates a FrameSetDocument container, for convience, by adding frameset and noframes elements. In addition it moves the body element down into the noframes element from the head element. @version $Id: FrameSetDocument.java,v 1.3 2001/03/29 23:02:32 rdonkin Exp $ @author <a href=" Stephan'>mailto:[EMAIL PROTECTED]" <mailto:[EMAIL PROTECTED]> >Stephan Nagy</a> @author <a href=" Jon'>mailto:[EMAIL PROTECTED]" <mailto:[EMAIL PROTECTED]> >Jon S. Stevens</a> */ public class FrameSetDocument extends Document { /** @serial frameset frameset */ private FrameSet frameset; /** @serial noframes frameset */ private NoFrames noframes; { frameset = new FrameSet(); noframes = new NoFrames(); getHtml ().addElement("frameset",frameset); getHtml ().addElement("noframes",noframes); // remove body from main html element and add into the noframe element noframes.addElement("body",getBody ()); getHtml ().removeElement ("body"); } /** Basic constructor. */ public FrameSetDocument() { } /** Get the FrameSet element for this FrameSetDocument container. */ public FrameSet getFrameSet() { return(frameset); } /** Set the FrameSet element for this FrameSetDocument container. */ public FrameSetDocument setFrameSet(FrameSet set_frameset) { getHtml ().addElement("frameset",set_frameset); this.frameset = set_frameset; return(this); } /** Append to the head element for this FrameSetDocument container. @param value adds to the value between the head tags */ public FrameSetDocument appendFrameSet(Element value) { frameset.addElement(value); return(this); } /** Append to the head element for this FrameSetDocument container. @param value adds to the value between the head tags */ public FrameSetDocument appendFrameSet(String value) { frameset.addElement(value); return(this); } /** Set the Body element for this FrameSetDocument container. <p>The Document#setBody method is overridden, because the Body element is in the NoFrames element. */ public Document setBody(Body set_body) { super.setBody (set_body); noframes.addElement("body",set_body); getHtml ().removeElement ("body"); return(this); } }
