KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > w3c > tidy > DOMDocumentImpl


1 /*
2  * @(#)DOMDocumentImpl.java 1.11 2000/08/16
3  *
4  */

5
6 package org.w3c.tidy;
7
8 import org.w3c.dom.DOMException JavaDoc;
9
10 /**
11  *
12  * DOMDocumentImpl
13  *
14  * (c) 1998-2000 (W3C) MIT, INRIA, Keio University
15  * See Tidy.java for the copyright notice.
16  * Derived from <a HREF="http://www.w3.org/People/Raggett/tidy">
17  * HTML Tidy Release 4 Aug 2000</a>
18  *
19  * @author Dave Raggett <dsr@w3.org>
20  * @author Andy Quick <ac.quick@sympatico.ca> (translation to Java)
21  * @version 1.4, 1999/09/04 DOM Support
22  * @version 1.5, 1999/10/23 Tidy Release 27 Sep 1999
23  * @version 1.6, 1999/11/01 Tidy Release 22 Oct 1999
24  * @version 1.7, 1999/12/06 Tidy Release 30 Nov 1999
25  * @version 1.8, 2000/01/22 Tidy Release 13 Jan 2000
26  * @version 1.9, 2000/06/03 Tidy Release 30 Apr 2000
27  * @version 1.10, 2000/07/22 Tidy Release 8 Jul 2000
28  * @version 1.11, 2000/08/16 Tidy Release 4 Aug 2000
29  */

