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.  Oracle designates this
7 * particular file as subject to the "Classpath" exception as provided
8 * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * 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
42package org.w3c.dom.traversal;
43
44import org.w3c.dom.Node;
45import org.w3c.dom.DOMException;
46
47/**
48 * <code>DocumentTraversal</code> contains methods that create
49 * <code>NodeIterators</code> and <code>TreeWalkers</code> to traverse a
50 * node and its children in document order (depth first, pre-order
51 * traversal, which is equivalent to the order in which the start tags occur
52 * in the text representation of the document). In DOMs which support the
53 * Traversal feature, <code>DocumentTraversal</code> will be implemented by
54 * the same objects that implement the Document interface.
55 * <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>.
56 * @since 9, DOM Level 2
57 */
58public interface DocumentTraversal {
59    /**
60     * Create a new <code>NodeIterator</code> over the subtree rooted at the
61     * specified node.
62     * @param root The node which will be iterated together with its
63     *   children. The <code>NodeIterator</code> is initially positioned
64     *   just before this node. The <code>whatToShow</code> flags and the
65     *   filter, if any, are not considered when setting this position. The
66     *   root must not be <code>null</code>.
67     * @param whatToShow This flag specifies which node types may appear in
68     *   the logical view of the tree presented by the
69     *   <code>NodeIterator</code>. See the description of
70     *   <code>NodeFilter</code> for the set of possible <code>SHOW_</code>
71     *   values.These flags can be combined using <code>OR</code>.
72     * @param filter The <code>NodeFilter</code> to be used with this
73     *   <code>NodeIterator</code>, or <code>null</code> to indicate no
74     *   filter.
75     * @param entityReferenceExpansion The value of this flag determines
76     *   whether entity reference nodes are expanded.
77     * @return The newly created <code>NodeIterator</code>.
78     * @exception DOMException
79     *   NOT_SUPPORTED_ERR: Raised if the specified <code>root</code> is
80     *   <code>null</code>.
81     */
82    public NodeIterator createNodeIterator(Node root,
83                                           int whatToShow,
84                                           NodeFilter filter,
85                                           boolean entityReferenceExpansion)
86                                           throws DOMException;
87
88    /**
89     * Create a new <code>TreeWalker</code> over the subtree rooted at the
90     * specified node.
91     * @param root The node which will serve as the <code>root</code> for the
92     *   <code>TreeWalker</code>. The <code>whatToShow</code> flags and the
93     *   <code>NodeFilter</code> are not considered when setting this value;
94     *   any node type will be accepted as the <code>root</code>. The
95     *   <code>currentNode</code> of the <code>TreeWalker</code> is
96     *   initialized to this node, whether or not it is visible. The
97     *   <code>root</code> functions as a stopping point for traversal
98     *   methods that look upward in the document structure, such as
99     *   <code>parentNode</code> and nextNode. The <code>root</code> must
100     *   not be <code>null</code>.
101     * @param whatToShow This flag specifies which node types may appear in
102     *   the logical view of the tree presented by the
103     *   <code>TreeWalker</code>. See the description of
104     *   <code>NodeFilter</code> for the set of possible <code>SHOW_</code>
105     *   values.These flags can be combined using <code>OR</code>.
106     * @param filter The <code>NodeFilter</code> to be used with this
107     *   <code>TreeWalker</code>, or <code>null</code> to indicate no filter.
108     * @param entityReferenceExpansion If this flag is false, the contents of
109     *   <code>EntityReference</code> nodes are not presented in the logical
110     *   view.
111     * @return The newly created <code>TreeWalker</code>.
112     * @exception DOMException
113     *    NOT_SUPPORTED_ERR: Raised if the specified <code>root</code> is
114     *   <code>null</code>.
115     */
116    public TreeWalker createTreeWalker(Node root,
117                                       int whatToShow,
118                                       NodeFilter filter,
119                                       boolean entityReferenceExpansion)
120                                       throws DOMException;
121
122}
123