Source for org.w3c.dom.NamedNodeMap

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