001    /*
002     * Copyright (c) 2000 World Wide Web Consortium,
003     * (Massachusetts Institute of Technology, Institut National de
004     * Recherche en Informatique et en Automatique, Keio University). All
005     * Rights Reserved. This program is distributed under the W3C's Software
006     * Intellectual Property License. This program is distributed in the
007     * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
008     * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
009     * PURPOSE.
010     * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
011     */
012    
013    package org.w3c.dom.traversal;
014    
015    import org.w3c.dom.Node;
016    import org.w3c.dom.DOMException;
017    
018    /**
019     * <code>NodeIterators</code> are used to step through a set of nodes, e.g.
020     * the set of nodes in a <code>NodeList</code>, the document subtree
021     * governed by a particular <code>Node</code>, the results of a query, or
022     * any other set of nodes. The set of nodes to be iterated is determined by
023     * the implementation of the <code>NodeIterator</code>. DOM Level 2
024     * specifies a single <code>NodeIterator</code> implementation for
025     * document-order traversal of a document subtree. Instances of these
026     * <code>NodeIterators</code> are created by calling
027     * <code>DocumentTraversal</code><code>.createNodeIterator()</code>.
028     * <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>.
029     * @since DOM Level 2
030     */
031    public interface NodeIterator {
032        /**
033         * The root node of the <code>NodeIterator</code>, as specified when it
034         * was created.
035         */
036        public Node getRoot();
037    
038        /**
039         * This attribute determines which node types are presented via the
040         * <code>NodeIterator</code>. The available set of constants is defined
041         * in the <code>NodeFilter</code> interface.  Nodes not accepted by
042         * <code>whatToShow</code> will be skipped, but their children may still
043         * be considered. Note that this skip takes precedence over the filter,
044         * if any.
045         */
046        public int getWhatToShow();
047    
048        /**
049         * The <code>NodeFilter</code> used to screen nodes.
050         */
051        public NodeFilter getFilter();
052    
053        /**
054         *  The value of this flag determines whether the children of entity
055         * reference nodes are visible to the <code>NodeIterator</code>. If
056         * false, these children  and their descendants will be rejected. Note
057         * that this rejection takes precedence over <code>whatToShow</code> and
058         * the filter. Also note that this is currently the only situation where
059         * <code>NodeIterators</code> may reject a complete subtree rather than
060         * skipping individual nodes.
061         * <br>
062         * <br> To produce a view of the document that has entity references
063         * expanded and does not expose the entity reference node itself, use
064         * the <code>whatToShow</code> flags to hide the entity reference node
065         * and set <code>expandEntityReferences</code> to true when creating the
066         * <code>NodeIterator</code>. To produce a view of the document that has
067         * entity reference nodes but no entity expansion, use the
068         * <code>whatToShow</code> flags to show the entity reference node and
069         * set <code>expandEntityReferences</code> to false.
070         */
071        public boolean getExpandEntityReferences();
072    
073        /**
074         * Returns the next node in the set and advances the position of the
075         * <code>NodeIterator</code> in the set. After a
076         * <code>NodeIterator</code> is created, the first call to
077         * <code>nextNode()</code> returns the first node in the set.
078         * @return The next <code>Node</code> in the set being iterated over, or
079         *   <code>null</code> if there are no more members in that set.
080         * @exception DOMException
081         *   INVALID_STATE_ERR: Raised if this method is called after the
082         *   <code>detach</code> method was invoked.
083         */
084        public Node nextNode()
085                             throws DOMException;
086    
087        /**
088         * Returns the previous node in the set and moves the position of the
089         * <code>NodeIterator</code> backwards in the set.
090         * @return The previous <code>Node</code> in the set being iterated over,
091         *   or <code>null</code> if there are no more members in that set.
092         * @exception DOMException
093         *   INVALID_STATE_ERR: Raised if this method is called after the
094         *   <code>detach</code> method was invoked.
095         */
096        public Node previousNode()
097                                 throws DOMException;
098    
099        /**
100         * Detaches the <code>NodeIterator</code> from the set which it iterated
101         * over, releasing any computational resources and placing the
102         * <code>NodeIterator</code> in the INVALID state. After
103         * <code>detach</code> has been invoked, calls to <code>nextNode</code>
104         * or <code>previousNode</code> will raise the exception
105         * INVALID_STATE_ERR.
106         */
107        public void detach();
108    
109    }