1 /* 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * 4 * This code is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License version 2 only, as 6 * published by the Free Software Foundation. Oracle designates this 7 * particular file as subject to the "Classpath" exception as provided 8 * by Oracle in the LICENSE file that accompanied this code. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 */ 24 25 /* 26 * This file is available under and governed by the GNU General Public 27 * License version 2 only, as published by the Free Software Foundation. 28 * However, the following notice accompanied the original version of this 29 * file and, per its terms, should not be removed: 30 * 31 * Copyright (c) 2004 World Wide Web Consortium, 32 * 33 * (Massachusetts Institute of Technology, European Research Consortium for 34 * Informatics and Mathematics, Keio University). All Rights Reserved. This 35 * work is distributed under the W3C(r) Software License [1] in the hope that 36 * it will be useful, but WITHOUT ANY WARRANTY; without even the implied 37 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 38 * 39 * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 40 */ 41 42 package org.w3c.dom; 43 44 /** 45 * The <code>Node</code> interface is the primary datatype for the entire 46 * Document Object Model. It represents a single node in the document tree. 47 * While all objects implementing the <code>Node</code> interface expose 48 * methods for dealing with children, not all objects implementing the 49 * <code>Node</code> interface may have children. For example, 50 * <code>Text</code> nodes may not have children, and adding children to 51 * such nodes results in a <code>DOMException</code> being raised. 52 * <p>The attributes <code>nodeName</code>, <code>nodeValue</code> and 53 * <code>attributes</code> are included as a mechanism to get at node 54 * information without casting down to the specific derived interface. In 55 * cases where there is no obvious mapping of these attributes for a 56 * specific <code>nodeType</code> (e.g., <code>nodeValue</code> for an 57 * <code>Element</code> or <code>attributes</code> for a <code>Comment</code> 58 * ), this returns <code>null</code>. Note that the specialized interfaces 59 * may contain additional and more convenient mechanisms to get and set the 60 * relevant information. 61 * <p>The values of <code>nodeName</code>, 62 * <code>nodeValue</code>, and <code>attributes</code> vary according to the 63 * node type as follows: 64 * <table border='1' cellpadding='3'> 65 * <tr> 66 * <th>Interface</th> 67 * <th>nodeName</th> 68 * <th>nodeValue</th> 69 * <th>attributes</th> 70 * </tr> 71 * <tr> 72 * <td valign='top' rowspan='1' colspan='1'> 73 * <code>Attr</code></td> 74 * <td valign='top' rowspan='1' colspan='1'>same as <code>Attr.name</code></td> 75 * <td valign='top' rowspan='1' colspan='1'>same as 76 * <code>Attr.value</code></td> 77 * <td valign='top' rowspan='1' colspan='1'><code>null</code></td> 78 * </tr> 79 * <tr> 80 * <td valign='top' rowspan='1' colspan='1'><code>CDATASection</code></td> 81 * <td valign='top' rowspan='1' colspan='1'> 82 * <code>"#cdata-section"</code></td> 83 * <td valign='top' rowspan='1' colspan='1'>same as <code>CharacterData.data</code>, the 84 * content of the CDATA Section</td> 85 * <td valign='top' rowspan='1' colspan='1'><code>null</code></td> 86 * </tr> 87 * <tr> 88 * <td valign='top' rowspan='1' colspan='1'><code>Comment</code></td> 89 * <td valign='top' rowspan='1' colspan='1'> 90 * <code>"#comment"</code></td> 91 * <td valign='top' rowspan='1' colspan='1'>same as <code>CharacterData.data</code>, the 92 * content of the comment</td> 93 * <td valign='top' rowspan='1' colspan='1'><code>null</code></td> 94 * </tr> 95 * <tr> 96 * <td valign='top' rowspan='1' colspan='1'><code>Document</code></td> 97 * <td valign='top' rowspan='1' colspan='1'> 98 * <code>"#document"</code></td> 99 * <td valign='top' rowspan='1' colspan='1'><code>null</code></td> 100 * <td valign='top' rowspan='1' colspan='1'><code>null</code></td> 101 * </tr> 102 * <tr> 103 * <td valign='top' rowspan='1' colspan='1'> 104 * <code>DocumentFragment</code></td> 105 * <td valign='top' rowspan='1' colspan='1'><code>"#document-fragment"</code></td> 106 * <td valign='top' rowspan='1' colspan='1'> 107 * <code>null</code></td> 108 * <td valign='top' rowspan='1' colspan='1'><code>null</code></td> 109 * </tr> 110 * <tr> 111 * <td valign='top' rowspan='1' colspan='1'><code>DocumentType</code></td> 112 * <td valign='top' rowspan='1' colspan='1'>same as 113 * <code>DocumentType.name</code></td> 114 * <td valign='top' rowspan='1' colspan='1'><code>null</code></td> 115 * <td valign='top' rowspan='1' colspan='1'><code>null</code></td> 116 * </tr> 117 * <tr> 118 * <td valign='top' rowspan='1' colspan='1'> 119 * <code>Element</code></td> 120 * <td valign='top' rowspan='1' colspan='1'>same as <code>Element.tagName</code></td> 121 * <td valign='top' rowspan='1' colspan='1'><code>null</code></td> 122 * <td valign='top' rowspan='1' colspan='1'> 123 * <code>NamedNodeMap</code></td> 124 * </tr> 125 * <tr> 126 * <td valign='top' rowspan='1' colspan='1'><code>Entity</code></td> 127 * <td valign='top' rowspan='1' colspan='1'>entity name</td> 128 * <td valign='top' rowspan='1' colspan='1'><code>null</code></td> 129 * <td valign='top' rowspan='1' colspan='1'> 130 * <code>null</code></td> 131 * </tr> 132 * <tr> 133 * <td valign='top' rowspan='1' colspan='1'><code>EntityReference</code></td> 134 * <td valign='top' rowspan='1' colspan='1'>name of entity referenced</td> 135 * <td valign='top' rowspan='1' colspan='1'> 136 * <code>null</code></td> 137 * <td valign='top' rowspan='1' colspan='1'><code>null</code></td> 138 * </tr> 139 * <tr> 140 * <td valign='top' rowspan='1' colspan='1'><code>Notation</code></td> 141 * <td valign='top' rowspan='1' colspan='1'>notation name</td> 142 * <td valign='top' rowspan='1' colspan='1'> 143 * <code>null</code></td> 144 * <td valign='top' rowspan='1' colspan='1'><code>null</code></td> 145 * </tr> 146 * <tr> 147 * <td valign='top' rowspan='1' colspan='1'><code>ProcessingInstruction</code></td> 148 * <td valign='top' rowspan='1' colspan='1'>same 149 * as <code>ProcessingInstruction.target</code></td> 150 * <td valign='top' rowspan='1' colspan='1'>same as 151 * <code>ProcessingInstruction.data</code></td> 152 * <td valign='top' rowspan='1' colspan='1'><code>null</code></td> 153 * </tr> 154 * <tr> 155 * <td valign='top' rowspan='1' colspan='1'><code>Text</code></td> 156 * <td valign='top' rowspan='1' colspan='1'> 157 * <code>"#text"</code></td> 158 * <td valign='top' rowspan='1' colspan='1'>same as <code>CharacterData.data</code>, the content 159 * of the text node</td> 160 * <td valign='top' rowspan='1' colspan='1'><code>null</code></td> 161 * </tr> 162 * </table> 163 * <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>. 164 */ 165 public interface Node { 166 // NodeType 167 /** 168 * The node is an <code>Element</code>. 169 */ 170 public static final short ELEMENT_NODE = 1; 171 /** 172 * The node is an <code>Attr</code>. 173 */ 174 public static final short ATTRIBUTE_NODE = 2; 175 /** 176 * The node is a <code>Text</code> node. 177 */ 178 public static final short TEXT_NODE = 3; 179 /** 180 * The node is a <code>CDATASection</code>. 181 */ 182 public static final short CDATA_SECTION_NODE = 4; 183 /** 184 * The node is an <code>EntityReference</code>. 185 */ 186 public static final short ENTITY_REFERENCE_NODE = 5; 187 /** 188 * The node is an <code>Entity</code>. 189 */ 190 public static final short ENTITY_NODE = 6; 191 /** 192 * The node is a <code>ProcessingInstruction</code>. 193 */ 194 public static final short PROCESSING_INSTRUCTION_NODE = 7; 195 /** 196 * The node is a <code>Comment</code>. 197 */ 198 public static final short COMMENT_NODE = 8; 199 /** 200 * The node is a <code>Document</code>. 201 */ 202 public static final short DOCUMENT_NODE = 9; 203 /** 204 * The node is a <code>DocumentType</code>. 205 */ 206 public static final short DOCUMENT_TYPE_NODE = 10; 207 /** 208 * The node is a <code>DocumentFragment</code>. 209 */ 210 public static final short DOCUMENT_FRAGMENT_NODE = 11; 211 /** 212 * The node is a <code>Notation</code>. 213 */ 214 public static final short NOTATION_NODE = 12; 215 216 /** 217 * The name of this node, depending on its type; see the table above. 218 */ 219 public String getNodeName(); 220 221 /** 222 * The value of this node, depending on its type; see the table above. 223 * When it is defined to be <code>null</code>, setting it has no effect, 224 * including if the node is read-only. 225 * @exception DOMException 226 * DOMSTRING_SIZE_ERR: Raised when it would return more characters than 227 * fit in a <code>DOMString</code> variable on the implementation 228 * platform. 229 */ 230 public String getNodeValue() 231 throws DOMException; 232 /** 233 * The value of this node, depending on its type; see the table above. 234 * When it is defined to be <code>null</code>, setting it has no effect, 235 * including if the node is read-only. 236 * @exception DOMException 237 * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly and if 238 * it is not defined to be <code>null</code>. 239 */ 240 public void setNodeValue(String nodeValue) 241 throws DOMException; 242 243 /** 244 * A code representing the type of the underlying object, as defined above. 245 */ 246 public short getNodeType(); 247 248 /** 249 * The parent of this node. All nodes, except <code>Attr</code>, 250 * <code>Document</code>, <code>DocumentFragment</code>, 251 * <code>Entity</code>, and <code>Notation</code> may have a parent. 252 * However, if a node has just been created and not yet added to the 253 * tree, or if it has been removed from the tree, this is 254 * <code>null</code>. 255 */ 256 public Node getParentNode(); 257 258 /** 259 * A <code>NodeList</code> that contains all children of this node. If 260 * there are no children, this is a <code>NodeList</code> containing no 261 * nodes. 262 */ 263 public NodeList getChildNodes(); 264 265 /** 266 * The first child of this node. If there is no such node, this returns 267 * <code>null</code>. 268 */ 269 public Node getFirstChild(); 270 271 /** 272 * The last child of this node. If there is no such node, this returns 273 * <code>null</code>. 274 */ 275 public Node getLastChild(); 276 277 /** 278 * The node immediately preceding this node. If there is no such node, 279 * this returns <code>null</code>. 280 */ 281 public Node getPreviousSibling(); 282 283 /** 284 * The node immediately following this node. If there is no such node, 285 * this returns <code>null</code>. 286 */ 287 public Node getNextSibling(); 288 289 /** 290 * A <code>NamedNodeMap</code> containing the attributes of this node (if 291 * it is an <code>Element</code>) or <code>null</code> otherwise. 292 */ 293 public NamedNodeMap getAttributes(); 294 295 /** 296 * The <code>Document</code> object associated with this node. This is 297 * also the <code>Document</code> object used to create new nodes. When 298 * this node is a <code>Document</code> or a <code>DocumentType</code> 299 * which is not used with any <code>Document</code> yet, this is 300 * <code>null</code>. 301 * 302 * @since 1.4, DOM Level 2 303 */ 304 public Document getOwnerDocument(); 305 306 /** 307 * Inserts the node <code>newChild</code> before the existing child node 308 * <code>refChild</code>. If <code>refChild</code> is <code>null</code>, 309 * insert <code>newChild</code> at the end of the list of children. 310 * <br>If <code>newChild</code> is a <code>DocumentFragment</code> object, 311 * all of its children are inserted, in the same order, before 312 * <code>refChild</code>. If the <code>newChild</code> is already in the 313 * tree, it is first removed. 314 * <p ><b>Note:</b> Inserting a node before itself is implementation 315 * dependent. 316 * @param newChild The node to insert. 317 * @param refChild The reference node, i.e., the node before which the 318 * new node must be inserted. 319 * @return The node being inserted. 320 * @exception DOMException 321 * HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not 322 * allow children of the type of the <code>newChild</code> node, or if 323 * the node to insert is one of this node's ancestors or this node 324 * itself, or if this node is of type <code>Document</code> and the 325 * DOM application attempts to insert a second 326 * <code>DocumentType</code> or <code>Element</code> node. 327 * <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created 328 * from a different document than the one that created this node. 329 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or 330 * if the parent of the node being inserted is readonly. 331 * <br>NOT_FOUND_ERR: Raised if <code>refChild</code> is not a child of 332 * this node. 333 * <br>NOT_SUPPORTED_ERR: if this node is of type <code>Document</code>, 334 * this exception might be raised if the DOM implementation doesn't 335 * support the insertion of a <code>DocumentType</code> or 336 * <code>Element</code> node. 337 * 338 * @since 1.4, DOM Level 3 339 */ 340 public Node insertBefore(Node newChild, 341 Node refChild) 342 throws DOMException; 343 344 /** 345 * Replaces the child node <code>oldChild</code> with <code>newChild</code> 346 * in the list of children, and returns the <code>oldChild</code> node. 347 * <br>If <code>newChild</code> is a <code>DocumentFragment</code> object, 348 * <code>oldChild</code> is replaced by all of the 349 * <code>DocumentFragment</code> children, which are inserted in the 350 * same order. If the <code>newChild</code> is already in the tree, it 351 * is first removed. 352 * <p ><b>Note:</b> Replacing a node with itself is implementation 353 * dependent. 354 * @param newChild The new node to put in the child list. 355 * @param oldChild The node being replaced in the list. 356 * @return The node replaced. 357 * @exception DOMException 358 * HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not 359 * allow children of the type of the <code>newChild</code> node, or if 360 * the node to put in is one of this node's ancestors or this node 361 * itself, or if this node is of type <code>Document</code> and the 362 * result of the replacement operation would add a second 363 * <code>DocumentType</code> or <code>Element</code> on the 364 * <code>Document</code> node. 365 * <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created 366 * from a different document than the one that created this node. 367 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the parent of 368 * the new node is readonly. 369 * <br>NOT_FOUND_ERR: Raised if <code>oldChild</code> is not a child of 370 * this node. 371 * <br>NOT_SUPPORTED_ERR: if this node is of type <code>Document</code>, 372 * this exception might be raised if the DOM implementation doesn't 373 * support the replacement of the <code>DocumentType</code> child or 374 * <code>Element</code> child. 375 * 376 * @since 1.4, DOM Level 3 377 */ 378 public Node replaceChild(Node newChild, 379 Node oldChild) 380 throws DOMException; 381 382 /** 383 * Removes the child node indicated by <code>oldChild</code> from the list 384 * of children, and returns it. 385 * @param oldChild The node being removed. 386 * @return The node removed. 387 * @exception DOMException 388 * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. 389 * <br>NOT_FOUND_ERR: Raised if <code>oldChild</code> is not a child of 390 * this node. 391 * <br>NOT_SUPPORTED_ERR: if this node is of type <code>Document</code>, 392 * this exception might be raised if the DOM implementation doesn't 393 * support the removal of the <code>DocumentType</code> child or the 394 * <code>Element</code> child. 395 * 396 * @since 1.4, DOM Level 3 397 */ 398 public Node removeChild(Node oldChild) 399 throws DOMException; 400 401 /** 402 * Adds the node <code>newChild</code> to the end of the list of children 403 * of this node. If the <code>newChild</code> is already in the tree, it 404 * is first removed. 405 * @param newChild The node to add.If it is a 406 * <code>DocumentFragment</code> object, the entire contents of the 407 * document fragment are moved into the child list of this node 408 * @return The node added. 409 * @exception DOMException 410 * HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not 411 * allow children of the type of the <code>newChild</code> node, or if 412 * the node to append is one of this node's ancestors or this node 413 * itself, or if this node is of type <code>Document</code> and the 414 * DOM application attempts to append a second 415 * <code>DocumentType</code> or <code>Element</code> node. 416 * <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created 417 * from a different document than the one that created this node. 418 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or 419 * if the previous parent of the node being inserted is readonly. 420 * <br>NOT_SUPPORTED_ERR: if the <code>newChild</code> node is a child 421 * of the <code>Document</code> node, this exception might be raised 422 * if the DOM implementation doesn't support the removal of the 423 * <code>DocumentType</code> child or <code>Element</code> child. 424 * 425 * @since 1.4, DOM Level 3 426 */ 427 public Node appendChild(Node newChild) 428 throws DOMException; 429 430 /** 431 * Returns whether this node has any children. 432 * @return Returns <code>true</code> if this node has any children, 433 * <code>false</code> otherwise. 434 */ 435 public boolean hasChildNodes(); 436 437 /** 438 * Returns a duplicate of this node, i.e., serves as a generic copy 439 * constructor for nodes. The duplicate node has no parent ( 440 * <code>parentNode</code> is <code>null</code>) and no user data. User 441 * data associated to the imported node is not carried over. However, if 442 * any <code>UserDataHandlers</code> has been specified along with the 443 * associated data these handlers will be called with the appropriate 444 * parameters before this method returns. 445 * <br>Cloning an <code>Element</code> copies all attributes and their 446 * values, including those generated by the XML processor to represent 447 * defaulted attributes, but this method does not copy any children it 448 * contains unless it is a deep clone. This includes text contained in 449 * an the <code>Element</code> since the text is contained in a child 450 * <code>Text</code> node. Cloning an <code>Attr</code> directly, as 451 * opposed to be cloned as part of an <code>Element</code> cloning 452 * operation, returns a specified attribute (<code>specified</code> is 453 * <code>true</code>). Cloning an <code>Attr</code> always clones its 454 * children, since they represent its value, no matter whether this is a 455 * deep clone or not. Cloning an <code>EntityReference</code> 456 * automatically constructs its subtree if a corresponding 457 * <code>Entity</code> is available, no matter whether this is a deep 458 * clone or not. Cloning any other type of node simply returns a copy of 459 * this node. 460 * <br>Note that cloning an immutable subtree results in a mutable copy, 461 * but the children of an <code>EntityReference</code> clone are readonly 462 * . In addition, clones of unspecified <code>Attr</code> nodes are 463 * specified. And, cloning <code>Document</code>, 464 * <code>DocumentType</code>, <code>Entity</code>, and 465 * <code>Notation</code> nodes is implementation dependent. 466 * @param deep If <code>true</code>, recursively clone the subtree under 467 * the specified node; if <code>false</code>, clone only the node 468 * itself (and its attributes, if it is an <code>Element</code>). 469 * @return The duplicate node. 470 */ 471 public Node cloneNode(boolean deep); 472 473 /** 474 * Puts all <code>Text</code> nodes in the full depth of the sub-tree 475 * underneath this <code>Node</code>, including attribute nodes, into a 476 * "normal" form where only structure (e.g., elements, comments, 477 * processing instructions, CDATA sections, and entity references) 478 * separates <code>Text</code> nodes, i.e., there are neither adjacent 479 * <code>Text</code> nodes nor empty <code>Text</code> nodes. This can 480 * be used to ensure that the DOM view of a document is the same as if 481 * it were saved and re-loaded, and is useful when operations (such as 482 * XPointer [<a href='http://www.w3.org/TR/2003/REC-xptr-framework-20030325/'>XPointer</a>] 483 * lookups) that depend on a particular document tree structure are to 484 * be used. If the parameter "normalize-characters" of the 485 * <code>DOMConfiguration</code> object attached to the 486 * <code>Node.ownerDocument</code> is <code>true</code>, this method 487 * will also fully normalize the characters of the <code>Text</code> 488 * nodes. 489 * <p ><b>Note:</b> In cases where the document contains 490 * <code>CDATASections</code>, the normalize operation alone may not be 491 * sufficient, since XPointers do not differentiate between 492 * <code>Text</code> nodes and <code>CDATASection</code> nodes. 493 * 494 * @since 1.4, DOM Level 3 495 */ 496 public void normalize(); 497 498 /** 499 * Tests whether the DOM implementation implements a specific feature and 500 * that feature is supported by this node, as specified in . 501 * @param feature The name of the feature to test. 502 * @param version This is the version number of the feature to test. 503 * @return Returns <code>true</code> if the specified feature is 504 * supported on this node, <code>false</code> otherwise. 505 * 506 * @since 1.4, DOM Level 2 507 */ 508 public boolean isSupported(String feature, 509 String version); 510 511 /** 512 * The namespace URI of this node, or <code>null</code> if it is 513 * unspecified (see ). 514 * <br>This is not a computed value that is the result of a namespace 515 * lookup based on an examination of the namespace declarations in 516 * scope. It is merely the namespace URI given at creation time. 517 * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and 518 * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1 519 * method, such as <code>Document.createElement()</code>, this is always 520 * <code>null</code>. 521 * <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>] 522 * an attribute does not inherit its namespace from the element it is 523 * attached to. If an attribute is not explicitly given a namespace, it 524 * simply has no namespace. 525 * 526 * @since 1.4, DOM Level 2 527 */ 528 public String getNamespaceURI(); 529 530 /** 531 * The namespace prefix of this node, or <code>null</code> if it is 532 * unspecified. When it is defined to be <code>null</code>, setting it 533 * has no effect, including if the node is read-only. 534 * <br>Note that setting this attribute, when permitted, changes the 535 * <code>nodeName</code> attribute, which holds the qualified name, as 536 * well as the <code>tagName</code> and <code>name</code> attributes of 537 * the <code>Element</code> and <code>Attr</code> interfaces, when 538 * applicable. 539 * <br>Setting the prefix to <code>null</code> makes it unspecified, 540 * setting it to an empty string is implementation dependent. 541 * <br>Note also that changing the prefix of an attribute that is known to 542 * have a default value, does not make a new attribute with the default 543 * value and the original prefix appear, since the 544 * <code>namespaceURI</code> and <code>localName</code> do not change. 545 * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and 546 * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1 547 * method, such as <code>createElement</code> from the 548 * <code>Document</code> interface, this is always <code>null</code>. 549 * 550 * @since 1.4, DOM Level 2 551 */ 552 public String getPrefix(); 553 /** 554 * The namespace prefix of this node, or <code>null</code> if it is 555 * unspecified. When it is defined to be <code>null</code>, setting it 556 * has no effect, including if the node is read-only. 557 * <br>Note that setting this attribute, when permitted, changes the 558 * <code>nodeName</code> attribute, which holds the qualified name, as 559 * well as the <code>tagName</code> and <code>name</code> attributes of 560 * the <code>Element</code> and <code>Attr</code> interfaces, when 561 * applicable. 562 * <br>Setting the prefix to <code>null</code> makes it unspecified, 563 * setting it to an empty string is implementation dependent. 564 * <br>Note also that changing the prefix of an attribute that is known to 565 * have a default value, does not make a new attribute with the default 566 * value and the original prefix appear, since the 567 * <code>namespaceURI</code> and <code>localName</code> do not change. 568 * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and 569 * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1 570 * method, such as <code>createElement</code> from the 571 * <code>Document</code> interface, this is always <code>null</code>. 572 * @exception DOMException 573 * INVALID_CHARACTER_ERR: Raised if the specified prefix contains an 574 * illegal character according to the XML version in use specified in 575 * the <code>Document.xmlVersion</code> attribute. 576 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. 577 * <br>NAMESPACE_ERR: Raised if the specified <code>prefix</code> is 578 * malformed per the Namespaces in XML specification, if the 579 * <code>namespaceURI</code> of this node is <code>null</code>, if the 580 * specified prefix is "xml" and the <code>namespaceURI</code> of this 581 * node is different from "<a href='http://www.w3.org/XML/1998/namespace'> 582 * http://www.w3.org/XML/1998/namespace</a>", if this node is an attribute and the specified prefix is "xmlns" and 583 * 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> of 584 * this node is "xmlns" [<a href='http://www.w3.org/TR/1999/REC-xml-names-19990114/'>XML Namespaces</a>] 585 * . 586 * 587 * @since 1.4, DOM Level 2 588 */ 589 public void setPrefix(String prefix) 590 throws DOMException; 591 592 /** 593 * Returns the local part of the qualified name of this node. 594 * <br>For nodes of any type other than <code>ELEMENT_NODE</code> and 595 * <code>ATTRIBUTE_NODE</code> and nodes created with a DOM Level 1 596 * method, such as <code>Document.createElement()</code>, this is always 597 * <code>null</code>. 598 * 599 * @since 1.4, DOM Level 2 600 */ 601 public String getLocalName(); 602 603 /** 604 * Returns whether this node (if it is an element) has any attributes. 605 * @return Returns <code>true</code> if this node has any attributes, 606 * <code>false</code> otherwise. 607 * 608 * @since 1.4, DOM Level 2 609 */ 610 public boolean hasAttributes(); 611 612 /** 613 * The absolute base URI of this node or <code>null</code> if the 614 * implementation wasn't able to obtain an absolute URI. This value is 615 * computed as described in . However, when the <code>Document</code> 616 * supports the feature "HTML" [<a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>DOM Level 2 HTML</a>] 617 * , the base URI is computed using first the value of the href 618 * attribute of the HTML BASE element if any, and the value of the 619 * <code>documentURI</code> attribute from the <code>Document</code> 620 * interface otherwise. 621 * 622 * @since 1.5, DOM Level 3 623 */ 624 public String getBaseURI(); 625 626 // DocumentPosition 627 /** 628 * The two nodes are disconnected. Order between disconnected nodes is 629 * always implementation-specific. 630 */ 631 public static final short DOCUMENT_POSITION_DISCONNECTED = 0x01; 632 /** 633 * The second node precedes the reference node. 634 */ 635 public static final short DOCUMENT_POSITION_PRECEDING = 0x02; 636 /** 637 * The node follows the reference node. 638 */ 639 public static final short DOCUMENT_POSITION_FOLLOWING = 0x04; 640 /** 641 * The node contains the reference node. A node which contains is always 642 * preceding, too. 643 */ 644 public static final short DOCUMENT_POSITION_CONTAINS = 0x08; 645 /** 646 * The node is contained by the reference node. A node which is contained 647 * is always following, too. 648 */ 649 public static final short DOCUMENT_POSITION_CONTAINED_BY = 0x10; 650 /** 651 * The determination of preceding versus following is 652 * implementation-specific. 653 */ 654 public static final short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 0x20; 655 656 /** 657 * Compares the reference node, i.e. the node on which this method is 658 * being called, with a node, i.e. the one passed as a parameter, with 659 * regard to their position in the document and according to the 660 * document order. 661 * @param other The node to compare against the reference node. 662 * @return Returns how the node is positioned relatively to the reference 663 * node. 664 * @exception DOMException 665 * NOT_SUPPORTED_ERR: when the compared nodes are from different DOM 666 * implementations that do not coordinate to return consistent 667 * implementation-specific results. 668 * 669 * @since 1.5, DOM Level 3 670 */ 671 public short compareDocumentPosition(Node other) 672 throws DOMException; 673 674 /** 675 * This attribute returns the text content of this node and its 676 * descendants. When it is defined to be <code>null</code>, setting it 677 * has no effect. On setting, any possible children this node may have 678 * are removed and, if it the new string is not empty or 679 * <code>null</code>, replaced by a single <code>Text</code> node 680 * containing the string this attribute is set to. 681 * <br> On getting, no serialization is performed, the returned string 682 * does not contain any markup. No whitespace normalization is performed 683 * and the returned string does not contain the white spaces in element 684 * content (see the attribute 685 * <code>Text.isElementContentWhitespace</code>). Similarly, on setting, 686 * no parsing is performed either, the input string is taken as pure 687 * textual content. 688 * <br>The string returned is made of the text content of this node 689 * depending on its type, as defined below: 690 * <table border='1' cellpadding='3'> 691 * <tr> 692 * <th>Node type</th> 693 * <th>Content</th> 694 * </tr> 695 * <tr> 696 * <td valign='top' rowspan='1' colspan='1'> 697 * ELEMENT_NODE, ATTRIBUTE_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, 698 * DOCUMENT_FRAGMENT_NODE</td> 699 * <td valign='top' rowspan='1' colspan='1'>concatenation of the <code>textContent</code> 700 * attribute value of every child node, excluding COMMENT_NODE and 701 * PROCESSING_INSTRUCTION_NODE nodes. This is the empty string if the 702 * node has no children.</td> 703 * </tr> 704 * <tr> 705 * <td valign='top' rowspan='1' colspan='1'>TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, 706 * PROCESSING_INSTRUCTION_NODE</td> 707 * <td valign='top' rowspan='1' colspan='1'><code>nodeValue</code></td> 708 * </tr> 709 * <tr> 710 * <td valign='top' rowspan='1' colspan='1'>DOCUMENT_NODE, 711 * DOCUMENT_TYPE_NODE, NOTATION_NODE</td> 712 * <td valign='top' rowspan='1' colspan='1'><em>null</em></td> 713 * </tr> 714 * </table> 715 * @exception DOMException 716 * DOMSTRING_SIZE_ERR: Raised when it would return more characters than 717 * fit in a <code>DOMString</code> variable on the implementation 718 * platform. 719 * 720 * @since 1.5, DOM Level 3 721 */ 722 public String getTextContent() 723 throws DOMException; 724 /** 725 * This attribute returns the text content of this node and its 726 * descendants. When it is defined to be <code>null</code>, setting it 727 * has no effect. On setting, any possible children this node may have 728 * are removed and, if it the new string is not empty or 729 * <code>null</code>, replaced by a single <code>Text</code> node 730 * containing the string this attribute is set to. 731 * <br> On getting, no serialization is performed, the returned string 732 * does not contain any markup. No whitespace normalization is performed 733 * and the returned string does not contain the white spaces in element 734 * content (see the attribute 735 * <code>Text.isElementContentWhitespace</code>). Similarly, on setting, 736 * no parsing is performed either, the input string is taken as pure 737 * textual content. 738 * <br>The string returned is made of the text content of this node 739 * depending on its type, as defined below: 740 * <table border='1' cellpadding='3'> 741 * <tr> 742 * <th>Node type</th> 743 * <th>Content</th> 744 * </tr> 745 * <tr> 746 * <td valign='top' rowspan='1' colspan='1'> 747 * ELEMENT_NODE, ATTRIBUTE_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, 748 * DOCUMENT_FRAGMENT_NODE</td> 749 * <td valign='top' rowspan='1' colspan='1'>concatenation of the <code>textContent</code> 750 * attribute value of every child node, excluding COMMENT_NODE and 751 * PROCESSING_INSTRUCTION_NODE nodes. This is the empty string if the 752 * node has no children.</td> 753 * </tr> 754 * <tr> 755 * <td valign='top' rowspan='1' colspan='1'>TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, 756 * PROCESSING_INSTRUCTION_NODE</td> 757 * <td valign='top' rowspan='1' colspan='1'><code>nodeValue</code></td> 758 * </tr> 759 * <tr> 760 * <td valign='top' rowspan='1' colspan='1'>DOCUMENT_NODE, 761 * DOCUMENT_TYPE_NODE, NOTATION_NODE</td> 762 * <td valign='top' rowspan='1' colspan='1'><em>null</em></td> 763 * </tr> 764 * </table> 765 * @exception DOMException 766 * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. 767 * 768 * @since 1.5, DOM Level 3 769 */ 770 public void setTextContent(String textContent) 771 throws DOMException; 772 773 /** 774 * Returns whether this node is the same node as the given one. 775 * <br>This method provides a way to determine whether two 776 * <code>Node</code> references returned by the implementation reference 777 * the same object. When two <code>Node</code> references are references 778 * to the same object, even if through a proxy, the references may be 779 * used completely interchangeably, such that all attributes have the 780 * same values and calling the same DOM method on either reference 781 * always has exactly the same effect. 782 * @param other The node to test against. 783 * @return Returns <code>true</code> if the nodes are the same, 784 * <code>false</code> otherwise. 785 * 786 * @since 1.5, DOM Level 3 787 */ 788 public boolean isSameNode(Node other); 789 790 /** 791 * Look up the prefix associated to the given namespace URI, starting from 792 * this node. The default namespace declarations are ignored by this 793 * method. 794 * <br>See for details on the algorithm used by this method. 795 * @param namespaceURI The namespace URI to look for. 796 * @return Returns an associated namespace prefix if found or 797 * <code>null</code> if none is found. If more than one prefix are 798 * associated to the namespace prefix, the returned namespace prefix 799 * is implementation dependent. 800 * 801 * @since 1.5, DOM Level 3 802 */ 803 public String lookupPrefix(String namespaceURI); 804 805 /** 806 * This method checks if the specified <code>namespaceURI</code> is the 807 * default namespace or not. 808 * @param namespaceURI The namespace URI to look for. 809 * @return Returns <code>true</code> if the specified 810 * <code>namespaceURI</code> is the default namespace, 811 * <code>false</code> otherwise. 812 * 813 * @since 1.5, DOM Level 3 814 */ 815 public boolean isDefaultNamespace(String namespaceURI); 816 817 /** 818 * Look up the namespace URI associated to the given prefix, starting from 819 * this node. 820 * <br>See for details on the algorithm used by this method. 821 * @param prefix The prefix to look for. If this parameter is 822 * <code>null</code>, the method will return the default namespace URI 823 * if any. 824 * @return Returns the associated namespace URI or <code>null</code> if 825 * none is found. 826 * 827 * @since 1.5, DOM Level 3 828 */ 829 public String lookupNamespaceURI(String prefix); 830 831 /** 832 * Tests whether two nodes are equal. 833 * <br>This method tests for equality of nodes, not sameness (i.e., 834 * whether the two nodes are references to the same object) which can be 835 * tested with <code>Node.isSameNode()</code>. All nodes that are the 836 * same will also be equal, though the reverse may not be true. 837 * <br>Two nodes are equal if and only if the following conditions are 838 * satisfied: 839 * <ul> 840 * <li>The two nodes are of the same type. 841 * </li> 842 * <li>The following string 843 * attributes are equal: <code>nodeName</code>, <code>localName</code>, 844 * <code>namespaceURI</code>, <code>prefix</code>, <code>nodeValue</code> 845 * . This is: they are both <code>null</code>, or they have the same 846 * length and are character for character identical. 847 * </li> 848 * <li>The 849 * <code>attributes</code> <code>NamedNodeMaps</code> are equal. This 850 * is: they are both <code>null</code>, or they have the same length and 851 * for each node that exists in one map there is a node that exists in 852 * the other map and is equal, although not necessarily at the same 853 * index. 854 * </li> 855 * <li>The <code>childNodes</code> <code>NodeLists</code> are equal. 856 * This is: they are both <code>null</code>, or they have the same 857 * length and contain equal nodes at the same index. Note that 858 * normalization can affect equality; to avoid this, nodes should be 859 * normalized before being compared. 860 * </li> 861 * </ul> 862 * <br>For two <code>DocumentType</code> nodes to be equal, the following 863 * conditions must also be satisfied: 864 * <ul> 865 * <li>The following string attributes 866 * are equal: <code>publicId</code>, <code>systemId</code>, 867 * <code>internalSubset</code>. 868 * </li> 869 * <li>The <code>entities</code> 870 * <code>NamedNodeMaps</code> are equal. 871 * </li> 872 * <li>The <code>notations</code> 873 * <code>NamedNodeMaps</code> are equal. 874 * </li> 875 * </ul> 876 * <br>On the other hand, the following do not affect equality: the 877 * <code>ownerDocument</code>, <code>baseURI</code>, and 878 * <code>parentNode</code> attributes, the <code>specified</code> 879 * attribute for <code>Attr</code> nodes, the <code>schemaTypeInfo</code> 880 * attribute for <code>Attr</code> and <code>Element</code> nodes, the 881 * <code>Text.isElementContentWhitespace</code> attribute for 882 * <code>Text</code> nodes, as well as any user data or event listeners 883 * registered on the nodes. 884 * <p ><b>Note:</b> As a general rule, anything not mentioned in the 885 * description above is not significant in consideration of equality 886 * checking. Note that future versions of this specification may take 887 * into account more attributes and implementations conform to this 888 * specification are expected to be updated accordingly. 889 * @param arg The node to compare equality with. 890 * @return Returns <code>true</code> if the nodes are equal, 891 * <code>false</code> otherwise. 892 * 893 * @since 1.5, DOM Level 3 894 */ 895 public boolean isEqualNode(Node arg); 896 897 /** 898 * This method returns a specialized object which implements the 899 * specialized APIs of the specified feature and version, as specified 900 * in . The specialized object may also be obtained by using 901 * binding-specific casting methods but is not necessarily expected to, 902 * as discussed in . This method also allow the implementation to 903 * provide specialized objects which do not support the <code>Node</code> 904 * interface. 905 * @param feature The name of the feature requested. Note that any plus 906 * sign "+" prepended to the name of the feature will be ignored since 907 * it is not significant in the context of this method. 908 * @param version This is the version number of the feature to test. 909 * @return Returns an object which implements the specialized APIs of 910 * the specified feature and version, if any, or <code>null</code> if 911 * there is no object which implements interfaces associated with that 912 * feature. If the <code>DOMObject</code> returned by this method 913 * implements the <code>Node</code> interface, it must delegate to the 914 * primary core <code>Node</code> and not return results inconsistent 915 * with the primary core <code>Node</code> such as attributes, 916 * childNodes, etc. 917 * 918 * @since 1.5, DOM Level 3 919 */ 920 public Object getFeature(String feature, 921 String version); 922 923 /** 924 * Associate an object to a key on this node. The object can later be 925 * retrieved from this node by calling <code>getUserData</code> with the 926 * same key. 927 * @param key The key to associate the object to. 928 * @param data The object to associate to the given key, or 929 * <code>null</code> to remove any existing association to that key. 930 * @param handler The handler to associate to that key, or 931 * <code>null</code>. 932 * @return Returns the <code>DOMUserData</code> previously associated to 933 * the given key on this node, or <code>null</code> if there was none. 934 * 935 * @since 1.5, DOM Level 3 936 */ 937 public Object setUserData(String key, 938 Object data, 939 UserDataHandler handler); 940 941 /** 942 * Retrieves the object associated to a key on a this node. The object 943 * must first have been set to this node by calling 944 * <code>setUserData</code> with the same key. 945 * @param key The key the object is associated to. 946 * @return Returns the <code>DOMUserData</code> associated to the given 947 * key on this node, or <code>null</code> if there was none. 948 * 949 * @since 1.5, DOM Level 3 950 */ 951 public Object getUserData(String key); 952 953 }