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