Path: blob/master/src/java.xml/share/classes/org/w3c/dom/NamedNodeMap.java
40948 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* Objects implementing the <code>NamedNodeMap</code> interface are used to45* represent collections of nodes that can be accessed by name. Note that46* <code>NamedNodeMap</code> does not inherit from <code>NodeList</code>;47* <code>NamedNodeMaps</code> are not maintained in any particular order.48* Objects contained in an object implementing <code>NamedNodeMap</code> may49* also be accessed by an ordinal index, but this is simply to allow50* convenient enumeration of the contents of a <code>NamedNodeMap</code>,51* and does not imply that the DOM specifies an order to these Nodes.52* <p><code>NamedNodeMap</code> objects in the DOM are live.53* <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>.54*/55public interface NamedNodeMap {56/**57* Retrieves a node specified by name.58* @param name The <code>nodeName</code> of a node to retrieve.59* @return A <code>Node</code> (of any type) with the specified60* <code>nodeName</code>, or <code>null</code> if it does not identify61* any node in this map.62*/63public Node getNamedItem(String name);6465/**66* Adds a node using its <code>nodeName</code> attribute. If a node with67* that name is already present in this map, it is replaced by the new68* one. Replacing a node by itself has no effect.69* <br>As the <code>nodeName</code> attribute is used to derive the name70* which the node must be stored under, multiple nodes of certain types71* (those that have a "special" string value) cannot be stored as the72* names would clash. This is seen as preferable to allowing nodes to be73* aliased.74* @param arg A node to store in this map. The node will later be75* accessible using the value of its <code>nodeName</code> attribute.76* @return If the new <code>Node</code> replaces an existing node the77* replaced <code>Node</code> is returned, otherwise <code>null</code>78* is returned.79* @exception DOMException80* WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a81* different document than the one that created this map.82* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.83* <br>INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an84* <code>Attr</code> that is already an attribute of another85* <code>Element</code> object. The DOM user must explicitly clone86* <code>Attr</code> nodes to re-use them in other elements.87* <br>HIERARCHY_REQUEST_ERR: Raised if an attempt is made to add a node88* doesn't belong in this NamedNodeMap. Examples would include trying89* to insert something other than an Attr node into an Element's map90* of attributes, or a non-Entity node into the DocumentType's map of91* Entities.92*/93public Node setNamedItem(Node arg)94throws DOMException;9596/**97* Removes a node specified by name. When this map contains the attributes98* attached to an element, if the removed attribute is known to have a99* default value, an attribute immediately appears containing the100* default value as well as the corresponding namespace URI, local name,101* and prefix when applicable.102* @param name The <code>nodeName</code> of the node to remove.103* @return The node removed from this map if a node with such a name104* exists.105* @exception DOMException106* NOT_FOUND_ERR: Raised if there is no node named <code>name</code> in107* this map.108* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.109*/110public Node removeNamedItem(String name)111throws DOMException;112113/**114* Returns the <code>index</code>th item in the map. If <code>index</code>115* is greater than or equal to the number of nodes in this map, this116* returns <code>null</code>.117* @param index Index into this map.118* @return The node at the <code>index</code>th position in the map, or119* <code>null</code> if that is not a valid index.120*/121public Node item(int index);122123/**124* The number of nodes in this map. The range of valid child node indices125* is <code>0</code> to <code>length-1</code> inclusive.126*/127public int getLength();128129/**130* Retrieves a node specified by local name and namespace URI.131* <br>Per [<a href='http://www.w3.org/TR/1999/REC-xml-names-19990114/'>XML Namespaces</a>]132* , applications must use the value null as the namespaceURI parameter133* for methods if they wish to have no namespace.134* @param namespaceURI The namespace URI of the node to retrieve.135* @param localName The local name of the node to retrieve.136* @return A <code>Node</code> (of any type) with the specified local137* name and namespace URI, or <code>null</code> if they do not138* identify any node in this map.139* @exception DOMException140* NOT_SUPPORTED_ERR: May be raised if the implementation does not141* support the feature "XML" and the language exposed through the142* 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 1.4, DOM Level 2144*/145public Node getNamedItemNS(String namespaceURI,146String localName)147throws DOMException;148149/**150* Adds a node using its <code>namespaceURI</code> and151* <code>localName</code>. If a node with that namespace URI and that152* local name is already present in this map, it is replaced by the new153* one. Replacing a node by itself has no effect.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 parameter156* for methods if they wish to have no namespace.157* @param arg A node to store in this map. The node will later be158* accessible using the value of its <code>namespaceURI</code> and159* <code>localName</code> attributes.160* @return If the new <code>Node</code> replaces an existing node the161* replaced <code>Node</code> is returned, otherwise <code>null</code>162* is returned.163* @exception DOMException164* WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a165* different document than the one that created this map.166* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.167* <br>INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an168* <code>Attr</code> that is already an attribute of another169* <code>Element</code> object. The DOM user must explicitly clone170* <code>Attr</code> nodes to re-use them in other elements.171* <br>HIERARCHY_REQUEST_ERR: Raised if an attempt is made to add a node172* doesn't belong in this NamedNodeMap. Examples would include trying173* to insert something other than an Attr node into an Element's map174* of attributes, or a non-Entity node into the DocumentType's map of175* Entities.176* <br>NOT_SUPPORTED_ERR: May be raised if the implementation does not177* support the feature "XML" and the language exposed through the178* Document does not support XML Namespaces (such as [<a href='http://www.w3.org/TR/1999/REC-html401-19991224/'>HTML 4.01</a>]).179* @since 1.4, DOM Level 2180*/181public Node setNamedItemNS(Node arg)182throws DOMException;183184/**185* Removes a node specified by local name and namespace URI. A removed186* attribute may be known to have a default value when this map contains187* the attributes attached to an element, as returned by the attributes188* attribute of the <code>Node</code> interface. If so, an attribute189* immediately appears containing the default value as well as the190* corresponding namespace URI, local name, and prefix when applicable.191* <br>Per [<a href='http://www.w3.org/TR/1999/REC-xml-names-19990114/'>XML Namespaces</a>]192* , applications must use the value null as the namespaceURI parameter193* for methods if they wish to have no namespace.194* @param namespaceURI The namespace URI of the node to remove.195* @param localName The local name of the node to remove.196* @return The node removed from this map if a node with such a local197* name and namespace URI exists.198* @exception DOMException199* NOT_FOUND_ERR: Raised if there is no node with the specified200* <code>namespaceURI</code> and <code>localName</code> in this map.201* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.202* <br>NOT_SUPPORTED_ERR: May be raised if the implementation does not203* support the feature "XML" and the language exposed through the204* Document does not support XML Namespaces (such as [<a href='http://www.w3.org/TR/1999/REC-html401-19991224/'>HTML 4.01</a>]).205* @since 1.4, DOM Level 2206*/207public Node removeNamedItemNS(String namespaceURI,208String localName)209throws DOMException;210211}212213214