KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > xml > dom > DocumentWrapper


1 /*
2  * Copyright 1999-2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.xml.dom;
17
18 import org.apache.cocoon.ProcessingException;
19 import org.apache.cocoon.xml.XMLUtils;
20
21 import org.apache.excalibur.xml.sax.XMLizable;
22
23 import org.w3c.dom.Attr JavaDoc;
24 import org.w3c.dom.CDATASection JavaDoc;
25 import org.w3c.dom.Comment JavaDoc;
26 import org.w3c.dom.DOMConfiguration JavaDoc;
27 import org.w3c.dom.DOMException JavaDoc;
28 import org.w3c.dom.DOMImplementation JavaDoc;
29 import org.w3c.dom.Document JavaDoc;
30 import org.w3c.dom.DocumentFragment JavaDoc;
31 import org.w3c.dom.DocumentType JavaDoc;
32 import org.w3c.dom.Element JavaDoc;
33 import org.w3c.dom.EntityReference JavaDoc;
34 import org.w3c.dom.NamedNodeMap JavaDoc;
35 import org.w3c.dom.Node JavaDoc;
36 import org.w3c.dom.NodeList JavaDoc;
37 import org.w3c.dom.ProcessingInstruction JavaDoc;
38 import org.w3c.dom.Text JavaDoc;
39 import org.w3c.dom.UserDataHandler JavaDoc;
40 import org.xml.sax.SAXException JavaDoc;
41
42
43 /**
44  * Wraps an org.w3c.dom.Document and offers additional interfaces
45  * like XMLizable and a toString() method.
46  *
47  * @author <a HREF="mailto:haul@apache.org">Christian Haul</a>
48  * @version CVS $Id: DocumentWrapper.java 156529 2005-03-08 14:45:48Z cziegeler $
49 */

