1. /*
  2. * Copyright (c) 2000 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. See W3C License http://www.w3.org/Consortium/Legal/ for more
  10. * details.
  11. */
  12. package org.w3c.dom.html;
  13. import org.w3c.dom.Node;
  14. /**
  15. * An <code>HTMLCollection</code> is a list of nodes. An individual node may
  16. * be accessed by either ordinal index or the node's<code>name</code> or
  17. * <code>id</code> attributes. Note: Collections in the HTML DOM are assumed
  18. * to be live meaning that they are automatically updated when the
  19. * underlying document is changed.
  20. * <p>See also the <a href='http://www.w3.org/TR/2000/CR-DOM-Level-2-20000510'>Document Object Model (DOM) Level 2 Specification</a>.
  21. */
  22. public interface HTMLCollection {
  23. /**
  24. * This attribute specifies the length or size of the list.
  25. */
  26. public int getLength();
  27. /**
  28. * This method retrieves a node specified by ordinal index. Nodes are
  29. * numbered in tree order (depth-first traversal order).
  30. * @param index The index of the node to be fetched. The index origin is
  31. * 0.
  32. * @return The <code>Node</code> at the corresponding position upon
  33. * success. A value of <code>null</code> is returned if the index is
  34. * out of range.
  35. */
  36. public Node item(int index);
  37. /**
  38. * This method retrieves a <code>Node</code> using a name. It first
  39. * searches for a <code>Node</code> with a matching <code>id</code>
  40. * attribute. If it doesn't find one, it then searches for a
  41. * <code>Node</code> with a matching <code>name</code> attribute, but
  42. * only on those elements that are allowed a name attribute.
  43. * @param name The name of the <code>Node</code> to be fetched.
  44. * @return The <code>Node</code> with a <code>name</code> or
  45. * <code>id</code> attribute whose value corresponds to the specified
  46. * string. Upon failure (e.g., no node with this name exists), returns
  47. * <code>null</code> .
  48. */
  49. public Node namedItem(String name);
  50. }