001 /*
002 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
003 *
004 * This code is free software; you can redistribute it and/or modify it
005 * under the terms of the GNU General Public License version 2 only, as
006 * published by the Free Software Foundation. Sun designates this
007 * particular file as subject to the "Classpath" exception as provided
008 * by Sun in the LICENSE file that accompanied this code.
009 *
010 * This code is distributed in the hope that it will be useful, but WITHOUT
011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
013 * version 2 for more details (a copy is included in the LICENSE file that
014 * accompanied this code).
015 *
016 * You should have received a copy of the GNU General Public License version
017 * 2 along with this work; if not, write to the Free Software Foundation,
018 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
019 *
020 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
021 * CA 95054 USA or visit www.sun.com if you need additional information or
022 * have any questions.
023 */
024
025 /*
026 * This file is available under and governed by the GNU General Public
027 * License version 2 only, as published by the Free Software Foundation.
028 * However, the following notice accompanied the original version of this
029 * file and, per its terms, should not be removed:
030 *
031 * Copyright (c) 2004 World Wide Web Consortium,
032 *
033 * (Massachusetts Institute of Technology, European Research Consortium for
034 * Informatics and Mathematics, Keio University). All Rights Reserved. This
035 * work is distributed under the W3C(r) Software License [1] in the hope that
036 * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
037 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
038 *
039 * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
040 */
041
042 package org.w3c.dom;
043
044 /**
045 * Objects implementing the <code>NamedNodeMap</code> interface are used to
046 * represent collections of nodes that can be accessed by name. Note that
047 * <code>NamedNodeMap</code> does not inherit from <code>NodeList</code>;
048 * <code>NamedNodeMaps</code> are not maintained in any particular order.
049 * Objects contained in an object implementing <code>NamedNodeMap</code> may
050 * also be accessed by an ordinal index, but this is simply to allow
051 * convenient enumeration of the contents of a <code>NamedNodeMap</code>,
052 * and does not imply that the DOM specifies an order to these Nodes.
053 * <p><code>NamedNodeMap</code> objects in the DOM are live.
054 * <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>.
055 */
056 public interface NamedNodeMap {
057 /**
058 * Retrieves a node specified by name.
059 * @param name The <code>nodeName</code> of a node to retrieve.
060 * @return A <code>Node</code> (of any type) with the specified
061 * <code>nodeName</code>, or <code>null</code> if it does not identify
062 * any node in this map.
063 */
064 public Node getNamedItem(String name);
065
066 /**
067 * Adds a node using its <code>nodeName</code> attribute. If a node with
068 * that name is already present in this map, it is replaced by the new
069 * one. Replacing a node by itself has no effect.
070 * <br>As the <code>nodeName</code> attribute is used to derive the name
071 * which the node must be stored under, multiple nodes of certain types
072 * (those that have a "special" string value) cannot be stored as the
073 * names would clash. This is seen as preferable to allowing nodes to be
074 * aliased.
075 * @param arg A node to store in this map. The node will later be
076 * accessible using the value of its <code>nodeName</code> attribute.
077 * @return If the new <code>Node</code> replaces an existing node the
078 * replaced <code>Node</code> is returned, otherwise <code>null</code>
079 * is returned.
080 * @exception DOMException
081 * WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a
082 * different document than the one that created this map.
083 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
084 * <br>INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an
085 * <code>Attr</code> that is already an attribute of another
086 * <code>Element</code> object. The DOM user must explicitly clone
087 * <code>Attr</code> nodes to re-use them in other elements.
088 * <br>HIERARCHY_REQUEST_ERR: Raised if an attempt is made to add a node
089 * doesn't belong in this NamedNodeMap. Examples would include trying
090 * to insert something other than an Attr node into an Element's map
091 * of attributes, or a non-Entity node into the DocumentType's map of
092 * Entities.
093 */
094 public Node setNamedItem(Node arg) throws DOMException;
095
096 /**
097 * Removes a node specified by name. When this map contains the attributes
098 * attached to an element, if the removed attribute is known to have a
099 * default value, an attribute immediately appears containing the
100 * 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 name
104 * exists.
105 * @exception DOMException
106 * NOT_FOUND_ERR: Raised if there is no node named <code>name</code> in
107 * this map.
108 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
109 */
110 public Node removeNamedItem(String name) throws DOMException;
111
112 /**
113 * Returns the <code>index</code>th item in the map. If <code>index</code>
114 * is greater than or equal to the number of nodes in this map, this
115 * returns <code>null</code>.
116 * @param index Index into this map.
117 * @return The node at the <code>index</code>th position in the map, or
118 * <code>null</code> if that is not a valid index.
119 */
120 public Node item(int index);
121
122 /**
123 * The number of nodes in this map. The range of valid child node indices
124 * is <code>0</code> to <code>length-1</code> inclusive.
125 */
126 public int getLength();
127
128 /**
129 * Retrieves a node specified by local name and namespace URI.
130 * <br>Per [<a href='http://www.w3.org/TR/1999/REC-xml-names-19990114/'>XML Namespaces</a>]
131 * , applications must use the value null as the namespaceURI parameter
132 * for methods if they wish to have no namespace.
133 * @param namespaceURI The namespace URI of the node to retrieve.
134 * @param localName The local name of the node to retrieve.
135 * @return A <code>Node</code> (of any type) with the specified local
136 * name and namespace URI, or <code>null</code> if they do not
137 * identify any node in this map.
138 * @exception DOMException
139 * NOT_SUPPORTED_ERR: May be raised if the implementation does not
140 * support the feature "XML" and the language exposed through the
141 * Document does not support XML Namespaces (such as [<a href='http://www.w3.org/TR/1999/REC-html401-19991224/'>HTML 4.01</a>]).
142 * @since DOM Level 2
143 */
144 public Node getNamedItemNS(String namespaceURI, String localName)
145 throws DOMException;
146
147 /**
148 * Adds a node using its <code>namespaceURI</code> and
149 * <code>localName</code>. If a node with that namespace URI and that
150 * local name is already present in this map, it is replaced by the new
151 * one. Replacing a node by itself has no effect.
152 * <br>Per [<a href='http://www.w3.org/TR/1999/REC-xml-names-19990114/'>XML Namespaces</a>]
153 * , applications must use the value null as the namespaceURI parameter
154 * for methods if they wish to have no namespace.
155 * @param arg A node to store in this map. The node will later be
156 * accessible using the value of its <code>namespaceURI</code> and
157 * <code>localName</code> attributes.
158 * @return If the new <code>Node</code> replaces an existing node the
159 * replaced <code>Node</code> is returned, otherwise <code>null</code>
160 * is returned.
161 * @exception DOMException
162 * WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a
163 * different document than the one that created this map.
164 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
165 * <br>INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an
166 * <code>Attr</code> that is already an attribute of another
167 * <code>Element</code> object. The DOM user must explicitly clone
168 * <code>Attr</code> nodes to re-use them in other elements.
169 * <br>HIERARCHY_REQUEST_ERR: Raised if an attempt is made to add a node
170 * doesn't belong in this NamedNodeMap. Examples would include trying
171 * to insert something other than an Attr node into an Element's map
172 * of attributes, or a non-Entity node into the DocumentType's map of
173 * Entities.
174 * <br>NOT_SUPPORTED_ERR: May be raised if the implementation does not
175 * support the feature "XML" and the language exposed through the
176 * Document does not support XML Namespaces (such as [<a href='http://www.w3.org/TR/1999/REC-html401-19991224/'>HTML 4.01</a>]).
177 * @since DOM Level 2
178 */
179 public Node setNamedItemNS(Node arg) throws DOMException;
180
181 /**
182 * Removes a node specified by local name and namespace URI. A removed
183 * attribute may be known to have a default value when this map contains
184 * the attributes attached to an element, as returned by the attributes
185 * attribute of the <code>Node</code> interface. If so, an attribute
186 * immediately appears containing the default value as well as the
187 * corresponding namespace URI, local name, and prefix when applicable.
188 * <br>Per [<a href='http://www.w3.org/TR/1999/REC-xml-names-19990114/'>XML Namespaces</a>]
189 * , applications must use the value null as the namespaceURI parameter
190 * for methods if they wish to have no namespace.
191 * @param namespaceURI The namespace URI of the node to remove.
192 * @param localName The local name of the node to remove.
193 * @return The node removed from this map if a node with such a local
194 * name and namespace URI exists.
195 * @exception DOMException
196 * NOT_FOUND_ERR: Raised if there is no node with the specified
197 * <code>namespaceURI</code> and <code>localName</code> in this map.
198 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
199 * <br>NOT_SUPPORTED_ERR: May be raised if the implementation does not
200 * support the feature "XML" and the language exposed through the
201 * Document does not support XML Namespaces (such as [<a href='http://www.w3.org/TR/1999/REC-html401-19991224/'>HTML 4.01</a>]).
202 * @since DOM Level 2
203 */
204 public Node removeNamedItemNS(String namespaceURI, String localName)
205 throws DOMException;
206
207 }
|