30
31 public class DOMDocumentImpl extends DOMNodeImpl implements org.w3c.dom.Document JavaDoc {
32
33     private TagTable tt; // a DOM Document has its own TagTable.
34

35     protected DOMDocumentImpl(Node adaptee)
36     {
37         super(adaptee);
38         tt = new TagTable();
39     }
40
41     public void setTagTable(TagTable tt)
42     {
43         this.tt = tt;
44     }
45
46     /* --------------------- DOM ---------------------------- */
47
48     /**
49      * @see org.w3c.dom.Node#getNodeName
50      */

51     public String JavaDoc getNodeName()
52     {
53         return "#document";
54     }
55
56     /**
57      * @see org.w3c.dom.Node#getNodeType
58      */

59     public short getNodeType()
60     {
61         return org.w3c.dom.Node.DOCUMENT_NODE;
62     }
63
64     /**
65      * @see org.w3c.dom.Document#getDoctype
66      */

67     public org.w3c.dom.DocumentType JavaDoc getDoctype()
68     {
69         Node node = adaptee.content;
70         while (node != null) {
71             if (node.type == Node.DocTypeTag) break;
72             node = node.next;
73         }
74         if (node != null)
75             return (org.w3c.dom.DocumentType JavaDoc)node.getAdapter();
76         else
77             return null;
78     }
79
80     /**
81      * @see org.w3c.dom.Document#getImplementation
82      */

83     public org.w3c.dom.DOMImplementation JavaDoc getImplementation()
84     {
85         // NOT SUPPORTED
86
return null;
87     }
88
89     /**
90      * @see org.w3c.dom.Document#getDocumentElement
91      */

92     public org.w3c.dom.Element JavaDoc getDocumentElement()
93     {
94         Node node = adaptee.content;
95         while (node != null) {
96             if (node.type == Node.StartTag ||
97                 node.type == Node.StartEndTag) break;
98             node = node.next;
99         }
100         if (node != null)
101             return (org.w3c.dom.Element JavaDoc)node.getAdapter();
102         else
103             return null;
104     }
105
106     /**
107      * @see org.w3c.dom.Document#createElement
108      */

109     public org.w3c.dom.Element JavaDoc createElement(String JavaDoc tagName)
110                                             throws DOMException JavaDoc
111     {
112         Node node = new Node(Node.StartEndTag, null, 0, 0, tagName, tt);
113         if (node != null) {
114             if (node.tag == null) // Fix Bug 121206
115
node.tag = tt.xmlTags;
116             return (org.w3c.dom.Element JavaDoc)node.getAdapter();
117         }
118         else
119             return null;
120     }
121
122     /**
123      * @see org.w3c.dom.Document#createDocumentFragment
124      */

125     public org.w3c.dom.DocumentFragment JavaDoc createDocumentFragment()
126     {
127         // NOT SUPPORTED
128
return null;
129     }
130
131     /**
132      * @see org.w3c.dom.Document#createTextNode
133      */

134     public org.w3c.dom.Text JavaDoc createTextNode(String JavaDoc data)
135     {
136         byte[] textarray = Lexer.getBytes(data);
137         Node node = new Node(Node.TextNode, textarray, 0, textarray.length);
138         if (node != null)
139             return (org.w3c.dom.Text JavaDoc)node.getAdapter();
140         else
141             return null;
142     }
143
144     /**
145      * @see org.w3c.dom.Document#createComment
146      */

147     public org.w3c.dom.Comment JavaDoc createComment(String JavaDoc data)
148     {
149         byte[] textarray = Lexer.getBytes(data);
150         Node node = new Node(Node.CommentTag, textarray, 0, textarray.length);
151         if (node != null)
152             return (org.w3c.dom.Comment JavaDoc)node.getAdapter();
153         else
154             return null;
155     }
156
157     /**
158      * @see org.w3c.dom.Document#createCDATASection
159      */

160     public org.w3c.dom.CDATASection JavaDoc createCDATASection(String JavaDoc data)
161                                                  throws DOMException JavaDoc
162     {
163         // NOT SUPPORTED
164
return null;
165     }
166
167     /**
168      * @see org.w3c.dom.Document#createProcessingInstruction
169      */

170     public org.w3c.dom.ProcessingInstruction JavaDoc createProcessingInstruction(String JavaDoc target,
171                                                           String JavaDoc data)
172                                                           throws DOMException JavaDoc
173     {
174         throw new DOMExceptionImpl(DOMException.NOT_SUPPORTED_ERR,
175                                    "HTML document");
176     }
177
178     /**
179      * @see org.w3c.dom.Document#createAttribute
180      */

181     public org.w3c.dom.Attr JavaDoc createAttribute(String JavaDoc name)
182                                               throws DOMException JavaDoc
183     {
184         AttVal av = new AttVal(null, null, (int)'"', name, null);
185         if (av != null) {
186             av.dict =
187                 AttributeTable.getDefaultAttributeTable().findAttribute(av);
188             return (org.w3c.dom.Attr JavaDoc)av.getAdapter();
189         } else {
190             return null;
191         }
192     }
193
194     /**
195      * @see org.w3c.dom.Document#createEntityReference
196      */

197     public org.w3c.dom.EntityReference JavaDoc createEntityReference(String JavaDoc name)
198                                                     throws DOMException JavaDoc
199     {
200         // NOT SUPPORTED
201
return null;
202     }
203
204     /**
205      * @see org.w3c.dom.Document#getElementsByTagName
206      */

207     public org.w3c.dom.NodeList JavaDoc getElementsByTagName(String JavaDoc tagname)
208     {
209         return new DOMNodeListByTagNameImpl(this.adaptee, tagname);
210     }
211
212     /**
213      * DOM2 - not implemented.
214      * @exception org.w3c.dom.DOMException
215      */

216     public org.w3c.dom.Node JavaDoc importNode(org.w3c.dom.Node JavaDoc importedNode, boolean deep)
217         throws org.w3c.dom.DOMException JavaDoc
218     {
219     return null;
220     }
221
222     /**
223      * DOM2 - not implemented.
224      * @exception org.w3c.dom.DOMException
225      */

226     public org.w3c.dom.Attr JavaDoc createAttributeNS(String JavaDoc namespaceURI,
227                                               String JavaDoc qualifiedName)
228         throws org.w3c.dom.DOMException JavaDoc
229     {
230     return null;
231     }
232
233     /**
234      * DOM2 - not implemented.
235      * @exception org.w3c.dom.DOMException
236      */

237     public org.w3c.dom.Element JavaDoc createElementNS(String JavaDoc namespaceURI,
238                                                String JavaDoc qualifiedName)
239         throws org.w3c.dom.DOMException JavaDoc
240     {
241     return null;
242     }
243
244     /**
245      * DOM2 - not implemented.
246      */

247     public org.w3c.dom.NodeList JavaDoc getElementsByTagNameNS(String JavaDoc namespaceURI,
248                                                        String JavaDoc localName)
249     {
250     return null;
251     }
252
253     /**
254      * DOM2 - not implemented.
255      */

256     public org.w3c.dom.Element JavaDoc getElementById(String JavaDoc elementId)
257     {
258     return null;
259     }
260
261     public org.w3c.dom.Node JavaDoc adoptNode (org.w3c.dom.Node JavaDoc oNode) {
262       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMDocumentImpl adoptNode() Not implemented");
263     }
264
265     public short compareDocumentPosition (org.w3c.dom.Node JavaDoc oNode) {
266       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMDocumentImpl compareDocumentPosition() Not implemented");
267     }
268
269     public boolean isDefaultNamespace(String JavaDoc sStr1) {
270       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMDocumentImpl isDefaultNamespace() Not implemented");
271     }
272
273     public boolean isEqualNode(org.w3c.dom.Node JavaDoc oNode) {
274       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMDocumentImpl isEqualNode() Not implemented");
275     }
276
277     public boolean isSameNode(org.w3c.dom.Node JavaDoc oNode) {
278       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMDocumentImpl isSameNode() Not implemented");
279     }
280
281     public String JavaDoc lookupPrefix(String JavaDoc sStr1) {
282       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMDocumentImpl lookupPreffix() Not implemented");
283     }
284
285     public String JavaDoc lookupNamespaceURI(String JavaDoc sStr1) {
286       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMDocumentImpl lookupNamespaceURI() Not implemented");
287     }
288
289     public String JavaDoc getDocumentURI() {
290       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMDocumentImpl getDocumentURI() Not implemented");
291     }
292
293     public void setDocumentURI(String JavaDoc sStr1) {
294       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMDocumentImpl setDocumentURI() Not implemented");
295     }
296
297     public boolean getStrictErrorChecking() {
298       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMDocumentImpl getStrictErrorChecking() Not implemented");
299     }
300
301     public void setStrictErrorChecking(boolean bStrictCheck) {
302       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMDocumentImpl setStrictErrorChecking() Not implemented");
303     }
304
305     public boolean getXmlStandalone() {
306       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMDocumentImpl getXmlStandalone() Not implemented");
307     }
308
309     public void setXmlStandalone(boolean bXmlStandalone) {
310       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMDocumentImpl setXmlStandalone() Not implemented");
311     }
312
313     public Object JavaDoc getFeature(String JavaDoc sStr1, String JavaDoc sStr2) {
314       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMDocumentImpl getFeature() Not implemented");
315     }
316
317     public String JavaDoc getInputEncoding() {
318       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMDocumentImpl getInputEncoding() Not implemented");
319     }
320
321     public String JavaDoc getXmlEncoding() {
322       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMDocumentImpl getXmlEncoding() Not implemented");
323     }
324
325     public String JavaDoc getXmlVersion() {
326       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMDocumentImpl getXmlVersion() Not implemented");
327     }
328
329     public void setXmlVersion(String JavaDoc sStr1) {
330       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMDocumentImpl setXmlVersion() Not implemented");
331     }
332
333     public Object JavaDoc getUserData(String JavaDoc sStr1) {
334       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMDocumentImpl getUserData() Not implemented");
335     }
336
337     public Object JavaDoc setUserData(String JavaDoc sStr1, Object JavaDoc oObj2, org.w3c.dom.UserDataHandler JavaDoc oHndlr) {
338       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMDocumentImpl setUserData() Not implemented");
339     }
340
341     public org.w3c.dom.DOMConfiguration JavaDoc getDomConfig () {
342       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMDocumentImpl getDomConfig() Not implemented");
343     }
344
345     public void normalizeDocument () {
346       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMDocumentImpl normalizeDocument() Not implemented");
347     }
348
349     public org.w3c.dom.Node JavaDoc renameNode (org.w3c.dom.Node JavaDoc oNode, String JavaDoc sStr1, String JavaDoc sStr2) {
350       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMDocumentImpl renameNode() Not implemented");
351     }
352
353     public String JavaDoc getBaseURI() {
354       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMDocumentImpl getBaseURI() Not implemented");
355     }
356
357     public String JavaDoc getTextContent() {
358       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMDocumentImpl getTextContent() Not implemented");
359     }
360
361     public void setTextContent(String JavaDoc sStr1) {
362       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMDocumentImpl setTextContent() Not implemented");
363     }
364
365 }
366
Popular Tags