50 public class DocumentWrapper implements org.w3c.dom.Document JavaDoc, XMLizable {
51
52     protected final static String JavaDoc DOMLEVEL3_ERR_MSG =
53         "This method was just added for providing future compatibility to JDK 1.5's DOM level 3 Document interface.";
54
55     protected final Document JavaDoc document;
56     
57     /** Creates a new instance of DocmentWrapper */
58     public DocumentWrapper(Document JavaDoc doc) {
59         this.document = doc;
60     }
61
62
63     /**
64      * Generates SAX events representing the object's state.<br/>
65      * <b>NOTE</b> : if the implementation can produce lexical events,
66      * care should be taken that <code>handler</code> can actually be
67      * a {@link org.apache.cocoon.xml.XMLConsumer} that accepts such
68      * events.
69      */

70     public void toSAX(org.xml.sax.ContentHandler JavaDoc handler) throws SAXException JavaDoc {
71
72         DOMStreamer ds = new DOMStreamer(handler);
73         ds.stream(this.document.getDocumentElement());
74     }
75
76
77     public String JavaDoc toString() {
78         try {
79             return XMLUtils.serializeNode(this.document, XMLUtils.createPropertiesForXML(false));
80         } catch (ProcessingException e) {
81         }
82         return "";
83     }
84
85
86     /** Adds the node <code>newChild</code> to the end of the list of children
87      * of this node. If the <code>newChild</code> is already in the tree, it
88      * is first removed.
89      * @param newChild The node to add.If it is a
90      * <code>DocumentFragment</code> object, the entire contents of the
91      * document fragment are moved into the child list of this node
92      * @return The node added.
93      * @exception DOMException
94      * HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
95      * allow children of the type of the <code>newChild</code> node, or if
96      * the node to append is one of this node's ancestors or this node
97      * itself.
98      * <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created
99      * from a different document than the one that created this node.
100      * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or
101      * if the previous parent of the node being inserted is readonly.
102      *
103      */

104     public Node JavaDoc appendChild(Node JavaDoc newChild) throws DOMException JavaDoc {
105         return this.document.appendChild(newChild);
106     }
107
108     /** Returns a duplicate of this node, i.e., serves as a generic copy
109      * constructor for nodes. The duplicate node has no parent; (
110      * <code>parentNode</code> is <code>null</code>.).
111      * <br>Cloning an <code>Element</code> copies all attributes and their
112      * values, including those generated by the XML processor to represent
113      * defaulted attributes, but this method does not copy any text it
114      * contains unless it is a deep clone, since the text is contained in a
115      * child <code>Text</code> node. Cloning an <code>Attribute</code>
116      * directly, as opposed to be cloned as part of an <code>Element</code>
117      * cloning operation, returns a specified attribute (
118      * <code>specified</code> is <code>true</code>). Cloning any other type
119      * of node simply returns a copy of this node.
120      * <br>Note that cloning an immutable subtree results in a mutable copy,
121      * but the children of an <code>EntityReference</code> clone are readonly
122      * . In addition, clones of unspecified <code>Attr</code> nodes are
123      * specified. And, cloning <code>Document</code>,
124      * <code>DocumentType</code>, <code>Entity</code>, and
125      * <code>Notation</code> nodes is implementation dependent.
126      * @param deep If <code>true</code>, recursively clone the subtree under
127      * the specified node; if <code>false</code>, clone only the node
128      * itself (and its attributes, if it is an <code>Element</code>).
129      * @return The duplicate node.
130      *
131      */

132     public Node JavaDoc cloneNode(boolean deep) {
133         return this.document.cloneNode(deep);
134     }
135
136     /** Creates an <code>Attr</code> of the given name. Note that the
137      * <code>Attr</code> instance can then be set on an <code>Element</code>
138      * using the <code>setAttributeNode</code> method.
139      * <br>To create an attribute with a qualified name and namespace URI, use
140      * the <code>createAttributeNS</code> method.
141      * @param name The name of the attribute.
142      * @return A new <code>Attr</code> object with the <code>nodeName</code>
143      * attribute set to <code>name</code>, and <code>localName</code>,
144      * <code>prefix</code>, and <code>namespaceURI</code> set to
145      * <code>null</code>. The value of the attribute is the empty string.
146      * @exception DOMException
147      * INVALID_CHARACTER_ERR: Raised if the specified name contains an
148      * illegal character.
149      *
150      */

151     public Attr JavaDoc createAttribute(String JavaDoc name) throws DOMException JavaDoc {
152         return this.document.createAttribute(name);
153     }
154
155     /** Creates an attribute of the given qualified name and namespace URI.
156      * @param namespaceURI The namespace URI of the attribute to create.
157      * @param qualifiedName The qualified name of the attribute to
158      * instantiate.
159      * @return A new <code>Attr</code> object with the following attributes:
160      * <table border='1'>
161      * <tr>
162      * <th>
163      * Attribute</th>
164      * <th>Value</th>
165      * </tr>
166      * <tr>
167      * <td valign='top' rowspan='1' colspan='1'><code>Node.nodeName</code></td>
168      * <td valign='top' rowspan='1' colspan='1'>qualifiedName</td>
169      * </tr>
170      * <tr>
171      * <td valign='top' rowspan='1' colspan='1'>
172      * <code>Node.namespaceURI</code></td>
173      * <td valign='top' rowspan='1' colspan='1'><code>namespaceURI</code></td>
174      * </tr>
175      * <tr>
176      * <td valign='top' rowspan='1' colspan='1'>
177      * <code>Node.prefix</code></td>
178      * <td valign='top' rowspan='1' colspan='1'>prefix, extracted from
179      * <code>qualifiedName</code>, or <code>null</code> if there is no
180      * prefix</td>
181      * </tr>
182      * <tr>
183      * <td valign='top' rowspan='1' colspan='1'><code>Node.localName</code></td>
184      * <td valign='top' rowspan='1' colspan='1'>local name, extracted from
185      * <code>qualifiedName</code></td>
186      * </tr>
187      * <tr>
188      * <td valign='top' rowspan='1' colspan='1'><code>Attr.name</code></td>
189      * <td valign='top' rowspan='1' colspan='1'>
190      * <code>qualifiedName</code></td>
191      * </tr>
192      * <tr>
193      * <td valign='top' rowspan='1' colspan='1'><code>Node.nodeValue</code></td>
194      * <td valign='top' rowspan='1' colspan='1'>the empty
195      * string</td>
196      * </tr>
197      * </table>
198      * @exception DOMException
199      * INVALID_CHARACTER_ERR: Raised if the specified qualified name
200      * contains an illegal character, per the XML 1.0 specification .
201      * <br>NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is
202      * malformed per the Namespaces in XML specification, if the
203      * <code>qualifiedName</code> has a prefix and the
204      * <code>namespaceURI</code> is <code>null</code>, if the
205      * <code>qualifiedName</code> has a prefix that is "xml" and the
206      * <code>namespaceURI</code> is different from "
207      * http://www.w3.org/XML/1998/namespace", or if the
208      * <code>qualifiedName</code>, or its prefix, is "xmlns" and the
209      * <code>namespaceURI</code> is different from "
210      * http://www.w3.org/2000/xmlns/".
211      * <br>NOT_SUPPORTED_ERR: Always thrown if the current document does not
212      * support the <code>"XML"</code> feature, since namespaces were
213      * defined by XML.
214      * @since DOM Level 2
215      *
216      */

217     public Attr JavaDoc createAttributeNS(String JavaDoc namespaceURI, String JavaDoc qualifiedName) throws DOMException JavaDoc {
218         return this.document.createAttributeNS(namespaceURI, qualifiedName);
219     }
220
221     /** Creates a <code>CDATASection</code> node whose value is the specified
222      * string.
223      * @param data The data for the <code>CDATASection</code> contents.
224      * @return The new <code>CDATASection</code> object.
225      * @exception DOMException
226      * NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
227      *
228      */

229     public CDATASection JavaDoc createCDATASection(String JavaDoc data) throws DOMException JavaDoc {
230         return this.document.createCDATASection(data);
231     }
232
233     /** Creates a <code>Comment</code> node given the specified string.
234      * @param data The data for the node.
235      * @return The new <code>Comment</code> object.
236      *
237      */

238     public Comment JavaDoc createComment(String JavaDoc data) {
239         return this.document.createComment(data);
240     }
241
242     /** Creates an empty <code>DocumentFragment</code> object.
243      * @return A new <code>DocumentFragment</code>.
244      *
245      */

246     public DocumentFragment JavaDoc createDocumentFragment() {
247         return this.document.createDocumentFragment();
248     }
249
250     /** Creates an element of the type specified. Note that the instance
251      * returned implements the <code>Element</code> interface, so attributes
252      * can be specified directly on the returned object.
253      * <br>In addition, if there are known attributes with default values,
254      * <code>Attr</code> nodes representing them are automatically created
255      * and attached to the element.
256      * <br>To create an element with a qualified name and namespace URI, use
257      * the <code>createElementNS</code> method.
258      * @param tagName The name of the element type to instantiate. For XML,
259      * this is case-sensitive. For HTML, the <code>tagName</code>
260      * parameter may be provided in any case, but it must be mapped to the
261      * canonical uppercase form by the DOM implementation.
262      * @return A new <code>Element</code> object with the
263      * <code>nodeName</code> attribute set to <code>tagName</code>, and
264      * <code>localName</code>, <code>prefix</code>, and
265      * <code>namespaceURI</code> set to <code>null</code>.
266      * @exception DOMException
267      * INVALID_CHARACTER_ERR: Raised if the specified name contains an
268      * illegal character.
269      *
270      */

271     public Element JavaDoc createElement(String JavaDoc tagName) throws DOMException JavaDoc {
272         return this.document.createElement(tagName);
273     }
274     
275     /** Creates an element of the given qualified name and namespace URI.
276      * @param namespaceURI The namespace URI of the element to create.
277      * @param qualifiedName The qualified name of the element type to
278      * instantiate.
279      * @return A new <code>Element</code> object with the following
280      * attributes:
281      * <table border='1'>
282      * <tr>
283      * <th>Attribute</th>
284      * <th>Value</th>
285      * </tr>
286      * <tr>
287      * <td valign='top' rowspan='1' colspan='1'><code>Node.nodeName</code></td>
288      * <td valign='top' rowspan='1' colspan='1'>
289      * <code>qualifiedName</code></td>
290      * </tr>
291      * <tr>
292      * <td valign='top' rowspan='1' colspan='1'><code>Node.namespaceURI</code></td>
293      * <td valign='top' rowspan='1' colspan='1'>
294      * <code>namespaceURI</code></td>
295      * </tr>
296      * <tr>
297      * <td valign='top' rowspan='1' colspan='1'><code>Node.prefix</code></td>
298      * <td valign='top' rowspan='1' colspan='1'>prefix, extracted
299      * from <code>qualifiedName</code>, or <code>null</code> if there is
300      * no prefix</td>
301      * </tr>
302      * <tr>
303      * <td valign='top' rowspan='1' colspan='1'><code>Node.localName</code></td>
304      * <td valign='top' rowspan='1' colspan='1'>local name, extracted from
305      * <code>qualifiedName</code></td>
306      * </tr>
307      * <tr>
308      * <td valign='top' rowspan='1' colspan='1'><code>Element.tagName</code></td>
309      * <td valign='top' rowspan='1' colspan='1'>
310      * <code>qualifiedName</code></td>
311      * </tr>
312      * </table>
313      * @exception DOMException
314      * INVALID_CHARACTER_ERR: Raised if the specified qualified name
315      * contains an illegal character, per the XML 1.0 specification .
316      * <br>NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is
317      * malformed per the Namespaces in XML specification, if the
318      * <code>qualifiedName</code> has a prefix and the
319      * <code>namespaceURI</code> is <code>null</code>, or if the
320      * <code>qualifiedName</code> has a prefix that is "xml" and the
321      * <code>namespaceURI</code> is different from "
322      * http://www.w3.org/XML/1998/namespace" .
323      * <br>NOT_SUPPORTED_ERR: Always thrown if the current document does not
324      * support the <code>"XML"</code> feature, since namespaces were
325      * defined by XML.
326      * @since DOM Level 2
327      *
328      */

329     public Element JavaDoc createElementNS(String JavaDoc namespaceURI, String JavaDoc qualifiedName) throws DOMException JavaDoc {
330         return this.document.createElementNS(namespaceURI, qualifiedName);
331     }
332
333     /** Creates an <code>EntityReference</code> object. In addition, if the
334      * referenced entity is known, the child list of the
335      * <code>EntityReference</code> node is made the same as that of the
336      * corresponding <code>Entity</code> node.If any descendant of the
337      * <code>Entity</code> node has an unbound namespace prefix, the
338      * corresponding descendant of the created <code>EntityReference</code>
339      * node is also unbound; (its <code>namespaceURI</code> is
340      * <code>null</code>). The DOM Level 2 does not support any mechanism to
341      * resolve namespace prefixes.
342      * @param name The name of the entity to reference.
343      * @return The new <code>EntityReference</code> object.
344      * @exception DOMException
345      * INVALID_CHARACTER_ERR: Raised if the specified name contains an
346      * illegal character.
347      * <br>NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
348      *
349      */

350     public EntityReference JavaDoc createEntityReference(String JavaDoc name) throws DOMException JavaDoc {
351         return this.document.createEntityReference(name);
352     }
353
354     /** Creates a <code>ProcessingInstruction</code> node given the specified
355      * name and data strings.
356      * @param target The target part of the processing instruction.
357      * @param data The data for the node.
358      * @return The new <code>ProcessingInstruction</code> object.
359      * @exception DOMException
360      * INVALID_CHARACTER_ERR: Raised if the specified target contains an
361      * illegal character.
362      * <br>NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
363      *
364      */

365     public ProcessingInstruction JavaDoc createProcessingInstruction(String JavaDoc target, String JavaDoc data) throws DOMException JavaDoc {
366         return this.document.createProcessingInstruction(target, data);
367     }
368
369     /** Creates a <code>Text</code> node given the specified string.
370      * @param data The data for the node.
371      * @return The new <code>Text</code> object.
372      *
373      */

374     public Text JavaDoc createTextNode(String JavaDoc data) {
375         return this.document.createTextNode(data);
376     }
377
378     /** A <code>NamedNodeMap</code> containing the attributes of this node (if
379      * it is an <code>Element</code>) or <code>null</code> otherwise.
380      *
381      */

382     public NamedNodeMap JavaDoc getAttributes() {
383         return this.document.getAttributes();
384     }
385
386     /** A <code>NodeList</code> that contains all children of this node. If
387      * there are no children, this is a <code>NodeList</code> containing no
388      * nodes.
389      *
390      */

391     public NodeList JavaDoc getChildNodes() {
392         return this.document.getChildNodes();
393     }
394
395     /** The Document Type Declaration (see <code>DocumentType</code>)
396      * associated with this document. For HTML documents as well as XML
397      * documents without a document type declaration this returns
398      * <code>null</code>. The DOM Level 2 does not support editing the
399      * Document Type Declaration. <code>docType</code> cannot be altered in
400      * any way, including through the use of methods inherited from the
401      * <code>Node</code> interface, such as <code>insertNode</code> or
402      * <code>removeNode</code>.
403      *
404      */

405     public DocumentType JavaDoc getDoctype() {
406         return this.document.getDoctype();
407     }
408
409     /** This is a convenience attribute that allows direct access to the child
410      * node that is the root element of the document. For HTML documents,
411      * this is the element with the tagName "HTML".
412      *
413      */

414     public Element JavaDoc getDocumentElement() {
415         return this.document.getDocumentElement();
416     }
417
418     /** Returns the <code>Element</code> whose <code>ID</code> is given by
419      * <code>elementId</code>. If no such element exists, returns
420      * <code>null</code>. Behavior is not defined if more than one element
421      * has this <code>ID</code>. The DOM implementation must have
422      * information that says which attributes are of type ID. Attributes
423      * with the name "ID" are not of type ID unless so defined.
424      * Implementations that do not know whether attributes are of type ID or
425      * not are expected to return <code>null</code>.
426      * @param elementId The unique <code>id</code> value for an element.
427      * @return The matching element.
428      * @since DOM Level 2
429      *
430      */

431     public Element JavaDoc getElementById(String JavaDoc elementId) {
432         return this.document.getElementById(elementId);
433     }
434
435     /** Returns a <code>NodeList</code> of all the <code>Elements</code> with a
436      * given tag name in the order in which they are encountered in a
437      * preorder traversal of the <code>Document</code> tree.
438      * @param tagname The name of the tag to match on. The special value "*"
439      * matches all tags.
440      * @return A new <code>NodeList</code> object containing all the matched
441      * <code>Elements</code>.
442      *
443      */

444     public NodeList JavaDoc getElementsByTagName(String JavaDoc tagname) {
445         return this.document.getElementsByTagName(tagname);
446     }
447
448     /** Returns a <code>NodeList</code> of all the <code>Elements</code> with a
449      * given local name and namespace URI in the order in which they are
450      * encountered in a preorder traversal of the <code>Document</code> tree.
451      * @param namespaceURI The namespace URI of the elements to match on. The
452      * special value "*" matches all namespaces.
453      * @param localName The local name of the elements to match on. The
454      * special value "*" matches all local names.
455      * @return A new <code>NodeList</code> object containing all the matched
456      * <code>Elements</code>.
457      * @since DOM Level 2
458      *
459      */

460     public NodeList JavaDoc getElementsByTagNameNS(String JavaDoc namespaceURI, String JavaDoc localName) {
461         return this.document.getElementsByTagNameNS(namespaceURI, localName);
462     }
463
464     /** The first child of this node. If there is no such node, this returns
465      * <code>null</code>.
466      *
467      */

468     public Node JavaDoc getFirstChild() {
469         return this.document.getFirstChild();
470     }
471
472     /** The <code>DOMImplementation</code> object that handles this document. A
473      * DOM application may use objects from multiple implementations.
474      *
475      */

476     public DOMImplementation JavaDoc getImplementation() {
477         return this.document.getImplementation();
478     }
479
480     /** The last child of this node. If there is no such node, this returns
481      * <code>null</code>.
482      *
483      */

484     public Node JavaDoc getLastChild() {
485         return this.document.getLastChild();
486     }
487
488     /** Returns the local part of the qualified name of this node.
489      * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and
490      * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1
491      * method, such as <code>createElement</code> from the
492      * <code>Document</code> interface, this is always <code>null</code>.
493      * @since DOM Level 2
494      *
495      */

496     public String JavaDoc getLocalName() {
497         return this.document.getLocalName();
498     }
499
500     /** The namespace URI of this node, or <code>null</code> if it is
501      * unspecified.
502      * <br>This is not a computed value that is the result of a namespace
503      * lookup based on an examination of the namespace declarations in
504      * scope. It is merely the namespace URI given at creation time.
505      * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and
506      * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1
507      * method, such as <code>createElement</code> from the
508      * <code>Document</code> interface, this is always <code>null</code>.Per
509      * the Namespaces in XML Specification an attribute does not inherit
510      * its namespace from the element it is attached to. If an attribute is
511      * not explicitly given a namespace, it simply has no namespace.
512      * @since DOM Level 2
513      *
514      */

515     public String JavaDoc getNamespaceURI() {
516         return this.document.getNamespaceURI();
517     }
518
519     /** The node immediately following this node. If there is no such node,
520      * this returns <code>null</code>.
521      *
522      */

523     public Node JavaDoc getNextSibling() {
524         return this.document.getNextSibling();
525     }
526
527     /** The name of this node, depending on its type; see the table above.
528      *
529      */

530     public String JavaDoc getNodeName() {
531         return this.document.getNodeName();
532     }
533
534     /** A code representing the type of the underlying object, as defined above.
535      *
536      */

537     public short getNodeType() {
538         return this.document.getNodeType();
539     }
540
541     /** The value of this node, depending on its type; see the table above.
542      * When it is defined to be <code>null</code>, setting it has no effect.
543      * @exception DOMException
544      * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
545      * DOMSTRING_SIZE_ERR: Raised when it would return more characters than
546      * fit in a <code>DOMString</code> variable on the implementation
547      * platform.
548      *
549      */

550     public String JavaDoc getNodeValue() throws DOMException JavaDoc {
551         return this.document.getNodeValue();
552     }
553
554     /** The <code>Document</code> object associated with this node. This is
555      * also the <code>Document</code> object used to create new nodes. When
556      * this node is a <code>Document</code> or a <code>DocumentType</code>
557      * which is not used with any <code>Document</code> yet, this is
558      * <code>null</code>.
559      * @since DOM Level 2
560      *
561      */

562     public Document JavaDoc getOwnerDocument() {
563         return this.document.getOwnerDocument();
564     }
565
566     /** The parent of this node. All nodes, except <code>Attr</code>,
567      * <code>Document</code>, <code>DocumentFragment</code>,
568      * <code>Entity</code>, and <code>Notation</code> may have a parent.
569      * However, if a node has just been created and not yet added to the
570      * tree, or if it has been removed from the tree, this is
571      * <code>null</code>.
572      *
573      */

574     public Node JavaDoc getParentNode() {
575         return this.document.getParentNode();
576     }
577
578     /** The namespace prefix of this node, or <code>null</code> if it is
579      * unspecified.
580      * <br>Note that setting this attribute, when permitted, changes the
581      * <code>nodeName</code> attribute, which holds the qualified name, as
582      * well as the <code>tagName</code> and <code>name</code> attributes of
583      * the <code>Element</code> and <code>Attr</code> interfaces, when
584      * applicable.
585      * <br>Note also that changing the prefix of an attribute that is known to
586      * have a default value, does not make a new attribute with the default
587      * value and the original prefix appear, since the
588      * <code>namespaceURI</code> and <code>localName</code> do not change.
589      * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and
590      * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1
591      * method, such as <code>createElement</code> from the
592      * <code>Document</code> interface, this is always <code>null</code>.
593      * @exception DOMException
594      * INVALID_CHARACTER_ERR: Raised if the specified prefix contains an
595      * illegal character, per the XML 1.0 specification .
596      * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
597      * <br>NAMESPACE_ERR: Raised if the specified <code>prefix</code> is
598      * malformed per the Namespaces in XML specification, if the
599      * <code>namespaceURI</code> of this node is <code>null</code>, if the
600      * specified prefix is "xml" and the <code>namespaceURI</code> of this
601      * node is different from "http://www.w3.org/XML/1998/namespace", if
602      * this node is an attribute and the specified prefix is "xmlns" and
603      * the <code>namespaceURI</code> of this node is different from "
604      * http://www.w3.org/2000/xmlns/", or if this node is an attribute and
605      * the <code>qualifiedName</code> of this node is "xmlns" .
606      * @since DOM Level 2
607      *
608      */

609     public String JavaDoc getPrefix() {
610         return this.document.getPrefix();
611     }
612
613     /** The node immediately preceding this node. If there is no such node,
614      * this returns <code>null</code>.
615      *
616      */

617     public Node JavaDoc getPreviousSibling() {
618         return this.document.getPreviousSibling();
619     }
620
621     /** Returns whether this node (if it is an element) has any attributes.
622      * @return <code>true</code> if this node has any attributes,
623      * <code>false</code> otherwise.
624      * @since DOM Level 2
625      *
626      */

627     public boolean hasAttributes() {
628         return this.document.hasAttributes();
629     }
630
631     /** Returns whether this node has any children.
632      * @return <code>true</code> if this node has any children,
633      * <code>false</code> otherwise.
634      *
635      */

636     public boolean hasChildNodes() {
637         return this.document.hasChildNodes();
638     }
639
640     /** Imports a node from another document to this document. The returned
641      * node has no parent; (<code>parentNode</code> is <code>null</code>).
642      * The source node is not altered or removed from the original document;
643      * this method creates a new copy of the source node.
644      * <br>For all nodes, importing a node creates a node object owned by the
645      * importing document, with attribute values identical to the source
646      * node's <code>nodeName</code> and <code>nodeType</code>, plus the
647      * attributes related to namespaces (<code>prefix</code>,
648      * <code>localName</code>, and <code>namespaceURI</code>). As in the
649      * <code>cloneNode</code> operation on a <code>Node</code>, the source
650      * node is not altered.
651      * <br>Additional information is copied as appropriate to the
652      * <code>nodeType</code>, attempting to mirror the behavior expected if
653      * a fragment of XML or HTML source was copied from one document to
654      * another, recognizing that the two documents may have different DTDs
655      * in the XML case. The following list describes the specifics for each
656      * type of node.
657      * <dl>
658      * <dt>ATTRIBUTE_NODE</dt>
659      * <dd>The <code>ownerElement</code> attribute
660      * is set to <code>null</code> and the <code>specified</code> flag is
661      * set to <code>true</code> on the generated <code>Attr</code>. The
662      * descendants of the source <code>Attr</code> are recursively imported
663      * and the resulting nodes reassembled to form the corresponding subtree.
664      * Note that the <code>deep</code> parameter has no effect on
665      * <code>Attr</code> nodes; they always carry their children with them
666      * when imported.</dd>
667      * <dt>DOCUMENT_FRAGMENT_NODE</dt>
668      * <dd>If the <code>deep</code> option
669      * was set to <code>true</code>, the descendants of the source element
670      * are recursively imported and the resulting nodes reassembled to form
671      * the corresponding subtree. Otherwise, this simply generates an empty
672      * <code>DocumentFragment</code>.</dd>
673      * <dt>DOCUMENT_NODE</dt>
674      * <dd><code>Document</code>
675      * nodes cannot be imported.</dd>
676      * <dt>DOCUMENT_TYPE_NODE</dt>
677      * <dd><code>DocumentType</code>
678      * nodes cannot be imported.</dd>
679      * <dt>ELEMENT_NODE</dt>
680      * <dd>Specified attribute nodes of the
681      * source element are imported, and the generated <code>Attr</code>
682      * nodes are attached to the generated <code>Element</code>. Default
683      * attributes are not copied, though if the document being imported into
684      * defines default attributes for this element name, those are assigned.
685      * If the <code>importNode</code> <code>deep</code> parameter was set to
686      * <code>true</code>, the descendants of the source element are
687      * recursively imported and the resulting nodes reassembled to form the
688      * corresponding subtree.</dd>
689      * <dt>ENTITY_NODE</dt>
690      * <dd><code>Entity</code> nodes can be
691      * imported, however in the current release of the DOM the
692      * <code>DocumentType</code> is readonly. Ability to add these imported
693      * nodes to a <code>DocumentType</code> will be considered for addition
694      * to a future release of the DOM.On import, the <code>publicId</code>,
695      * <code>systemId</code>, and <code>notationName</code> attributes are
696      * copied. If a <code>deep</code> import is requested, the descendants
697      * of the the source <code>Entity</code> are recursively imported and
698      * the resulting nodes reassembled to form the corresponding subtree.</dd>
699      * <dt>
700      * ENTITY_REFERENCE_NODE</dt>
701      * <dd>Only the <code>EntityReference</code> itself is
702      * copied, even if a <code>deep</code> import is requested, since the
703      * source and destination documents might have defined the entity
704      * differently. If the document being imported into provides a
705      * definition for this entity name, its value is assigned.</dd>
706      * <dt>NOTATION_NODE</dt>
707      * <dd>
708      * <code>Notation</code> nodes can be imported, however in the current
709      * release of the DOM the <code>DocumentType</code> is readonly. Ability
710      * to add these imported nodes to a <code>DocumentType</code> will be
711      * considered for addition to a future release of the DOM.On import, the
712      * <code>publicId</code> and <code>systemId</code> attributes are copied.
713      * Note that the <code>deep</code> parameter has no effect on
714      * <code>Notation</code> nodes since they never have any children.</dd>
715      * <dt>
716      * PROCESSING_INSTRUCTION_NODE</dt>
717      * <dd>The imported node copies its
718      * <code>target</code> and <code>data</code> values from those of the
719      * source node.</dd>
720      * <dt>TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE</dt>
721      * <dd>These three
722      * types of nodes inheriting from <code>CharacterData</code> copy their
723      * <code>data</code> and <code>length</code> attributes from those of
724      * the source node.</dd>
725      * </dl>
726      * @param importedNode The node to import.
727      * @param deep If <code>true</code>, recursively import the subtree under
728      * the specified node; if <code>false</code>, import only the node
729      * itself, as explained above. This has no effect on <code>Attr</code>
730      * , <code>EntityReference</code>, and <code>Notation</code> nodes.
731      * @return The imported node that belongs to this <code>Document</code>.
732      * @exception DOMException
733      * NOT_SUPPORTED_ERR: Raised if the type of node being imported is not
734      * supported.
735      * @since DOM Level 2
736      *
737      */

738     public Node JavaDoc importNode(Node JavaDoc importedNode, boolean deep) throws DOMException JavaDoc {
739         return this.document.importNode(importedNode, deep);
740     }
741
742     /** Inserts the node <code>newChild</code> before the existing child node
743      * <code>refChild</code>. If <code>refChild</code> is <code>null</code>,
744      * insert <code>newChild</code> at the end of the list of children.
745      * <br>If <code>newChild</code> is a <code>DocumentFragment</code> object,
746      * all of its children are inserted, in the same order, before
747      * <code>refChild</code>. If the <code>newChild</code> is already in the
748      * tree, it is first removed.
749      * @param newChild The node to insert.
750      * @param refChild The reference node, i.e., the node before which the
751      * new node must be inserted.
752      * @return The node being inserted.
753      * @exception DOMException
754      * HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
755      * allow children of the type of the <code>newChild</code> node, or if
756      * the node to insert is one of this node's ancestors or this node
757      * itself.
758      * <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created
759      * from a different document than the one that created this node.
760      * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or
761      * if the parent of the node being inserted is readonly.
762      * <br>NOT_FOUND_ERR: Raised if <code>refChild</code> is not a child of
763      * this node.
764      *
765      */

766     public Node JavaDoc insertBefore(Node JavaDoc newChild, Node JavaDoc refChild) throws DOMException JavaDoc {
767         return this.document.insertBefore(newChild, refChild);
768     }
769
770     /** Tests whether the DOM implementation implements a specific feature and
771      * that feature is supported by this node.
772      * @param feature The name of the feature to test. This is the same name
773      * which can be passed to the method <code>hasFeature</code> on
774      * <code>DOMImplementation</code>.
775      * @param version This is the version number of the feature to test. In
776      * Level 2, version 1, this is the string "2.0". If the version is not
777      * specified, supporting any version of the feature will cause the
778      * method to return <code>true</code>.
779      * @return Returns <code>true</code> if the specified feature is
780      * supported on this node, <code>false</code> otherwise.
781      * @since DOM Level 2
782      *
783      */

784     public boolean isSupported(String JavaDoc feature, String JavaDoc version) {
785         return this.document.isSupported(feature, version);
786     }
787
788     /** Puts all <code>Text</code> nodes in the full depth of the sub-tree
789      * underneath this <code>Node</code>, including attribute nodes, into a
790      * "normal" form where only structure (e.g., elements, comments,
791      * processing instructions, CDATA sections, and entity references)
792      * separates <code>Text</code> nodes, i.e., there are neither adjacent
793      * <code>Text</code> nodes nor empty <code>Text</code> nodes. This can
794      * be used to ensure that the DOM view of a document is the same as if
795      * it were saved and re-loaded, and is useful when operations (such as
796      * XPointer lookups) that depend on a particular document tree
797      * structure are to be used.In cases where the document contains
798      * <code>CDATASections</code>, the normalize operation alone may not be
799      * sufficient, since XPointers do not differentiate between
800      * <code>Text</code> nodes and <code>CDATASection</code> nodes.
801      * @since DOM Level 2
802      *
803      */

804     public void normalize() {
805         this.document.normalize();
806     }
807
808     /** Removes the child node indicated by <code>oldChild</code> from the list
809      * of children, and returns it.
810      * @param oldChild The node being removed.
811      * @return The node removed.
812      * @exception DOMException
813      * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
814      * <br>NOT_FOUND_ERR: Raised if <code>oldChild</code> is not a child of
815      * this node.
816      *
817      */

818     public Node JavaDoc removeChild(Node JavaDoc oldChild) throws DOMException JavaDoc {
819         return this.document.removeChild(oldChild);
820     }
821
822     /** Replaces the child node <code>oldChild</code> with <code>newChild</code>
823      * in the list of children, and returns the <code>oldChild</code> node.
824      * <br>If <code>newChild</code> is a <code>DocumentFragment</code> object,
825      * <code>oldChild</code> is replaced by all of the
826      * <code>DocumentFragment</code> children, which are inserted in the
827      * same order. If the <code>newChild</code> is already in the tree, it
828      * is first removed.
829      * @param newChild The new node to put in the child list.
830      * @param oldChild The node being replaced in the list.
831      * @return The node replaced.
832      * @exception DOMException
833      * HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
834      * allow children of the type of the <code>newChild</code> node, or if
835      * the node to put in is one of this node's ancestors or this node
836      * itself.
837      * <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created
838      * from a different document than the one that created this node.
839      * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the parent of
840      * the new node is readonly.
841      * <br>NOT_FOUND_ERR: Raised if <code>oldChild</code> is not a child of
842      * this node.
843      *
844      */

845     public Node JavaDoc replaceChild(Node JavaDoc newChild, Node JavaDoc oldChild) throws DOMException JavaDoc {
846         return this.document.replaceChild(newChild, oldChild);
847     }
848
849     /** The value of this node, depending on its type; see the table above.
850      * When it is defined to be <code>null</code>, setting it has no effect.
851      * @exception DOMException
852      * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
853      * DOMSTRING_SIZE_ERR: Raised when it would return more characters than
854      * fit in a <code>DOMString</code> variable on the implementation
855      * platform.
856      *
857      */

858     public void setNodeValue(String JavaDoc nodeValue) throws DOMException JavaDoc {
859         this.document.setNodeValue(nodeValue);
860     }
861
862     /** The namespace prefix of this node, or <code>null</code> if it is
863      * unspecified.
864      * <br>Note that setting this attribute, when permitted, changes the
865      * <code>nodeName</code> attribute, which holds the qualified name, as
866      * well as the <code>tagName</code> and <code>name</code> attributes of
867      * the <code>Element</code> and <code>Attr</code> interfaces, when
868      * applicable.
869      * <br>Note also that changing the prefix of an attribute that is known to
870      * have a default value, does not make a new attribute with the default
871      * value and the original prefix appear, since the
872      * <code>namespaceURI</code> and <code>localName</code> do not change.
873      * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and
874      * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1
875      * method, such as <code>createElement</code> from the
876      * <code>Document</code> interface, this is always <code>null</code>.
877      * @exception DOMException
878      * INVALID_CHARACTER_ERR: Raised if the specified prefix contains an
879      * illegal character, per the XML 1.0 specification .
880      * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
881      * <br>NAMESPACE_ERR: Raised if the specified <code>prefix</code> is
882      * malformed per the Namespaces in XML specification, if the
883      * <code>namespaceURI</code> of this node is <code>null</code>, if the
884      * specified prefix is "xml" and the <code>namespaceURI</code> of this
885      * node is different from "http://www.w3.org/XML/1998/namespace", if
886      * this node is an attribute and the specified prefix is "xmlns" and
887      * the <code>namespaceURI</code> of this node is different from "
888      * http://www.w3.org/2000/xmlns/", or if this node is an attribute and
889      * the <code>qualifiedName</code> of this node is "xmlns" .
890      * @since DOM Level 2
891      *
892      */

893     public void setPrefix(String JavaDoc prefix) throws DOMException JavaDoc {
894         this.document.setPrefix(prefix);
895     }
896     
897     /**
898      * @since DOM Level 3
899      */

900     public Node JavaDoc renameNode(Node JavaDoc node, String JavaDoc namespaceURI, String JavaDoc qualifiedName) throws DOMException JavaDoc {
901         throw new UnsupportedOperationException JavaDoc(DOMLEVEL3_ERR_MSG);
902     }
903
904     /**
905      * @since DOM Level 3
906      */

907     public void normalizeDocument() {
908         throw new UnsupportedOperationException JavaDoc(DOMLEVEL3_ERR_MSG);
909     }
910
911     /**
912      * @since DOM Level 3
913      */

914     public DOMConfiguration JavaDoc getDomConfig() {
915         throw new UnsupportedOperationException JavaDoc(DOMLEVEL3_ERR_MSG);
916     }
917
918     /**
919      * @since DOM Level 3
920      */

921     public Node JavaDoc adoptNode(Node JavaDoc source) {
922         throw new UnsupportedOperationException JavaDoc(DOMLEVEL3_ERR_MSG);
923     }
924
925     /**
926      * @since DOM Level 3
927      */

928     public void setDocumentURI(String JavaDoc uri) {
929         throw new UnsupportedOperationException JavaDoc(DOMLEVEL3_ERR_MSG);
930     }
931
932     /**
933      * @since DOM Level 3
934      */

935     public String JavaDoc getDocumentURI() {
936         throw new UnsupportedOperationException JavaDoc(DOMLEVEL3_ERR_MSG);
937     }
938
939     /**
940      * @since DOM Level 3
941      */

942     public void setStrictErrorChecking(boolean value) {
943         throw new UnsupportedOperationException JavaDoc(DOMLEVEL3_ERR_MSG);
944     }
945
946     /**
947      * @since DOM Level 3
948      */

949     public boolean getStrictErrorChecking() {
950         throw new UnsupportedOperationException JavaDoc(DOMLEVEL3_ERR_MSG);
951     }
952
953     /**
954      * @since DOM Level 3
955      */

956     public void setXmlVersion(String JavaDoc version) {
957         throw new UnsupportedOperationException JavaDoc(DOMLEVEL3_ERR_MSG);
958     }
959
960     /**
961      * @since DOM Level 3
962      */

963     public String JavaDoc getXmlVersion() {
964         throw new UnsupportedOperationException JavaDoc(DOMLEVEL3_ERR_MSG);
965     }
966
967     /**
968      * @since DOM Level 3
969      */

970     public void setXmlStandalone(boolean value) {
971         throw new UnsupportedOperationException JavaDoc(DOMLEVEL3_ERR_MSG);
972     }
973
974     /**
975      * @since DOM Level 3
976      */

977     public boolean getXmlStandalone() {
978         throw new UnsupportedOperationException JavaDoc(DOMLEVEL3_ERR_MSG);
979     }
980     
981     /**
982      * @since DOM Level 3
983      */

984     public void setXmlEncoding(String JavaDoc version) {
985         throw new UnsupportedOperationException JavaDoc(DOMLEVEL3_ERR_MSG);
986     }
987
988     /**
989      * @since DOM Level 3
990      */

991     public String JavaDoc getXmlEncoding() {
992         throw new UnsupportedOperationException JavaDoc(DOMLEVEL3_ERR_MSG);
993     }
994
995     /**
996      * @since DOM Level 3
997      */

998     public String JavaDoc getInputEncoding() {
999         throw new UnsupportedOperationException JavaDoc(DOMLEVEL3_ERR_MSG);
1000    }
1001
1002    /**
1003     * @since DOM Level 3
1004     */

1005    public Object JavaDoc getUserData(String JavaDoc key) {
1006        throw new UnsupportedOperationException JavaDoc(DOMLEVEL3_ERR_MSG);
1007    }
1008
1009    /**
1010     * @since DOM Level 3
1011     */

1012    public Object JavaDoc setUserData(String JavaDoc key, Object JavaDoc value, UserDataHandler JavaDoc handler) {
1013        throw new UnsupportedOperationException JavaDoc(DOMLEVEL3_ERR_MSG);
1014    }
1015    
1016    /**
1017     * @since DOM Level 3
1018     */

1019    public Object JavaDoc getFeature(String JavaDoc feature, String JavaDoc version) {
1020        throw new UnsupportedOperationException JavaDoc(DOMLEVEL3_ERR_MSG);
1021    }
1022
1023    /**
1024     * @since DOM Level 3
1025     */

1026    public short compareDocumentPosition(Node JavaDoc other) throws DOMException JavaDoc {
1027        throw new UnsupportedOperationException JavaDoc(DOMLEVEL3_ERR_MSG);
1028    }
1029
1030    /**
1031     * @since DOM Level 3
1032     */

1033    public String JavaDoc getBaseURI() {
1034        throw new UnsupportedOperationException JavaDoc(DOMLEVEL3_ERR_MSG);
1035    }
1036
1037    /**
1038     * @since DOM Level 3
1039     */

1040    public String JavaDoc getTextContent() throws DOMException JavaDoc {
1041        throw new UnsupportedOperationException JavaDoc(DOMLEVEL3_ERR_MSG);
1042    }
1043
1044    /**
1045     * @since DOM Level 3
1046     */

1047    public boolean isDefaultNamespace(String JavaDoc namespaceURI) {
1048        throw new UnsupportedOperationException JavaDoc(DOMLEVEL3_ERR_MSG);
1049    }
1050
1051    /**
1052     * @since DOM Level 3
1053     */

1054    public boolean isEqualNode(Node JavaDoc arg) {
1055        throw new UnsupportedOperationException JavaDoc(DOMLEVEL3_ERR_MSG);
1056    }
1057
1058    /**
1059     * @since DOM Level 3
1060     */

1061    public boolean isSameNode(Node JavaDoc other) {
1062        throw new UnsupportedOperationException JavaDoc(DOMLEVEL3_ERR_MSG);
1063    }
1064
1065    /**
1066     * @since DOM Level 3
1067     */

1068    public String JavaDoc lookupNamespaceURI(String JavaDoc prefix) {
1069        throw new UnsupportedOperationException JavaDoc(DOMLEVEL3_ERR_MSG);
1070    }
1071
1072    /**
1073     * @since DOM Level 3
1074     */

1075    public String JavaDoc lookupPrefix(String JavaDoc namespaceURI) {
1076        throw new UnsupportedOperationException JavaDoc(DOMLEVEL3_ERR_MSG);
1077    }
1078
1079    /**
1080     * @since DOM Level 3
1081     */

1082    public void setTextContent(String JavaDoc textContent) throws DOMException JavaDoc {
1083        throw new UnsupportedOperationException JavaDoc(DOMLEVEL3_ERR_MSG);
1084    }
1085}
1086
Popular Tags