Jesse Wilson | 320c989 | 2010-01-26 15:22:44 -0800 | [diff] [blame] | 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. |
| 10 | * See W3C License http://www.w3.org/Consortium/Legal/ for more details. |
| 11 | */ |
| 12 | |
| 13 | package org.w3c.dom.traversal; |
| 14 | |
| 15 | import org.w3c.dom.Node; |
| 16 | import org.w3c.dom.DOMException; |
| 17 | |
| 18 | /** |
Elliott Hughes | f33eae7 | 2010-05-13 12:36:25 -0700 | [diff] [blame^] | 19 | * <code>NodeIterators</code> are used to step through a set of nodes, e.g. |
| 20 | * the set of nodes in a <code>NodeList</code>, the document subtree |
| 21 | * governed by a particular <code>Node</code>, the results of a query, or |
| 22 | * any other set of nodes. The set of nodes to be iterated is determined by |
| 23 | * the implementation of the <code>NodeIterator</code>. DOM Level 2 |
| 24 | * specifies a single <code>NodeIterator</code> implementation for |
| 25 | * document-order traversal of a document subtree. Instances of these |
| 26 | * <code>NodeIterators</code> are created by calling |
Jesse Wilson | 320c989 | 2010-01-26 15:22:44 -0800 | [diff] [blame] | 27 | * <code>DocumentTraversal</code><code>.createNodeIterator()</code>. |
| 28 | * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113'>Document Object Model (DOM) Level 2 Traversal and Range Specification</a>. |
| 29 | * @since DOM Level 2 |
Jesse Wilson | 0233201 | 2010-02-11 16:08:33 -0800 | [diff] [blame] | 30 | * |
| 31 | * @hide |
Jesse Wilson | 320c989 | 2010-01-26 15:22:44 -0800 | [diff] [blame] | 32 | */ |
| 33 | public interface NodeIterator { |
| 34 | /** |
Elliott Hughes | f33eae7 | 2010-05-13 12:36:25 -0700 | [diff] [blame^] | 35 | * The root node of the <code>NodeIterator</code>, as specified when it |
Jesse Wilson | 320c989 | 2010-01-26 15:22:44 -0800 | [diff] [blame] | 36 | * was created. |
| 37 | */ |
| 38 | public Node getRoot(); |
| 39 | |
| 40 | /** |
Elliott Hughes | f33eae7 | 2010-05-13 12:36:25 -0700 | [diff] [blame^] | 41 | * This attribute determines which node types are presented via the |
| 42 | * <code>NodeIterator</code>. The available set of constants is defined |
| 43 | * in the <code>NodeFilter</code> interface. Nodes not accepted by |
| 44 | * <code>whatToShow</code> will be skipped, but their children may still |
| 45 | * be considered. Note that this skip takes precedence over the filter, |
| 46 | * if any. |
Jesse Wilson | 320c989 | 2010-01-26 15:22:44 -0800 | [diff] [blame] | 47 | */ |
| 48 | public int getWhatToShow(); |
| 49 | |
| 50 | /** |
| 51 | * The <code>NodeFilter</code> used to screen nodes. |
| 52 | */ |
| 53 | public NodeFilter getFilter(); |
| 54 | |
| 55 | /** |
Elliott Hughes | f33eae7 | 2010-05-13 12:36:25 -0700 | [diff] [blame^] | 56 | * The value of this flag determines whether the children of entity |
| 57 | * reference nodes are visible to the <code>NodeIterator</code>. If |
| 58 | * false, these children and their descendants will be rejected. Note |
| 59 | * that this rejection takes precedence over <code>whatToShow</code> and |
| 60 | * the filter. Also note that this is currently the only situation where |
| 61 | * <code>NodeIterators</code> may reject a complete subtree rather than |
| 62 | * skipping individual nodes. |
Jesse Wilson | 320c989 | 2010-01-26 15:22:44 -0800 | [diff] [blame] | 63 | * <br> |
Elliott Hughes | f33eae7 | 2010-05-13 12:36:25 -0700 | [diff] [blame^] | 64 | * <br> To produce a view of the document that has entity references |
| 65 | * expanded and does not expose the entity reference node itself, use |
| 66 | * the <code>whatToShow</code> flags to hide the entity reference node |
| 67 | * and set <code>expandEntityReferences</code> to true when creating the |
| 68 | * <code>NodeIterator</code>. To produce a view of the document that has |
| 69 | * entity reference nodes but no entity expansion, use the |
| 70 | * <code>whatToShow</code> flags to show the entity reference node and |
Jesse Wilson | 320c989 | 2010-01-26 15:22:44 -0800 | [diff] [blame] | 71 | * set <code>expandEntityReferences</code> to false. |
| 72 | */ |
| 73 | public boolean getExpandEntityReferences(); |
| 74 | |
| 75 | /** |
Elliott Hughes | f33eae7 | 2010-05-13 12:36:25 -0700 | [diff] [blame^] | 76 | * Returns the next node in the set and advances the position of the |
| 77 | * <code>NodeIterator</code> in the set. After a |
| 78 | * <code>NodeIterator</code> is created, the first call to |
Jesse Wilson | 320c989 | 2010-01-26 15:22:44 -0800 | [diff] [blame] | 79 | * <code>nextNode()</code> returns the first node in the set. |
Elliott Hughes | f33eae7 | 2010-05-13 12:36:25 -0700 | [diff] [blame^] | 80 | * @return The next <code>Node</code> in the set being iterated over, or |
Jesse Wilson | 320c989 | 2010-01-26 15:22:44 -0800 | [diff] [blame] | 81 | * <code>null</code> if there are no more members in that set. |
| 82 | * @exception DOMException |
Elliott Hughes | f33eae7 | 2010-05-13 12:36:25 -0700 | [diff] [blame^] | 83 | * INVALID_STATE_ERR: Raised if this method is called after the |
Jesse Wilson | 320c989 | 2010-01-26 15:22:44 -0800 | [diff] [blame] | 84 | * <code>detach</code> method was invoked. |
| 85 | */ |
| 86 | public Node nextNode() |
| 87 | throws DOMException; |
| 88 | |
| 89 | /** |
Elliott Hughes | f33eae7 | 2010-05-13 12:36:25 -0700 | [diff] [blame^] | 90 | * Returns the previous node in the set and moves the position of the |
Jesse Wilson | 320c989 | 2010-01-26 15:22:44 -0800 | [diff] [blame] | 91 | * <code>NodeIterator</code> backwards in the set. |
Elliott Hughes | f33eae7 | 2010-05-13 12:36:25 -0700 | [diff] [blame^] | 92 | * @return The previous <code>Node</code> in the set being iterated over, |
| 93 | * or <code>null</code> if there are no more members in that set. |
Jesse Wilson | 320c989 | 2010-01-26 15:22:44 -0800 | [diff] [blame] | 94 | * @exception DOMException |
Elliott Hughes | f33eae7 | 2010-05-13 12:36:25 -0700 | [diff] [blame^] | 95 | * INVALID_STATE_ERR: Raised if this method is called after the |
Jesse Wilson | 320c989 | 2010-01-26 15:22:44 -0800 | [diff] [blame] | 96 | * <code>detach</code> method was invoked. |
| 97 | */ |
| 98 | public Node previousNode() |
| 99 | throws DOMException; |
| 100 | |
| 101 | /** |
Elliott Hughes | f33eae7 | 2010-05-13 12:36:25 -0700 | [diff] [blame^] | 102 | * Detaches the <code>NodeIterator</code> from the set which it iterated |
| 103 | * over, releasing any computational resources and placing the |
| 104 | * <code>NodeIterator</code> in the INVALID state. After |
| 105 | * <code>detach</code> has been invoked, calls to <code>nextNode</code> |
| 106 | * or <code>previousNode</code> will raise the exception |
Jesse Wilson | 320c989 | 2010-01-26 15:22:44 -0800 | [diff] [blame] | 107 | * INVALID_STATE_ERR. |
| 108 | */ |
| 109 | public void detach(); |
| 110 | |
| 111 | } |