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 import org.w3c.dom.DOMException; 17 18 /** 19 * An <code>HTMLOptionsCollection</code> is a list of nodes representing HTML 20 * option element. An individual node may be accessed by either ordinal 21 * index or the node's <code>name</code> or <code>id</code> attributes. 22 * Collections in the HTML DOM are assumed to be live meaning that they are 23 * automatically updated when the underlying document is changed. 24 * <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>. 25 * @since DOM Level 2 26 */ 27 public interface HTMLOptionsCollection { 28 /** 29 * This attribute specifies the length or size of the list. 30 */ getLength()31 public int getLength(); 32 /** 33 * This attribute specifies the length or size of the list. 34 * @exception DOMException 35 * NOT_SUPPORTED_ERR: if setting the length is not allowed by the 36 * implementation. 37 */ setLength(int length)38 public void setLength(int length) 39 throws DOMException; 40 41 /** 42 * This method retrieves a node specified by ordinal index. Nodes are 43 * numbered in tree order (depth-first traversal order). 44 * @param index The index of the node to be fetched. The index origin is 45 * 0. 46 * @return The <code>Node</code> at the corresponding position upon 47 * success. A value of <code>null</code> is returned if the index is 48 * out of range. 49 */ item(int index)50 public Node item(int index); 51 52 /** 53 * This method retrieves a <code>Node</code> using a name. It first 54 * searches for a <code>Node</code> with a matching <code>id</code> 55 * attribute. If it doesn't find one, it then searches for a 56 * <code>Node</code> with a matching <code>name</code> attribute, but 57 * only on those elements that are allowed a name attribute. This method 58 * is case insensitive in HTML documents and case sensitive in XHTML 59 * documents. 60 * @param name The name of the <code>Node</code> to be fetched. 61 * @return The <code>Node</code> with a <code>name</code> or 62 * <code>id</code> attribute whose value corresponds to the specified 63 * string. Upon failure (e.g., no node with this name exists), returns 64 * <code>null</code>. 65 */ namedItem(String name)66 public Node namedItem(String name); 67 68 } 69