KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > xml > xhtml > dom > xerces > XHTMLDocumentImpl


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

57 package org.enhydra.xml.xhtml.dom.xerces;
58
59 /*
60  * Derived from Xerces HTMLDocument implementation.
61  * Author: Assaf Arkin <arkin@exoffice.com>
62  */

63 import java.util.HashMap JavaDoc;
64
65 import org.enhydra.apache.html.dom.HTMLAnchorElementImpl;
66 import org.enhydra.xml.xmlc.XMLObject;
67 import org.enhydra.xml.xmlc.XMLObjectLink;
68 import org.w3c.dom.DocumentType JavaDoc;
69 import org.w3c.dom.html.HTMLDocument;
70
71 /**
72  * Implements an XHTML document. Provides access to the top level element in
73  * the document, its body and title.
74  *
75  * @see org.w3c.dom.html.HTMLDocument
76  */

77 public class XHTMLDocumentImpl extends XHTMLDocumentBase implements HTMLDocument, XMLObjectLink {
78     /**
79      * Holds names and classes of HTML element types. When an element with a
80      * particular tag name is created, the matching {@link java.lang.Class}
81      * is used to create the element object. For example, &lt;A&gt; matches
82      * {@link HTMLAnchorElementImpl}. This static table is shared across all
83      * HTML documents.
84      *
85      * @see #createElement
86      */

87     private static HashMap JavaDoc fElementTypes;
88
89     /**
90      * Constructor without document type.
91      */

92     public XHTMLDocumentImpl() {
93     super(fElementTypes);
94     }
95
96     /**
97      * Constructor with document type.
98      */

99     public XHTMLDocumentImpl(DocumentType JavaDoc doctype) {
100     super(doctype, fElementTypes);
101     }
102     /**
103      * Class initializer.
104      */

105     static {
106     fElementTypes = new HashMap JavaDoc();
107         fElementTypes.put("basefont", XHTMLBaseFontElementImpl.class);
108         fElementTypes.put("button", XHTMLButtonElementImpl.class);
109         fElementTypes.put("textarea", XHTMLTextAreaElementImpl.class);
110         fElementTypes.put("em", XHTMLEmElementImpl.class);
111         fElementTypes.put("small", XHTMLSmallElementImpl.class);
112         fElementTypes.put("area", XHTMLAreaElementImpl.class);
113         fElementTypes.put("noframes", XHTMLNoframesElementImpl.class);
114         fElementTypes.put("bdo", XHTMLBdoElementImpl.class);
115         fElementTypes.put("form", XHTMLFormElementImpl.class);
116         fElementTypes.put("link", XHTMLLinkElementImpl.class);
117         fElementTypes.put("label", XHTMLLabelElementImpl.class);
118         fElementTypes.put("dt", XHTMLDtElementImpl.class);
119         fElementTypes.put("span", XHTMLSpanElementImpl.class);
120         fElementTypes.put("isindex", XHTMLIsIndexElementImpl.class);
121         fElementTypes.put("title", XHTMLTitleElementImpl.class);
122         fElementTypes.put("strong", XHTMLStrongElementImpl.class);
123         fElementTypes.put("script", XHTMLScriptElementImpl.class);
124         fElementTypes.put("div", XHTMLDivElementImpl.class);
125         fElementTypes.put("dl", XHTMLDListElementImpl.class);
126         fElementTypes.put("blockquote", XHTMLQuoteElementImpl.class);
127         fElementTypes.put("kbd", XHTMLKbdElementImpl.class);
128         fElementTypes.put("menu", XHTMLMenuElementImpl.class);
129         fElementTypes.put("body", XHTMLBodyElementImpl.class);
130         fElementTypes.put("dir", XHTMLDirectoryElementImpl.class);
131         fElementTypes.put("ins", XHTMLModElementImpl.class);
132         fElementTypes.put("map", XHTMLMapElementImpl.class);
133         fElementTypes.put("dd", XHTMLDdElementImpl.class);
134         fElementTypes.put("fieldset", XHTMLFieldSetElementImpl.class);
135         fElementTypes.put("head", XHTMLHeadElementImpl.class);
136         fElementTypes.put("col", XHTMLTableColElementImpl.class);
137         fElementTypes.put("base", XHTMLBaseElementImpl.class);
138         fElementTypes.put("big", XHTMLBigElementImpl.class);
139         fElementTypes.put("meta", XHTMLMetaElementImpl.class);
140         fElementTypes.put("code", XHTMLCodeElementImpl.class);
141         fElementTypes.put("tbody", XHTMLTbodyElementImpl.class);
142         fElementTypes.put("option", XHTMLOptionElementImpl.class);
143         fElementTypes.put("u", XHTMLUElementImpl.class);
144         fElementTypes.put("s", XHTMLSElementImpl.class);
145         fElementTypes.put("q", XHTMLQuoteElementImpl.class);
146         fElementTypes.put("p", XHTMLParagraphElementImpl.class);
147         fElementTypes.put("ol", XHTMLOListElementImpl.class);
148         fElementTypes.put("thead", XHTMLTheadElementImpl.class);
149         fElementTypes.put("ul", XHTMLUListElementImpl.class);
150         fElementTypes.put("i", XHTMLIElementImpl.class);
151         fElementTypes.put("pre", XHTMLPreElementImpl.class);
152         fElementTypes.put("optgroup", XHTMLOptGroupElementImpl.class);
153         fElementTypes.put("img", XHTMLImageElementImpl.class);
154         fElementTypes.put("caption", XHTMLTableCaptionElementImpl.class);
155         fElementTypes.put("b", XHTMLBElementImpl.class);
156         fElementTypes.put("a", XHTMLAnchorElementImpl.class);
157         fElementTypes.put("frame", XHTMLFrameElementImpl.class);
158         fElementTypes.put("br", XHTMLBRElementImpl.class);
159         fElementTypes.put("style", XHTMLStyleElementImpl.class);
160         fElementTypes.put("hr", XHTMLHRElementImpl.class);
161         fElementTypes.put("param", XHTMLParamElementImpl.class);
162         fElementTypes.put("table", XHTMLTableElementImpl.class);
163         fElementTypes.put("applet", XHTMLAppletElementImpl.class);
164         fElementTypes.put("tt", XHTMLTtElementImpl.class);
165         fElementTypes.put("tr", XHTMLTableRowElementImpl.class);
166         fElementTypes.put("th", XHTMLTableCellElementImpl.class);
167         fElementTypes.put("center", XHTMLCenterElementImpl.class);
168         fElementTypes.put("td", XHTMLTableCellElementImpl.class);
169         fElementTypes.put("samp", XHTMLSampElementImpl.class);
170         fElementTypes.put("tfoot", XHTMLTfootElementImpl.class);
171         fElementTypes.put("font", XHTMLFontElementImpl.class);
172         fElementTypes.put("dfn", XHTMLDfnElementImpl.class);
173         fElementTypes.put("noscript", XHTMLNoscriptElementImpl.class);
174         fElementTypes.put("object", XHTMLObjectElementImpl.class);
175         fElementTypes.put("colgroup", XHTMLTableColElementImpl.class);
176         fElementTypes.put("sup", XHTMLSupElementImpl.class);
177         fElementTypes.put("html", XHTMLHtmlElementImpl.class);
178         fElementTypes.put("h6", XHTMLHeadingElementImpl.class);
179         fElementTypes.put("h5", XHTMLHeadingElementImpl.class);
180         fElementTypes.put("h4", XHTMLHeadingElementImpl.class);
181         fElementTypes.put("h3", XHTMLHeadingElementImpl.class);
182         fElementTypes.put("frameset", XHTMLFrameSetElementImpl.class);
183         fElementTypes.put("h2", XHTMLHeadingElementImpl.class);
184         fElementTypes.put("h1", XHTMLHeadingElementImpl.class);
185         fElementTypes.put("iframe", XHTMLIFrameElementImpl.class);
186         fElementTypes.put("strike", XHTMLStrikeElementImpl.class);
187         fElementTypes.put("sub", XHTMLSubElementImpl.class);
188         fElementTypes.put("acronym", XHTMLAcronymElementImpl.class);
189         fElementTypes.put("select", XHTMLSelectElementImpl.class);
190         fElementTypes.put("del", XHTMLModElementImpl.class);
191         fElementTypes.put("li", XHTMLLIElementImpl.class);
192         fElementTypes.put("cite", XHTMLCiteElementImpl.class);
193         fElementTypes.put("var", XHTMLVarElementImpl.class);
194         fElementTypes.put("legend", XHTMLLegendElementImpl.class);
195         fElementTypes.put("abbr", XHTMLAbbrElementImpl.class);
196         fElementTypes.put("input", XHTMLInputElementImpl.class);
197         fElementTypes.put("address", XHTMLAddressElementImpl.class);;
198     }
199
200     //-------------------------------------------------------------------------
201
// XMLObjectLink implementation
202
//-------------------------------------------------------------------------
203

204     /**
205      * Reference to XMLObject containing this Document.
206      */

207     private XMLObject fXmlObjectLink;
208
209     /**
210      * @see XMLObjectLink#setXMLObject
211      */

212     public void setXMLObject(XMLObject xmlObject) {
213         fXmlObjectLink = xmlObject;
214     }
215
216     /**
217      * @see XMLObjectLink#getXMLObject
218      */

219     public XMLObject getXMLObject() {
220         return fXmlObjectLink;
221     }
222
223 }
224
Popular Tags