1320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson/* 2320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * Copyright (c) 2000 World Wide Web Consortium, 3320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * (Massachusetts Institute of Technology, Institut National de 4320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * Recherche en Informatique et en Automatique, Keio University). All 5320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * Rights Reserved. This program is distributed under the W3C's Software 6320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * Intellectual Property License. This program is distributed in the 7320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * hope that it will be useful, but WITHOUT ANY WARRANTY; without even 8320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 9320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * PURPOSE. 10320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * See W3C License http://www.w3.org/Consortium/Legal/ for more details. 11320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson */ 12320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson 13320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilsonpackage org.w3c.dom.traversal; 14320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson 15320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilsonimport org.w3c.dom.DOMException; 167365de1056414750d0a7d1fdd26025fd247f0d04Jesse Wilsonimport org.w3c.dom.Node; 17320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson 18320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson/** 19f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * <code>NodeIterators</code> are used to step through a set of nodes, e.g. 20f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * the set of nodes in a <code>NodeList</code>, the document subtree 21f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * governed by a particular <code>Node</code>, the results of a query, or 22f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * any other set of nodes. The set of nodes to be iterated is determined by 23f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * the implementation of the <code>NodeIterator</code>. DOM Level 2 24f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * specifies a single <code>NodeIterator</code> implementation for 25f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * document-order traversal of a document subtree. Instances of these 26f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * <code>NodeIterators</code> are created by calling 27320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * <code>DocumentTraversal</code><code>.createNodeIterator()</code>. 28320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * <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>. 29320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * @since DOM Level 2 300233201f5e7de490d3830ca96e8a18765797ea3aJesse Wilson * 310233201f5e7de490d3830ca96e8a18765797ea3aJesse Wilson * @hide 32320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson */ 33320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilsonpublic interface NodeIterator { 34320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson /** 35f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * The root node of the <code>NodeIterator</code>, as specified when it 36320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * was created. 37320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson */ 38320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson public Node getRoot(); 39320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson 40320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson /** 41f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * This attribute determines which node types are presented via the 42f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * <code>NodeIterator</code>. The available set of constants is defined 43f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * in the <code>NodeFilter</code> interface. Nodes not accepted by 44f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * <code>whatToShow</code> will be skipped, but their children may still 45f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * be considered. Note that this skip takes precedence over the filter, 46f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * if any. 47320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson */ 48320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson public int getWhatToShow(); 49320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson 50320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson /** 51320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * The <code>NodeFilter</code> used to screen nodes. 52320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson */ 53320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson public NodeFilter getFilter(); 54320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson 55320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson /** 56f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * The value of this flag determines whether the children of entity 57f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * reference nodes are visible to the <code>NodeIterator</code>. If 58f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * false, these children and their descendants will be rejected. Note 59f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * that this rejection takes precedence over <code>whatToShow</code> and 60f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * the filter. Also note that this is currently the only situation where 61f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * <code>NodeIterators</code> may reject a complete subtree rather than 62f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * skipping individual nodes. 63320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * <br> 64f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * <br> To produce a view of the document that has entity references 65f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * expanded and does not expose the entity reference node itself, use 66f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * the <code>whatToShow</code> flags to hide the entity reference node 67f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * and set <code>expandEntityReferences</code> to true when creating the 68f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * <code>NodeIterator</code>. To produce a view of the document that has 69f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * entity reference nodes but no entity expansion, use the 70f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * <code>whatToShow</code> flags to show the entity reference node and 71320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * set <code>expandEntityReferences</code> to false. 72320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson */ 73320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson public boolean getExpandEntityReferences(); 74320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson 75320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson /** 76f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * Returns the next node in the set and advances the position of the 77f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * <code>NodeIterator</code> in the set. After a 78f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * <code>NodeIterator</code> is created, the first call to 79320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * <code>nextNode()</code> returns the first node in the set. 80f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * @return The next <code>Node</code> in the set being iterated over, or 81320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * <code>null</code> if there are no more members in that set. 82320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * @exception DOMException 83f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * INVALID_STATE_ERR: Raised if this method is called after the 84320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * <code>detach</code> method was invoked. 85320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson */ 86320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson public Node nextNode() 87320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson throws DOMException; 88320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson 89320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson /** 90f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * Returns the previous node in the set and moves the position of the 91320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * <code>NodeIterator</code> backwards in the set. 92f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * @return The previous <code>Node</code> in the set being iterated over, 93f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * or <code>null</code> if there are no more members in that set. 94320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * @exception DOMException 95f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * INVALID_STATE_ERR: Raised if this method is called after the 96320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * <code>detach</code> method was invoked. 97320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson */ 98320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson public Node previousNode() 99320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson throws DOMException; 100320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson 101320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson /** 102f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * Detaches the <code>NodeIterator</code> from the set which it iterated 103f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * over, releasing any computational resources and placing the 104f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * <code>NodeIterator</code> in the INVALID state. After 105f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * <code>detach</code> has been invoked, calls to <code>nextNode</code> 106f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * or <code>previousNode</code> will raise the exception 107320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson * INVALID_STATE_ERR. 108320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson */ 109320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson public void detach(); 110320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson 111320c9890e8241fb0ad05de6fa5e6c3eb3aece159Jesse Wilson} 112