jaxp/src/share/classes/org/w3c/dom/traversal/NodeIterator.java
changeset 6 7f561c08de6b
equal deleted inserted replaced
0:fd16c54261b3 6:7f561c08de6b
       
     1 /*
       
     2  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     3  *
       
     4  * This code is free software; you can redistribute it and/or modify it
       
     5  * under the terms of the GNU General Public License version 2 only, as
       
     6  * published by the Free Software Foundation.  Sun designates this
       
     7  * particular file as subject to the "Classpath" exception as provided
       
     8  * by Sun in the LICENSE file that accompanied this code.
       
     9  *
       
    10  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    13  * version 2 for more details (a copy is included in the LICENSE file that
       
    14  * accompanied this code).
       
    15  *
       
    16  * You should have received a copy of the GNU General Public License version
       
    17  * 2 along with this work; if not, write to the Free Software Foundation,
       
    18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    19  *
       
    20  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
       
    21  * CA 95054 USA or visit www.sun.com if you need additional information or
       
    22  * have any questions.
       
    23  */
       
    24 
       
    25 /*
       
    26  * This file is available under and governed by the GNU General Public
       
    27  * License version 2 only, as published by the Free Software Foundation.
       
    28  * However, the following notice accompanied the original version of this
       
    29  * file and, per its terms, should not be removed:
       
    30  *
       
    31  * Copyright (c) 2000 World Wide Web Consortium,
       
    32  * (Massachusetts Institute of Technology, Institut National de
       
    33  * Recherche en Informatique et en Automatique, Keio University). All
       
    34  * Rights Reserved. This program is distributed under the W3C's Software
       
    35  * Intellectual Property License. This program is distributed in the
       
    36  * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
       
    37  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
       
    38  * PURPOSE.
       
    39  * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
       
    40  */
       
    41 
       
    42 package org.w3c.dom.traversal;
       
    43 
       
    44 import org.w3c.dom.Node;
       
    45 import org.w3c.dom.DOMException;
       
    46 
       
    47 /**
       
    48  * <code>NodeIterators</code> are used to step through a set of nodes, e.g.
       
    49  * the set of nodes in a <code>NodeList</code>, the document subtree
       
    50  * governed by a particular <code>Node</code>, the results of a query, or
       
    51  * any other set of nodes. The set of nodes to be iterated is determined by
       
    52  * the implementation of the <code>NodeIterator</code>. DOM Level 2
       
    53  * specifies a single <code>NodeIterator</code> implementation for
       
    54  * document-order traversal of a document subtree. Instances of these
       
    55  * <code>NodeIterators</code> are created by calling
       
    56  * <code>DocumentTraversal</code><code>.createNodeIterator()</code>.
       
    57  * <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>.
       
    58  * @since DOM Level 2
       
    59  */
       
    60 public interface NodeIterator {
       
    61     /**
       
    62      * The root node of the <code>NodeIterator</code>, as specified when it
       
    63      * was created.
       
    64      */
       
    65     public Node getRoot();
       
    66 
       
    67     /**
       
    68      * This attribute determines which node types are presented via the
       
    69      * <code>NodeIterator</code>. The available set of constants is defined
       
    70      * in the <code>NodeFilter</code> interface.  Nodes not accepted by
       
    71      * <code>whatToShow</code> will be skipped, but their children may still
       
    72      * be considered. Note that this skip takes precedence over the filter,
       
    73      * if any.
       
    74      */
       
    75     public int getWhatToShow();
       
    76 
       
    77     /**
       
    78      * The <code>NodeFilter</code> used to screen nodes.
       
    79      */
       
    80     public NodeFilter getFilter();
       
    81 
       
    82     /**
       
    83      *  The value of this flag determines whether the children of entity
       
    84      * reference nodes are visible to the <code>NodeIterator</code>. If
       
    85      * false, these children  and their descendants will be rejected. Note
       
    86      * that this rejection takes precedence over <code>whatToShow</code> and
       
    87      * the filter. Also note that this is currently the only situation where
       
    88      * <code>NodeIterators</code> may reject a complete subtree rather than
       
    89      * skipping individual nodes.
       
    90      * <br>
       
    91      * <br> To produce a view of the document that has entity references
       
    92      * expanded and does not expose the entity reference node itself, use
       
    93      * the <code>whatToShow</code> flags to hide the entity reference node
       
    94      * and set <code>expandEntityReferences</code> to true when creating the
       
    95      * <code>NodeIterator</code>. To produce a view of the document that has
       
    96      * entity reference nodes but no entity expansion, use the
       
    97      * <code>whatToShow</code> flags to show the entity reference node and
       
    98      * set <code>expandEntityReferences</code> to false.
       
    99      */
       
   100     public boolean getExpandEntityReferences();
       
   101 
       
   102     /**
       
   103      * Returns the next node in the set and advances the position of the
       
   104      * <code>NodeIterator</code> in the set. After a
       
   105      * <code>NodeIterator</code> is created, the first call to
       
   106      * <code>nextNode()</code> returns the first node in the set.
       
   107      * @return The next <code>Node</code> in the set being iterated over, or
       
   108      *   <code>null</code> if there are no more members in that set.
       
   109      * @exception DOMException
       
   110      *   INVALID_STATE_ERR: Raised if this method is called after the
       
   111      *   <code>detach</code> method was invoked.
       
   112      */
       
   113     public Node nextNode()
       
   114                          throws DOMException;
       
   115 
       
   116     /**
       
   117      * Returns the previous node in the set and moves the position of the
       
   118      * <code>NodeIterator</code> backwards in the set.
       
   119      * @return The previous <code>Node</code> in the set being iterated over,
       
   120      *   or <code>null</code> if there are no more members in that set.
       
   121      * @exception DOMException
       
   122      *   INVALID_STATE_ERR: Raised if this method is called after the
       
   123      *   <code>detach</code> method was invoked.
       
   124      */
       
   125     public Node previousNode()
       
   126                              throws DOMException;
       
   127 
       
   128     /**
       
   129      * Detaches the <code>NodeIterator</code> from the set which it iterated
       
   130      * over, releasing any computational resources and placing the
       
   131      * <code>NodeIterator</code> in the INVALID state. After
       
   132      * <code>detach</code> has been invoked, calls to <code>nextNode</code>
       
   133      * or <code>previousNode</code> will raise the exception
       
   134      * INVALID_STATE_ERR.
       
   135      */
       
   136     public void detach();
       
   137 
       
   138 }