1 /* 2 * Copyright (c) 2000 World Wide Web Consortium, 3 * (Massachusetts Institute of Technology, Institut National de 4 * Recherche en Informatique et en Automatique, Keio University). All 5 * Rights Reserved. This program is distributed under the W3C's Software 6 * Intellectual Property License. This program is distributed in the 7 * hope that it will be useful, but WITHOUT ANY WARRANTY; without even 8 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 9 * PURPOSE. 10 * See W3C License http://www.w3.org/Consortium/Legal/ for more details. 11 */ 12 13 package org.w3c.dom; 14 15 // BEGIN android-note 16 // Cleaned up @param tags that seemed to be missing spaces between 17 // the parameter name and the start of the description. 18 // END android-note 19 20 //BEGIN android-note 21 //Filled some gaps in the documentation and refactored parts of the existing 22 //documentation to make the Doclet happy. 23 //END android-note 24 25 /** 26 * Objects implementing the <code>NamedNodeMap</code> interface are used to 27 * represent collections of nodes that can be accessed by name. Note that 28 * <code>NamedNodeMap</code> does not inherit from <code>NodeList</code>; 29 * <code>NamedNodeMaps</code> are not maintained in any particular order. 30 * Objects contained in an object implementing <code>NamedNodeMap</code> may 31 * also be accessed by an ordinal index, but this is simply to allow 32 * convenient enumeration of the contents of a <code>NamedNodeMap</code>, 33 * and does not imply that the DOM specifies an order to these Nodes. 34 * <p><code>NamedNodeMap</code> objects in the DOM are live. 35 * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113'>Document Object Model (DOM) Level 2 Core Specification</a>. 36 */ 37 public interface NamedNodeMap { 38 /** 39 * Retrieves a node specified by name. 40 * @param name The <code>nodeName</code> of a node to retrieve. 41 * @return A <code>Node</code> (of any type) with the specified 42 * <code>nodeName</code>, or <code>null</code> if it does not identify 43 * any node in this map. 44 */ getNamedItem(String name)45 public Node getNamedItem(String name); 46 47 /** 48 * Adds a node using its <code>nodeName</code> attribute. If a node with 49 * that name is already present in this map, it is replaced by the new 50 * one. 51 * <br>As the <code>nodeName</code> attribute is used to derive the name 52 * which the node must be stored under, multiple nodes of certain types 53 * (those that have a "special" string value) cannot be stored as the 54 * names would clash. This is seen as preferable to allowing nodes to be 55 * aliased. 56 * @param arg A node to store in this map. The node will later be 57 * accessible using the value of its <code>nodeName</code> attribute. 58 * @return If the new <code>Node</code> replaces an existing node the 59 * replaced <code>Node</code> is returned, otherwise <code>null</code> 60 * is returned. 61 * @exception DOMException 62 * WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a 63 * different document than the one that created this map. 64 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly. 65 * <br>INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an 66 * <code>Attr</code> that is already an attribute of another 67 * <code>Element</code> object. The DOM user must explicitly clone 68 * <code>Attr</code> nodes to re-use them in other elements. 69 */ setNamedItem(Node arg)70 public Node setNamedItem(Node arg) 71 throws DOMException; 72 73 /** 74 * Removes a node specified by name. When this map contains the attributes 75 * attached to an element, if the removed attribute is known to have a 76 * default value, an attribute immediately appears containing the 77 * default value as well as the corresponding namespace URI, local name, 78 * and prefix when applicable. 79 * @param name The <code>nodeName</code> of the node to remove. 80 * @return The node removed from this map if a node with such a name 81 * exists. 82 * @exception DOMException 83 * NOT_FOUND_ERR: Raised if there is no node named <code>name</code> in 84 * this map. 85 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly. 86 */ removeNamedItem(String name)87 public Node removeNamedItem(String name) 88 throws DOMException; 89 90 /** 91 * Returns the <code>index</code>th item in the map. If <code>index</code> 92 * is greater than or equal to the number of nodes in this map, this 93 * returns <code>null</code>. 94 * @param index Index into this map. 95 * @return The node at the <code>index</code>th position in the map, or 96 * <code>null</code> if that is not a valid index. 97 */ item(int index)98 public Node item(int index); 99 100 /** 101 * The number of nodes in this map. The range of valid child node indices 102 * is <code>0</code> to <code>length-1</code> inclusive. 103 * 104 * @return the length of the map. 105 */ getLength()106 public int getLength(); 107 108 /** 109 * Retrieves a node specified by local name and namespace URI. HTML-only 110 * DOM implementations do not need to implement this method. 111 * @param namespaceURI The namespace URI of the node to retrieve. 112 * @param localName The local name of the node to retrieve. 113 * @return A <code>Node</code> (of any type) with the specified local 114 * name and namespace URI, or <code>null</code> if they do not 115 * identify any node in this map. 116 * @since DOM Level 2 117 */ getNamedItemNS(String namespaceURI, String localName)118 public Node getNamedItemNS(String namespaceURI, 119 String localName); 120 121 /** 122 * Adds a node using its <code>namespaceURI</code> and 123 * <code>localName</code>. If a node with that namespace URI and that 124 * local name is already present in this map, it is replaced by the new 125 * one. 126 * <br>HTML-only DOM implementations do not need to implement this method. 127 * @param arg A node to store in this map. The node will later be 128 * accessible using the value of its <code>namespaceURI</code> and 129 * <code>localName</code> attributes. 130 * @return If the new <code>Node</code> replaces an existing node the 131 * replaced <code>Node</code> is returned, otherwise <code>null</code> 132 * is returned. 133 * @exception DOMException 134 * WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a 135 * different document than the one that created this map. 136 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly. 137 * <br>INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an 138 * <code>Attr</code> that is already an attribute of another 139 * <code>Element</code> object. The DOM user must explicitly clone 140 * <code>Attr</code> nodes to re-use them in other elements. 141 * @since DOM Level 2 142 */ setNamedItemNS(Node arg)143 public Node setNamedItemNS(Node arg) 144 throws DOMException; 145 146 /** 147 * Removes a node specified by local name and namespace URI. A removed 148 * attribute may be known to have a default value when this map contains 149 * the attributes attached to an element, as returned by the attributes 150 * attribute of the <code>Node</code> interface. If so, an attribute 151 * immediately appears containing the default value as well as the 152 * corresponding namespace URI, local name, and prefix when applicable. 153 * <br>HTML-only DOM implementations do not need to implement this method. 154 * @param namespaceURI The namespace URI of the node to remove. 155 * @param localName The local name of the node to remove. 156 * @return The node removed from this map if a node with such a local 157 * name and namespace URI exists. 158 * @exception DOMException 159 * NOT_FOUND_ERR: Raised if there is no node with the specified 160 * <code>namespaceURI</code> and <code>localName</code> in this map. 161 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly. 162 * @since DOM Level 2 163 */ removeNamedItemNS(String namespaceURI, String localName)164 public Node removeNamedItemNS(String namespaceURI, 165 String localName) 166 throws DOMException; 167 168 } 169