Path: blob/aarch64-shenandoah-jdk8u272-b10/jaxp/src/org/w3c/dom/Node.java
86409 views
/*1* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.2*3* This code is free software; you can redistribute it and/or modify it4* under the terms of the GNU General Public License version 2 only, as5* published by the Free Software Foundation. Oracle designates this6* particular file as subject to the "Classpath" exception as provided7* by Oracle in the LICENSE file that accompanied this code.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*/2324/*25* This file is available under and governed by the GNU General Public26* License version 2 only, as published by the Free Software Foundation.27* However, the following notice accompanied the original version of this28* file and, per its terms, should not be removed:29*30* Copyright (c) 2004 World Wide Web Consortium,31*32* (Massachusetts Institute of Technology, European Research Consortium for33* Informatics and Mathematics, Keio University). All Rights Reserved. This34* work is distributed under the W3C(r) Software License [1] in the hope that35* it will be useful, but WITHOUT ANY WARRANTY; without even the implied36* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.37*38* [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-2002123139*/4041package org.w3c.dom;4243/**44* The <code>Node</code> interface is the primary datatype for the entire45* Document Object Model. It represents a single node in the document tree.46* While all objects implementing the <code>Node</code> interface expose47* methods for dealing with children, not all objects implementing the48* <code>Node</code> interface may have children. For example,49* <code>Text</code> nodes may not have children, and adding children to50* such nodes results in a <code>DOMException</code> being raised.51* <p>The attributes <code>nodeName</code>, <code>nodeValue</code> and52* <code>attributes</code> are included as a mechanism to get at node53* information without casting down to the specific derived interface. In54* cases where there is no obvious mapping of these attributes for a55* specific <code>nodeType</code> (e.g., <code>nodeValue</code> for an56* <code>Element</code> or <code>attributes</code> for a <code>Comment</code>57* ), this returns <code>null</code>. Note that the specialized interfaces58* may contain additional and more convenient mechanisms to get and set the59* relevant information.60* <p>The values of <code>nodeName</code>,61* <code>nodeValue</code>, and <code>attributes</code> vary according to the62* node type as follows:63* <table border='1' cellpadding='3'>64* <tr>65* <th>Interface</th>66* <th>nodeName</th>67* <th>nodeValue</th>68* <th>attributes</th>69* </tr>70* <tr>71* <td valign='top' rowspan='1' colspan='1'>72* <code>Attr</code></td>73* <td valign='top' rowspan='1' colspan='1'>same as <code>Attr.name</code></td>74* <td valign='top' rowspan='1' colspan='1'>same as75* <code>Attr.value</code></td>76* <td valign='top' rowspan='1' colspan='1'><code>null</code></td>77* </tr>78* <tr>79* <td valign='top' rowspan='1' colspan='1'><code>CDATASection</code></td>80* <td valign='top' rowspan='1' colspan='1'>81* <code>"#cdata-section"</code></td>82* <td valign='top' rowspan='1' colspan='1'>same as <code>CharacterData.data</code>, the83* content of the CDATA Section</td>84* <td valign='top' rowspan='1' colspan='1'><code>null</code></td>85* </tr>86* <tr>87* <td valign='top' rowspan='1' colspan='1'><code>Comment</code></td>88* <td valign='top' rowspan='1' colspan='1'>89* <code>"#comment"</code></td>90* <td valign='top' rowspan='1' colspan='1'>same as <code>CharacterData.data</code>, the91* content of the comment</td>92* <td valign='top' rowspan='1' colspan='1'><code>null</code></td>93* </tr>94* <tr>95* <td valign='top' rowspan='1' colspan='1'><code>Document</code></td>96* <td valign='top' rowspan='1' colspan='1'>97* <code>"#document"</code></td>98* <td valign='top' rowspan='1' colspan='1'><code>null</code></td>99* <td valign='top' rowspan='1' colspan='1'><code>null</code></td>100* </tr>101* <tr>102* <td valign='top' rowspan='1' colspan='1'>103* <code>DocumentFragment</code></td>104* <td valign='top' rowspan='1' colspan='1'><code>"#document-fragment"</code></td>105* <td valign='top' rowspan='1' colspan='1'>106* <code>null</code></td>107* <td valign='top' rowspan='1' colspan='1'><code>null</code></td>108* </tr>109* <tr>110* <td valign='top' rowspan='1' colspan='1'><code>DocumentType</code></td>111* <td valign='top' rowspan='1' colspan='1'>same as112* <code>DocumentType.name</code></td>113* <td valign='top' rowspan='1' colspan='1'><code>null</code></td>114* <td valign='top' rowspan='1' colspan='1'><code>null</code></td>115* </tr>116* <tr>117* <td valign='top' rowspan='1' colspan='1'>118* <code>Element</code></td>119* <td valign='top' rowspan='1' colspan='1'>same as <code>Element.tagName</code></td>120* <td valign='top' rowspan='1' colspan='1'><code>null</code></td>121* <td valign='top' rowspan='1' colspan='1'>122* <code>NamedNodeMap</code></td>123* </tr>124* <tr>125* <td valign='top' rowspan='1' colspan='1'><code>Entity</code></td>126* <td valign='top' rowspan='1' colspan='1'>entity name</td>127* <td valign='top' rowspan='1' colspan='1'><code>null</code></td>128* <td valign='top' rowspan='1' colspan='1'>129* <code>null</code></td>130* </tr>131* <tr>132* <td valign='top' rowspan='1' colspan='1'><code>EntityReference</code></td>133* <td valign='top' rowspan='1' colspan='1'>name of entity referenced</td>134* <td valign='top' rowspan='1' colspan='1'>135* <code>null</code></td>136* <td valign='top' rowspan='1' colspan='1'><code>null</code></td>137* </tr>138* <tr>139* <td valign='top' rowspan='1' colspan='1'><code>Notation</code></td>140* <td valign='top' rowspan='1' colspan='1'>notation name</td>141* <td valign='top' rowspan='1' colspan='1'>142* <code>null</code></td>143* <td valign='top' rowspan='1' colspan='1'><code>null</code></td>144* </tr>145* <tr>146* <td valign='top' rowspan='1' colspan='1'><code>ProcessingInstruction</code></td>147* <td valign='top' rowspan='1' colspan='1'>same148* as <code>ProcessingInstruction.target</code></td>149* <td valign='top' rowspan='1' colspan='1'>same as150* <code>ProcessingInstruction.data</code></td>151* <td valign='top' rowspan='1' colspan='1'><code>null</code></td>152* </tr>153* <tr>154* <td valign='top' rowspan='1' colspan='1'><code>Text</code></td>155* <td valign='top' rowspan='1' colspan='1'>156* <code>"#text"</code></td>157* <td valign='top' rowspan='1' colspan='1'>same as <code>CharacterData.data</code>, the content158* of the text node</td>159* <td valign='top' rowspan='1' colspan='1'><code>null</code></td>160* </tr>161* </table>162* <p>See also the <a href='http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407'>Document Object Model (DOM) Level 3 Core Specification</a>.163*/164public interface Node {165// NodeType166/**167* The node is an <code>Element</code>.168*/169public static final short ELEMENT_NODE = 1;170/**171* The node is an <code>Attr</code>.172*/173public static final short ATTRIBUTE_NODE = 2;174/**175* The node is a <code>Text</code> node.176*/177public static final short TEXT_NODE = 3;178/**179* The node is a <code>CDATASection</code>.180*/181public static final short CDATA_SECTION_NODE = 4;182/**183* The node is an <code>EntityReference</code>.184*/185public static final short ENTITY_REFERENCE_NODE = 5;186/**187* The node is an <code>Entity</code>.188*/189public static final short ENTITY_NODE = 6;190/**191* The node is a <code>ProcessingInstruction</code>.192*/193public static final short PROCESSING_INSTRUCTION_NODE = 7;194/**195* The node is a <code>Comment</code>.196*/197public static final short COMMENT_NODE = 8;198/**199* The node is a <code>Document</code>.200*/201public static final short DOCUMENT_NODE = 9;202/**203* The node is a <code>DocumentType</code>.204*/205public static final short DOCUMENT_TYPE_NODE = 10;206/**207* The node is a <code>DocumentFragment</code>.208*/209public static final short DOCUMENT_FRAGMENT_NODE = 11;210/**211* The node is a <code>Notation</code>.212*/213public static final short NOTATION_NODE = 12;214215/**216* The name of this node, depending on its type; see the table above.217*/218public String getNodeName();219220/**221* The value of this node, depending on its type; see the table above.222* When it is defined to be <code>null</code>, setting it has no effect,223* including if the node is read-only.224* @exception DOMException225* DOMSTRING_SIZE_ERR: Raised when it would return more characters than226* fit in a <code>DOMString</code> variable on the implementation227* platform.228*/229public String getNodeValue()230throws DOMException;231/**232* The value of this node, depending on its type; see the table above.233* When it is defined to be <code>null</code>, setting it has no effect,234* including if the node is read-only.235* @exception DOMException236* NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly and if237* it is not defined to be <code>null</code>.238*/239public void setNodeValue(String nodeValue)240throws DOMException;241242/**243* A code representing the type of the underlying object, as defined above.244*/245public short getNodeType();246247/**248* The parent of this node. All nodes, except <code>Attr</code>,249* <code>Document</code>, <code>DocumentFragment</code>,250* <code>Entity</code>, and <code>Notation</code> may have a parent.251* However, if a node has just been created and not yet added to the252* tree, or if it has been removed from the tree, this is253* <code>null</code>.254*/255public Node getParentNode();256257/**258* A <code>NodeList</code> that contains all children of this node. If259* there are no children, this is a <code>NodeList</code> containing no260* nodes.261*/262public NodeList getChildNodes();263264/**265* The first child of this node. If there is no such node, this returns266* <code>null</code>.267*/268public Node getFirstChild();269270/**271* The last child of this node. If there is no such node, this returns272* <code>null</code>.273*/274public Node getLastChild();275276/**277* The node immediately preceding this node. If there is no such node,278* this returns <code>null</code>.279*/280public Node getPreviousSibling();281282/**283* The node immediately following this node. If there is no such node,284* this returns <code>null</code>.285*/286public Node getNextSibling();287288/**289* A <code>NamedNodeMap</code> containing the attributes of this node (if290* it is an <code>Element</code>) or <code>null</code> otherwise.291*/292public NamedNodeMap getAttributes();293294/**295* The <code>Document</code> object associated with this node. This is296* also the <code>Document</code> object used to create new nodes. When297* this node is a <code>Document</code> or a <code>DocumentType</code>298* which is not used with any <code>Document</code> yet, this is299* <code>null</code>.300*301* @since DOM Level 2302*/303public Document getOwnerDocument();304305/**306* Inserts the node <code>newChild</code> before the existing child node307* <code>refChild</code>. If <code>refChild</code> is <code>null</code>,308* insert <code>newChild</code> at the end of the list of children.309* <br>If <code>newChild</code> is a <code>DocumentFragment</code> object,310* all of its children are inserted, in the same order, before311* <code>refChild</code>. If the <code>newChild</code> is already in the312* tree, it is first removed.313* <p ><b>Note:</b> Inserting a node before itself is implementation314* dependent.315* @param newChild The node to insert.316* @param refChild The reference node, i.e., the node before which the317* new node must be inserted.318* @return The node being inserted.319* @exception DOMException320* HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not321* allow children of the type of the <code>newChild</code> node, or if322* the node to insert is one of this node's ancestors or this node323* itself, or if this node is of type <code>Document</code> and the324* DOM application attempts to insert a second325* <code>DocumentType</code> or <code>Element</code> node.326* <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created327* from a different document than the one that created this node.328* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or329* if the parent of the node being inserted is readonly.330* <br>NOT_FOUND_ERR: Raised if <code>refChild</code> is not a child of331* this node.332* <br>NOT_SUPPORTED_ERR: if this node is of type <code>Document</code>,333* this exception might be raised if the DOM implementation doesn't334* support the insertion of a <code>DocumentType</code> or335* <code>Element</code> node.336*337* @since DOM Level 3338*/339public Node insertBefore(Node newChild,340Node refChild)341throws DOMException;342343/**344* Replaces the child node <code>oldChild</code> with <code>newChild</code>345* in the list of children, and returns the <code>oldChild</code> node.346* <br>If <code>newChild</code> is a <code>DocumentFragment</code> object,347* <code>oldChild</code> is replaced by all of the348* <code>DocumentFragment</code> children, which are inserted in the349* same order. If the <code>newChild</code> is already in the tree, it350* is first removed.351* <p ><b>Note:</b> Replacing a node with itself is implementation352* dependent.353* @param newChild The new node to put in the child list.354* @param oldChild The node being replaced in the list.355* @return The node replaced.356* @exception DOMException357* HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not358* allow children of the type of the <code>newChild</code> node, or if359* the node to put in is one of this node's ancestors or this node360* itself, or if this node is of type <code>Document</code> and the361* result of the replacement operation would add a second362* <code>DocumentType</code> or <code>Element</code> on the363* <code>Document</code> node.364* <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created365* from a different document than the one that created this node.366* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the parent of367* the new node is readonly.368* <br>NOT_FOUND_ERR: Raised if <code>oldChild</code> is not a child of369* this node.370* <br>NOT_SUPPORTED_ERR: if this node is of type <code>Document</code>,371* this exception might be raised if the DOM implementation doesn't372* support the replacement of the <code>DocumentType</code> child or373* <code>Element</code> child.374*375* @since DOM Level 3376*/377public Node replaceChild(Node newChild,378Node oldChild)379throws DOMException;380381/**382* Removes the child node indicated by <code>oldChild</code> from the list383* of children, and returns it.384* @param oldChild The node being removed.385* @return The node removed.386* @exception DOMException387* NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.388* <br>NOT_FOUND_ERR: Raised if <code>oldChild</code> is not a child of389* this node.390* <br>NOT_SUPPORTED_ERR: if this node is of type <code>Document</code>,391* this exception might be raised if the DOM implementation doesn't392* support the removal of the <code>DocumentType</code> child or the393* <code>Element</code> child.394*395* @since DOM Level 3396*/397public Node removeChild(Node oldChild)398throws DOMException;399400/**401* Adds the node <code>newChild</code> to the end of the list of children402* of this node. If the <code>newChild</code> is already in the tree, it403* is first removed.404* @param newChild The node to add.If it is a405* <code>DocumentFragment</code> object, the entire contents of the406* document fragment are moved into the child list of this node407* @return The node added.408* @exception DOMException409* HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not410* allow children of the type of the <code>newChild</code> node, or if411* the node to append is one of this node's ancestors or this node412* itself, or if this node is of type <code>Document</code> and the413* DOM application attempts to append a second414* <code>DocumentType</code> or <code>Element</code> node.415* <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created416* from a different document than the one that created this node.417* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or418* if the previous parent of the node being inserted is readonly.419* <br>NOT_SUPPORTED_ERR: if the <code>newChild</code> node is a child420* of the <code>Document</code> node, this exception might be raised421* if the DOM implementation doesn't support the removal of the422* <code>DocumentType</code> child or <code>Element</code> child.423*424* @since DOM Level 3425*/426public Node appendChild(Node newChild)427throws DOMException;428429/**430* Returns whether this node has any children.431* @return Returns <code>true</code> if this node has any children,432* <code>false</code> otherwise.433*/434public boolean hasChildNodes();435436/**437* Returns a duplicate of this node, i.e., serves as a generic copy438* constructor for nodes. The duplicate node has no parent (439* <code>parentNode</code> is <code>null</code>) and no user data. User440* data associated to the imported node is not carried over. However, if441* any <code>UserDataHandlers</code> has been specified along with the442* associated data these handlers will be called with the appropriate443* parameters before this method returns.444* <br>Cloning an <code>Element</code> copies all attributes and their445* values, including those generated by the XML processor to represent446* defaulted attributes, but this method does not copy any children it447* contains unless it is a deep clone. This includes text contained in448* an the <code>Element</code> since the text is contained in a child449* <code>Text</code> node. Cloning an <code>Attr</code> directly, as450* opposed to be cloned as part of an <code>Element</code> cloning451* operation, returns a specified attribute (<code>specified</code> is452* <code>true</code>). Cloning an <code>Attr</code> always clones its453* children, since they represent its value, no matter whether this is a454* deep clone or not. Cloning an <code>EntityReference</code>455* automatically constructs its subtree if a corresponding456* <code>Entity</code> is available, no matter whether this is a deep457* clone or not. Cloning any other type of node simply returns a copy of458* this node.459* <br>Note that cloning an immutable subtree results in a mutable copy,460* but the children of an <code>EntityReference</code> clone are readonly461* . In addition, clones of unspecified <code>Attr</code> nodes are462* specified. And, cloning <code>Document</code>,463* <code>DocumentType</code>, <code>Entity</code>, and464* <code>Notation</code> nodes is implementation dependent.465* @param deep If <code>true</code>, recursively clone the subtree under466* the specified node; if <code>false</code>, clone only the node467* itself (and its attributes, if it is an <code>Element</code>).468* @return The duplicate node.469*/470public Node cloneNode(boolean deep);471472/**473* Puts all <code>Text</code> nodes in the full depth of the sub-tree474* underneath this <code>Node</code>, including attribute nodes, into a475* "normal" form where only structure (e.g., elements, comments,476* processing instructions, CDATA sections, and entity references)477* separates <code>Text</code> nodes, i.e., there are neither adjacent478* <code>Text</code> nodes nor empty <code>Text</code> nodes. This can479* be used to ensure that the DOM view of a document is the same as if480* it were saved and re-loaded, and is useful when operations (such as481* XPointer [<a href='http://www.w3.org/TR/2003/REC-xptr-framework-20030325/'>XPointer</a>]482* lookups) that depend on a particular document tree structure are to483* be used. If the parameter "normalize-characters" of the484* <code>DOMConfiguration</code> object attached to the485* <code>Node.ownerDocument</code> is <code>true</code>, this method486* will also fully normalize the characters of the <code>Text</code>487* nodes.488* <p ><b>Note:</b> In cases where the document contains489* <code>CDATASections</code>, the normalize operation alone may not be490* sufficient, since XPointers do not differentiate between491* <code>Text</code> nodes and <code>CDATASection</code> nodes.492*493* @since DOM Level 3494*/495public void normalize();496497/**498* Tests whether the DOM implementation implements a specific feature and499* that feature is supported by this node, as specified in .500* @param feature The name of the feature to test.501* @param version This is the version number of the feature to test.502* @return Returns <code>true</code> if the specified feature is503* supported on this node, <code>false</code> otherwise.504*505* @since DOM Level 2506*/507public boolean isSupported(String feature,508String version);509510/**511* The namespace URI of this node, or <code>null</code> if it is512* unspecified (see ).513* <br>This is not a computed value that is the result of a namespace514* lookup based on an examination of the namespace declarations in515* scope. It is merely the namespace URI given at creation time.516* <br>For nodes of any type other than <code>ELEMENT_NODE</code> and517* <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1518* method, such as <code>Document.createElement()</code>, this is always519* <code>null</code>.520* <p ><b>Note:</b> Per the <em>Namespaces in XML</em> Specification [<a href='http://www.w3.org/TR/1999/REC-xml-names-19990114/'>XML Namespaces</a>]521* an attribute does not inherit its namespace from the element it is522* attached to. If an attribute is not explicitly given a namespace, it523* simply has no namespace.524*525* @since DOM Level 2526*/527public String getNamespaceURI();528529/**530* The namespace prefix of this node, or <code>null</code> if it is531* unspecified. When it is defined to be <code>null</code>, setting it532* has no effect, including if the node is read-only.533* <br>Note that setting this attribute, when permitted, changes the534* <code>nodeName</code> attribute, which holds the qualified name, as535* well as the <code>tagName</code> and <code>name</code> attributes of536* the <code>Element</code> and <code>Attr</code> interfaces, when537* applicable.538* <br>Setting the prefix to <code>null</code> makes it unspecified,539* setting it to an empty string is implementation dependent.540* <br>Note also that changing the prefix of an attribute that is known to541* have a default value, does not make a new attribute with the default542* value and the original prefix appear, since the543* <code>namespaceURI</code> and <code>localName</code> do not change.544* <br>For nodes of any type other than <code>ELEMENT_NODE</code> and545* <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1546* method, such as <code>createElement</code> from the547* <code>Document</code> interface, this is always <code>null</code>.548*549* @since DOM Level 2550*/551public String getPrefix();552/**553* The namespace prefix of this node, or <code>null</code> if it is554* unspecified. When it is defined to be <code>null</code>, setting it555* has no effect, including if the node is read-only.556* <br>Note that setting this attribute, when permitted, changes the557* <code>nodeName</code> attribute, which holds the qualified name, as558* well as the <code>tagName</code> and <code>name</code> attributes of559* the <code>Element</code> and <code>Attr</code> interfaces, when560* applicable.561* <br>Setting the prefix to <code>null</code> makes it unspecified,562* setting it to an empty string is implementation dependent.563* <br>Note also that changing the prefix of an attribute that is known to564* have a default value, does not make a new attribute with the default565* value and the original prefix appear, since the566* <code>namespaceURI</code> and <code>localName</code> do not change.567* <br>For nodes of any type other than <code>ELEMENT_NODE</code> and568* <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1569* method, such as <code>createElement</code> from the570* <code>Document</code> interface, this is always <code>null</code>.571* @exception DOMException572* INVALID_CHARACTER_ERR: Raised if the specified prefix contains an573* illegal character according to the XML version in use specified in574* the <code>Document.xmlVersion</code> attribute.575* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.576* <br>NAMESPACE_ERR: Raised if the specified <code>prefix</code> is577* malformed per the Namespaces in XML specification, if the578* <code>namespaceURI</code> of this node is <code>null</code>, if the579* specified prefix is "xml" and the <code>namespaceURI</code> of this580* node is different from "<a href='http://www.w3.org/XML/1998/namespace'>581* http://www.w3.org/XML/1998/namespace</a>", if this node is an attribute and the specified prefix is "xmlns" and582* the <code>namespaceURI</code> of this node is different from "<a href='http://www.w3.org/2000/xmlns/'>http://www.w3.org/2000/xmlns/</a>", or if this node is an attribute and the <code>qualifiedName</code> of583* this node is "xmlns" [<a href='http://www.w3.org/TR/1999/REC-xml-names-19990114/'>XML Namespaces</a>]584* .585*586* @since DOM Level 2587*/588public void setPrefix(String prefix)589throws DOMException;590591/**592* Returns the local part of the qualified name of this node.593* <br>For nodes of any type other than <code>ELEMENT_NODE</code> and594* <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1595* method, such as <code>Document.createElement()</code>, this is always596* <code>null</code>.597*598* @since DOM Level 2599*/600public String getLocalName();601602/**603* Returns whether this node (if it is an element) has any attributes.604* @return Returns <code>true</code> if this node has any attributes,605* <code>false</code> otherwise.606*607* @since DOM Level 2608*/609public boolean hasAttributes();610611/**612* The absolute base URI of this node or <code>null</code> if the613* implementation wasn't able to obtain an absolute URI. This value is614* computed as described in . However, when the <code>Document</code>615* supports the feature "HTML" [<a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>DOM Level 2 HTML</a>]616* , the base URI is computed using first the value of the href617* attribute of the HTML BASE element if any, and the value of the618* <code>documentURI</code> attribute from the <code>Document</code>619* interface otherwise.620*621* @since DOM Level 3622*/623public String getBaseURI();624625// DocumentPosition626/**627* The two nodes are disconnected. Order between disconnected nodes is628* always implementation-specific.629*/630public static final short DOCUMENT_POSITION_DISCONNECTED = 0x01;631/**632* The second node precedes the reference node.633*/634public static final short DOCUMENT_POSITION_PRECEDING = 0x02;635/**636* The node follows the reference node.637*/638public static final short DOCUMENT_POSITION_FOLLOWING = 0x04;639/**640* The node contains the reference node. A node which contains is always641* preceding, too.642*/643public static final short DOCUMENT_POSITION_CONTAINS = 0x08;644/**645* The node is contained by the reference node. A node which is contained646* is always following, too.647*/648public static final short DOCUMENT_POSITION_CONTAINED_BY = 0x10;649/**650* The determination of preceding versus following is651* implementation-specific.652*/653public static final short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20;654655/**656* Compares the reference node, i.e. the node on which this method is657* being called, with a node, i.e. the one passed as a parameter, with658* regard to their position in the document and according to the659* document order.660* @param other The node to compare against the reference node.661* @return Returns how the node is positioned relatively to the reference662* node.663* @exception DOMException664* NOT_SUPPORTED_ERR: when the compared nodes are from different DOM665* implementations that do not coordinate to return consistent666* implementation-specific results.667*668* @since DOM Level 3669*/670public short compareDocumentPosition(Node other)671throws DOMException;672673/**674* This attribute returns the text content of this node and its675* descendants. When it is defined to be <code>null</code>, setting it676* has no effect. On setting, any possible children this node may have677* are removed and, if it the new string is not empty or678* <code>null</code>, replaced by a single <code>Text</code> node679* containing the string this attribute is set to.680* <br> On getting, no serialization is performed, the returned string681* does not contain any markup. No whitespace normalization is performed682* and the returned string does not contain the white spaces in element683* content (see the attribute684* <code>Text.isElementContentWhitespace</code>). Similarly, on setting,685* no parsing is performed either, the input string is taken as pure686* textual content.687* <br>The string returned is made of the text content of this node688* depending on its type, as defined below:689* <table border='1' cellpadding='3'>690* <tr>691* <th>Node type</th>692* <th>Content</th>693* </tr>694* <tr>695* <td valign='top' rowspan='1' colspan='1'>696* ELEMENT_NODE, ATTRIBUTE_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE,697* DOCUMENT_FRAGMENT_NODE</td>698* <td valign='top' rowspan='1' colspan='1'>concatenation of the <code>textContent</code>699* attribute value of every child node, excluding COMMENT_NODE and700* PROCESSING_INSTRUCTION_NODE nodes. This is the empty string if the701* node has no children.</td>702* </tr>703* <tr>704* <td valign='top' rowspan='1' colspan='1'>TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE,705* PROCESSING_INSTRUCTION_NODE</td>706* <td valign='top' rowspan='1' colspan='1'><code>nodeValue</code></td>707* </tr>708* <tr>709* <td valign='top' rowspan='1' colspan='1'>DOCUMENT_NODE,710* DOCUMENT_TYPE_NODE, NOTATION_NODE</td>711* <td valign='top' rowspan='1' colspan='1'><em>null</em></td>712* </tr>713* </table>714* @exception DOMException715* DOMSTRING_SIZE_ERR: Raised when it would return more characters than716* fit in a <code>DOMString</code> variable on the implementation717* platform.718*719* @since DOM Level 3720*/721public String getTextContent()722throws DOMException;723/**724* This attribute returns the text content of this node and its725* descendants. When it is defined to be <code>null</code>, setting it726* has no effect. On setting, any possible children this node may have727* are removed and, if it the new string is not empty or728* <code>null</code>, replaced by a single <code>Text</code> node729* containing the string this attribute is set to.730* <br> On getting, no serialization is performed, the returned string731* does not contain any markup. No whitespace normalization is performed732* and the returned string does not contain the white spaces in element733* content (see the attribute734* <code>Text.isElementContentWhitespace</code>). Similarly, on setting,735* no parsing is performed either, the input string is taken as pure736* textual content.737* <br>The string returned is made of the text content of this node738* depending on its type, as defined below:739* <table border='1' cellpadding='3'>740* <tr>741* <th>Node type</th>742* <th>Content</th>743* </tr>744* <tr>745* <td valign='top' rowspan='1' colspan='1'>746* ELEMENT_NODE, ATTRIBUTE_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE,747* DOCUMENT_FRAGMENT_NODE</td>748* <td valign='top' rowspan='1' colspan='1'>concatenation of the <code>textContent</code>749* attribute value of every child node, excluding COMMENT_NODE and750* PROCESSING_INSTRUCTION_NODE nodes. This is the empty string if the751* node has no children.</td>752* </tr>753* <tr>754* <td valign='top' rowspan='1' colspan='1'>TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE,755* PROCESSING_INSTRUCTION_NODE</td>756* <td valign='top' rowspan='1' colspan='1'><code>nodeValue</code></td>757* </tr>758* <tr>759* <td valign='top' rowspan='1' colspan='1'>DOCUMENT_NODE,760* DOCUMENT_TYPE_NODE, NOTATION_NODE</td>761* <td valign='top' rowspan='1' colspan='1'><em>null</em></td>762* </tr>763* </table>764* @exception DOMException765* NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.766*767* @since DOM Level 3768*/769public void setTextContent(String textContent)770throws DOMException;771772/**773* Returns whether this node is the same node as the given one.774* <br>This method provides a way to determine whether two775* <code>Node</code> references returned by the implementation reference776* the same object. When two <code>Node</code> references are references777* to the same object, even if through a proxy, the references may be778* used completely interchangeably, such that all attributes have the779* same values and calling the same DOM method on either reference780* always has exactly the same effect.781* @param other The node to test against.782* @return Returns <code>true</code> if the nodes are the same,783* <code>false</code> otherwise.784*785* @since DOM Level 3786*/787public boolean isSameNode(Node other);788789/**790* Look up the prefix associated to the given namespace URI, starting from791* this node. The default namespace declarations are ignored by this792* method.793* <br>See for details on the algorithm used by this method.794* @param namespaceURI The namespace URI to look for.795* @return Returns an associated namespace prefix if found or796* <code>null</code> if none is found. If more than one prefix are797* associated to the namespace prefix, the returned namespace prefix798* is implementation dependent.799*800* @since DOM Level 3801*/802public String lookupPrefix(String namespaceURI);803804/**805* This method checks if the specified <code>namespaceURI</code> is the806* default namespace or not.807* @param namespaceURI The namespace URI to look for.808* @return Returns <code>true</code> if the specified809* <code>namespaceURI</code> is the default namespace,810* <code>false</code> otherwise.811*812* @since DOM Level 3813*/814public boolean isDefaultNamespace(String namespaceURI);815816/**817* Look up the namespace URI associated to the given prefix, starting from818* this node.819* <br>See for details on the algorithm used by this method.820* @param prefix The prefix to look for. If this parameter is821* <code>null</code>, the method will return the default namespace URI822* if any.823* @return Returns the associated namespace URI or <code>null</code> if824* none is found.825*826* @since DOM Level 3827*/828public String lookupNamespaceURI(String prefix);829830/**831* Tests whether two nodes are equal.832* <br>This method tests for equality of nodes, not sameness (i.e.,833* whether the two nodes are references to the same object) which can be834* tested with <code>Node.isSameNode()</code>. All nodes that are the835* same will also be equal, though the reverse may not be true.836* <br>Two nodes are equal if and only if the following conditions are837* satisfied:838* <ul>839* <li>The two nodes are of the same type.840* </li>841* <li>The following string842* attributes are equal: <code>nodeName</code>, <code>localName</code>,843* <code>namespaceURI</code>, <code>prefix</code>, <code>nodeValue</code>844* . This is: they are both <code>null</code>, or they have the same845* length and are character for character identical.846* </li>847* <li>The848* <code>attributes</code> <code>NamedNodeMaps</code> are equal. This849* is: they are both <code>null</code>, or they have the same length and850* for each node that exists in one map there is a node that exists in851* the other map and is equal, although not necessarily at the same852* index.853* </li>854* <li>The <code>childNodes</code> <code>NodeLists</code> are equal.855* This is: they are both <code>null</code>, or they have the same856* length and contain equal nodes at the same index. Note that857* normalization can affect equality; to avoid this, nodes should be858* normalized before being compared.859* </li>860* </ul>861* <br>For two <code>DocumentType</code> nodes to be equal, the following862* conditions must also be satisfied:863* <ul>864* <li>The following string attributes865* are equal: <code>publicId</code>, <code>systemId</code>,866* <code>internalSubset</code>.867* </li>868* <li>The <code>entities</code>869* <code>NamedNodeMaps</code> are equal.870* </li>871* <li>The <code>notations</code>872* <code>NamedNodeMaps</code> are equal.873* </li>874* </ul>875* <br>On the other hand, the following do not affect equality: the876* <code>ownerDocument</code>, <code>baseURI</code>, and877* <code>parentNode</code> attributes, the <code>specified</code>878* attribute for <code>Attr</code> nodes, the <code>schemaTypeInfo</code>879* attribute for <code>Attr</code> and <code>Element</code> nodes, the880* <code>Text.isElementContentWhitespace</code> attribute for881* <code>Text</code> nodes, as well as any user data or event listeners882* registered on the nodes.883* <p ><b>Note:</b> As a general rule, anything not mentioned in the884* description above is not significant in consideration of equality885* checking. Note that future versions of this specification may take886* into account more attributes and implementations conform to this887* specification are expected to be updated accordingly.888* @param arg The node to compare equality with.889* @return Returns <code>true</code> if the nodes are equal,890* <code>false</code> otherwise.891*892* @since DOM Level 3893*/894public boolean isEqualNode(Node arg);895896/**897* This method returns a specialized object which implements the898* specialized APIs of the specified feature and version, as specified899* in . The specialized object may also be obtained by using900* binding-specific casting methods but is not necessarily expected to,901* as discussed in . This method also allow the implementation to902* provide specialized objects which do not support the <code>Node</code>903* interface.904* @param feature The name of the feature requested. Note that any plus905* sign "+" prepended to the name of the feature will be ignored since906* it is not significant in the context of this method.907* @param version This is the version number of the feature to test.908* @return Returns an object which implements the specialized APIs of909* the specified feature and version, if any, or <code>null</code> if910* there is no object which implements interfaces associated with that911* feature. If the <code>DOMObject</code> returned by this method912* implements the <code>Node</code> interface, it must delegate to the913* primary core <code>Node</code> and not return results inconsistent914* with the primary core <code>Node</code> such as attributes,915* childNodes, etc.916*917* @since DOM Level 3918*/919public Object getFeature(String feature,920String version);921922/**923* Associate an object to a key on this node. The object can later be924* retrieved from this node by calling <code>getUserData</code> with the925* same key.926* @param key The key to associate the object to.927* @param data The object to associate to the given key, or928* <code>null</code> to remove any existing association to that key.929* @param handler The handler to associate to that key, or930* <code>null</code>.931* @return Returns the <code>DOMUserData</code> previously associated to932* the given key on this node, or <code>null</code> if there was none.933*934* @since DOM Level 3935*/936public Object setUserData(String key,937Object data,938UserDataHandler handler);939940/**941* Retrieves the object associated to a key on a this node. The object942* must first have been set to this node by calling943* <code>setUserData</code> with the same key.944* @param key The key the object is associated to.945* @return Returns the <code>DOMUserData</code> associated to the given946* key on this node, or <code>null</code> if there was none.947*948* @since DOM Level 3949*/950public Object getUserData(String key);951952}953954955