001: /*
002: * Copyright (c) 2000 World Wide Web Consortium,
003: * (Massachusetts Institute of Technology, Institut National de
004: * Recherche en Informatique et en Automatique, Keio University). All
005: * Rights Reserved. This program is distributed under the W3C's Software
006: * Intellectual Property License. This program is distributed in the
007: * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
008: * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
009: * PURPOSE.
010: * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
011: */
012:
013: package org.w3c.dom;
014:
015: /**
016: * Objects implementing the <code>NamedNodeMap</code> interface are used to
017: * represent collections of nodes that can be accessed by name. Note that
018: * <code>NamedNodeMap</code> does not inherit from <code>NodeList</code>;
019: * <code>NamedNodeMaps</code> are not maintained in any particular order.
020: * Objects contained in an object implementing <code>NamedNodeMap</code> may
021: * also be accessed by an ordinal index, but this is simply to allow
022: * convenient enumeration of the contents of a <code>NamedNodeMap</code>,
023: * and does not imply that the DOM specifies an order to these Nodes.
024: * <p><code>NamedNodeMap</code> objects in the DOM are live.
025: * <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>.
026: */
027: public interface NamedNodeMap {
028: /**
029: * Retrieves a node specified by name.
030: * @param name The <code>nodeName</code> of a node to retrieve.
031: * @return A <code>Node</code> (of any type) with the specified
032: * <code>nodeName</code>, or <code>null</code> if it does not identify
033: * any node in this map.
034: */
035: public Node getNamedItem(String name);
036:
037: /**
038: * Adds a node using its <code>nodeName</code> attribute. If a node with
039: * that name is already present in this map, it is replaced by the new
040: * one.
041: * <br>As the <code>nodeName</code> attribute is used to derive the name
042: * which the node must be stored under, multiple nodes of certain types
043: * (those that have a "special" string value) cannot be stored as the
044: * names would clash. This is seen as preferable to allowing nodes to be
045: * aliased.
046: * @param arg A node to store in this map. The node will later be
047: * accessible using the value of its <code>nodeName</code> attribute.
048: * @return If the new <code>Node</code> replaces an existing node the
049: * replaced <code>Node</code> is returned, otherwise <code>null</code>
050: * is returned.
051: * @exception DOMException
052: * WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a
053: * different document than the one that created this map.
054: * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
055: * <br>INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an
056: * <code>Attr</code> that is already an attribute of another
057: * <code>Element</code> object. The DOM user must explicitly clone
058: * <code>Attr</code> nodes to re-use them in other elements.
059: * <br>HIERARCHY_REQUEST_ERR: Raised if an attempt is made to add a node
060: * doesn't belong in this NamedNodeMap. Examples would include trying
061: * to insert something other than an Attr node into an Element's map
062: * of attributes, or a non-Entity node into the DocumentType's map of
063: * Entities.
064: */
065: public Node setNamedItem(Node arg) throws DOMException;
066:
067: /**
068: * Removes a node specified by name. When this map contains the attributes
069: * attached to an element, if the removed attribute is known to have a
070: * default value, an attribute immediately appears containing the
071: * default value as well as the corresponding namespace URI, local name,
072: * and prefix when applicable.
073: * @param name The <code>nodeName</code> of the node to remove.
074: * @return The node removed from this map if a node with such a name
075: * exists.
076: * @exception DOMException
077: * NOT_FOUND_ERR: Raised if there is no node named <code>name</code> in
078: * this map.
079: * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
080: */
081: public Node removeNamedItem(String name) throws DOMException;
082:
083: /**
084: * Returns the <code>index</code>th item in the map. If <code>index</code>
085: * is greater than or equal to the number of nodes in this map, this
086: * returns <code>null</code>.
087: * @param index Index into this map.
088: * @return The node at the <code>index</code>th position in the map, or
089: * <code>null</code> if that is not a valid index.
090: */
091: public Node item(int index);
092:
093: /**
094: * The number of nodes in this map. The range of valid child node indices
095: * is <code>0</code> to <code>length-1</code> inclusive.
096: */
097: public int getLength();
098:
099: /**
100: * Retrieves a node specified by local name and namespace URI.
101: * <br>Documents which do not support the "XML" feature will permit only
102: * the DOM Level 1 calls for creating/setting elements and attributes.
103: * Hence, if you specify a non-null namespace URI, these DOMs will never
104: * find a matching node.
105: * @param namespaceURI The namespace URI of the node to retrieve.
106: * @param localName The local name of the node to retrieve.
107: * @return A <code>Node</code> (of any type) with the specified local
108: * name and namespace URI, or <code>null</code> if they do not
109: * identify any node in this map.
110: * @since DOM Level 2
111: */
112: public Node getNamedItemNS(String namespaceURI, String localName);
113:
114: /**
115: * Adds a node using its <code>namespaceURI</code> and
116: * <code>localName</code>. If a node with that namespace URI and that
117: * local name is already present in this map, it is replaced by the new
118: * one.
119: * @param arg A node to store in this map. The node will later be
120: * accessible using the value of its <code>namespaceURI</code> and
121: * <code>localName</code> attributes.
122: * @return If the new <code>Node</code> replaces an existing node the
123: * replaced <code>Node</code> is returned, otherwise <code>null</code>
124: * is returned.
125: * @exception DOMException
126: * WRONG_DOCUMENT_ERR: Raised if <code>arg</code> was created from a
127: * different document than the one that created this map.
128: * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
129: * <br>INUSE_ATTRIBUTE_ERR: Raised if <code>arg</code> is an
130: * <code>Attr</code> that is already an attribute of another
131: * <code>Element</code> object. The DOM user must explicitly clone
132: * <code>Attr</code> nodes to re-use them in other elements.
133: * <br>HIERARCHY_REQUEST_ERR: Raised if an attempt is made to add a node
134: * doesn't belong in this NamedNodeMap. Examples would include trying
135: * to insert something other than an Attr node into an Element's map
136: * of attributes, or a non-Entity node into the DocumentType's map of
137: * Entities.
138: * <br>NOT_SUPPORTED_ERR: Always thrown if the current document does not
139: * support the <code>"XML"</code> feature, since namespaces were
140: * defined by XML.
141: * @since DOM Level 2
142: */
143: public Node setNamedItemNS(Node arg) throws DOMException;
144:
145: /**
146: * Removes a node specified by local name and namespace URI. A removed
147: * attribute may be known to have a default value when this map contains
148: * the attributes attached to an element, as returned by the attributes
149: * attribute of the <code>Node</code> interface. If so, an attribute
150: * immediately appears containing the default value as well as the
151: * corresponding namespace URI, local name, and prefix when applicable.
152: * <br>Documents which do not support the "XML" feature will permit only
153: * the DOM Level 1 calls for creating/setting elements and attributes.
154: * Hence, if you specify a non-null namespace URI, these DOMs will never
155: * find a matching node.
156: * @param namespaceURI The namespace URI of the node to remove.
157: * @param localName The local name of the node to remove.
158: * @return The node removed from this map if a node with such a local
159: * name and namespace URI exists.
160: * @exception DOMException
161: * NOT_FOUND_ERR: Raised if there is no node with the specified
162: * <code>namespaceURI</code> and <code>localName</code> in this map.
163: * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.
164: * @since DOM Level 2
165: */
166: public Node removeNamedItemNS(String namespaceURI, String localName)
167: throws DOMException;
168:
169: }
|