Source for org.w3c.dom.html2.HTMLCollection

   1: /*
   2:  * Copyright (c) 2003 World Wide Web Consortium,
   3:  * (Massachusetts Institute of Technology, Institut National de
   4:  * Recherche en Informatique et en Automatique, Keio University). All
   5:  * Rights Reserved. This program is distributed under the W3C's Software
   6:  * Intellectual Property License. This program is distributed in the
   7:  * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   8:  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   9:  * PURPOSE.
  10:  * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
  11:  */
  12: 
  13: package org.w3c.dom.html2;
  14: 
  15: import org.w3c.dom.Node;
  16: 
  17: /**
  18:  * An <code>HTMLCollection</code> is a list of nodes. An individual node may 
  19:  * be accessed by either ordinal index or the node's <code>name</code> or 
  20:  * <code>id</code> attributes. Collections in the HTML DOM are assumed to be 
  21:  * live meaning that they are automatically updated when the underlying 
  22:  * document is changed. 
  23:  * <p>See also the <a href='http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109'>Document Object Model (DOM) Level 2 HTML Specification</a>.
  24:  */
  25: public interface HTMLCollection {
  26:     /**
  27:      * This attribute specifies the length or size of the list. 
  28:      */
  29:     public int getLength();
  30: 
  31:     /**
  32:      * This method retrieves a node specified by ordinal index. Nodes are 
  33:      * numbered in tree order (depth-first traversal order).
  34:      * @param index The index of the node to be fetched. The index origin is 
  35:      *   <code>0</code>.
  36:      * @return The <code>Node</code> at the corresponding position upon 
  37:      *   success. A value of <code>null</code> is returned if the index is 
  38:      *   out of range. 
  39:      */
  40:     public Node item(int index);
  41: 
  42:     /**
  43:      * This method retrieves a <code>Node</code> using a name. With [<a href='http://www.w3.org/TR/1999/REC-html401-19991224'>HTML 4.01</a>] 
  44:      * documents, it first searches for a <code>Node</code> with a matching 
  45:      * <code>id</code> attribute. If it doesn't find one, it then searches 
  46:      * for a <code>Node</code> with a matching <code>name</code> attribute, 
  47:      * but only on those elements that are allowed a name attribute. With [<a href='http://www.w3.org/TR/2002/REC-xhtml1-20020801'>XHTML 1.0</a>] 
  48:      * documents, this method only searches for <code>Nodes</code> with a 
  49:      * matching <code>id</code> attribute. This method is case insensitive 
  50:      * in HTML documents and case sensitive in XHTML documents.
  51:      * @param name The name of the <code>Node</code> to be fetched.
  52:      * @return The <code>Node</code> with a <code>name</code> or 
  53:      *   <code>id</code> attribute whose value corresponds to the specified 
  54:      *   string. Upon failure (e.g., no node with this name exists), returns 
  55:      *   <code>null</code>.
  56:      */
  57:     public Node namedItem(String name);
  58: 
  59: }