KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dom4j > dom > DOMDocumentType


1 /*
2  * Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
3  *
4  * This software is open source.
5  * See the bottom of this file for the licence.
6  */

7
8 package org.dom4j.dom;
9
10 import org.dom4j.tree.DefaultDocumentType;
11
12 import org.w3c.dom.DOMException JavaDoc;
13 import org.w3c.dom.Document JavaDoc;
14 import org.w3c.dom.NamedNodeMap JavaDoc;
15 import org.w3c.dom.NodeList JavaDoc;
16
17 /**
18  * <p>
19  * <code>DOMDocumentType</code> implements a DocumentType node which supports
20  * the W3C DOM API.
21  * </p>
22  *
23  * @author <a HREF="mailto:james.strachan@metastuff.com">James Strachan </a>
24  * @version $Revision: 1.11 $
25  */

26 public class DOMDocumentType extends DefaultDocumentType implements
27         org.w3c.dom.DocumentType JavaDoc {
28     public DOMDocumentType() {
29     }
30
31     public DOMDocumentType(String JavaDoc elementName, String JavaDoc systemID) {
32         super(elementName, systemID);
33     }
34
35     public DOMDocumentType(String JavaDoc name, String JavaDoc publicID, String JavaDoc systemID) {
36         super(name, publicID, systemID);
37     }
38
39     // org.w3c.dom.Node interface
40
// -------------------------------------------------------------------------
41
public boolean supports(String JavaDoc feature, String JavaDoc version) {
42         return DOMNodeHelper.supports(this, feature, version);
43     }
44
45     public String JavaDoc getNamespaceURI() {
46         return DOMNodeHelper.getNamespaceURI(this);
47     }
48
49     public String JavaDoc getPrefix() {
50         return DOMNodeHelper.getPrefix(this);
51     }
52
53     public void setPrefix(String JavaDoc prefix) throws DOMException JavaDoc {
54         DOMNodeHelper.setPrefix(this, prefix);
55     }
56
57     public String JavaDoc getLocalName() {
58         return DOMNodeHelper.getLocalName(this);
59     }
60
61     public String JavaDoc getNodeName() {
62         return getName();
63     }
64
65     // already part of API
66
//
67
// public short getNodeType();
68
public String JavaDoc getNodeValue() throws DOMException JavaDoc {
69         return null;
70     }
71
72     public void setNodeValue(String JavaDoc nodeValue) throws DOMException JavaDoc {
73     }
74
75     public org.w3c.dom.Node JavaDoc getParentNode() {
76         return DOMNodeHelper.getParentNode(this);
77     }
78
79     public NodeList JavaDoc getChildNodes() {
80         return DOMNodeHelper.getChildNodes(this);
81     }
82
83     public org.w3c.dom.Node JavaDoc getFirstChild() {
84         return DOMNodeHelper.getFirstChild(this);
85     }
86
87     public org.w3c.dom.Node JavaDoc getLastChild() {
88         return DOMNodeHelper.getLastChild(this);
89     }
90
91     public org.w3c.dom.Node JavaDoc getPreviousSibling() {
92         return DOMNodeHelper.getPreviousSibling(this);
93     }
94
95     public org.w3c.dom.Node JavaDoc getNextSibling() {
96         return DOMNodeHelper.getNextSibling(this);
97     }
98
99     public NamedNodeMap JavaDoc getAttributes() {
100         return null;
101     }
102
103     public Document JavaDoc getOwnerDocument() {
104         return DOMNodeHelper.getOwnerDocument(this);
105     }
106
107     public org.w3c.dom.Node JavaDoc insertBefore(org.w3c.dom.Node JavaDoc newChild,
108             org.w3c.dom.Node JavaDoc refChild) throws DOMException JavaDoc {
109         checkNewChildNode(newChild);
110
111         return DOMNodeHelper.insertBefore(this, newChild, refChild);
112     }
113
114     public org.w3c.dom.Node JavaDoc replaceChild(org.w3c.dom.Node JavaDoc newChild,
115             org.w3c.dom.Node JavaDoc oldChild) throws DOMException JavaDoc {
116         checkNewChildNode(newChild);
117
118         return DOMNodeHelper.replaceChild(this, newChild, oldChild);
119     }
120
121     public org.w3c.dom.Node JavaDoc removeChild(org.w3c.dom.Node JavaDoc oldChild)
122             throws DOMException JavaDoc {
123         return DOMNodeHelper.removeChild(this, oldChild);
124     }
125
126     public org.w3c.dom.Node JavaDoc appendChild(org.w3c.dom.Node JavaDoc newChild)
127             throws DOMException JavaDoc {
128         checkNewChildNode(newChild);
129
130         return DOMNodeHelper.appendChild(this, newChild);
131     }
132
133     private void checkNewChildNode(org.w3c.dom.Node JavaDoc newChild)
134             throws DOMException JavaDoc {
135         throw new DOMException JavaDoc(DOMException.HIERARCHY_REQUEST_ERR,
136                 "DocumentType nodes cannot have children");
137     }
138
139     public boolean hasChildNodes() {
140         return DOMNodeHelper.hasChildNodes(this);
141     }
142
143     public org.w3c.dom.Node JavaDoc cloneNode(boolean deep) {
144         return DOMNodeHelper.cloneNode(this, deep);
145     }
146
147     public void normalize() {
148         DOMNodeHelper.normalize(this);
149     }
150
151     public boolean isSupported(String JavaDoc feature, String JavaDoc version) {
152         return DOMNodeHelper.isSupported(this, feature, version);
153     }
154
155     public boolean hasAttributes() {
156         return DOMNodeHelper.hasAttributes(this);
157     }
158
159     // org.w3c.dom.DocumentType interface
160
// -------------------------------------------------------------------------
161
public NamedNodeMap JavaDoc getEntities() {
162         return null;
163     }
164
165     public NamedNodeMap JavaDoc getNotations() {
166         return null;
167     }
168
169     public String JavaDoc getPublicId() {
170         return getPublicID();
171     }
172
173     public String JavaDoc getSystemId() {
174         return getSystemID();
175     }
176
177     public String JavaDoc getInternalSubset() {
178         return getElementName();
179     }
180 }
181
182 /*
183  * Redistribution and use of this software and associated documentation
184  * ("Software"), with or without modification, are permitted provided that the
185  * following conditions are met:
186  *
187  * 1. Redistributions of source code must retain copyright statements and
188  * notices. Redistributions must also contain a copy of this document.
189  *
190  * 2. Redistributions in binary form must reproduce the above copyright notice,
191  * this list of conditions and the following disclaimer in the documentation
192  * and/or other materials provided with the distribution.
193  *
194  * 3. The name "DOM4J" must not be used to endorse or promote products derived
195  * from this Software without prior written permission of MetaStuff, Ltd. For
196  * written permission, please contact dom4j-info@metastuff.com.
197  *
198  * 4. Products derived from this Software may not be called "DOM4J" nor may
199  * "DOM4J" appear in their names without prior written permission of MetaStuff,
200  * Ltd. DOM4J is a registered trademark of MetaStuff, Ltd.
201  *
202  * 5. Due credit should be given to the DOM4J Project - http://www.dom4j.org
203  *
204  * THIS SOFTWARE IS PROVIDED BY METASTUFF, LTD. AND CONTRIBUTORS ``AS IS'' AND
205  * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
206  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
207  * ARE DISCLAIMED. IN NO EVENT SHALL METASTUFF, LTD. OR ITS CONTRIBUTORS BE
208  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
209  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
210  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
211  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
212  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
213  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
214  * POSSIBILITY OF SUCH DAMAGE.
215  *
216  * Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved.
217  */

218
Popular Tags