286N/A/*
286N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
286N/A *
286N/A * This code is free software; you can redistribute it and/or modify it
286N/A * under the terms of the GNU General Public License version 2 only, as
286N/A * published by the Free Software Foundation. Oracle designates this
286N/A * particular file as subject to the "Classpath" exception as provided
286N/A * by Oracle in the LICENSE file that accompanied this code.
286N/A *
286N/A * This code is distributed in the hope that it will be useful, but WITHOUT
286N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
286N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
286N/A * version 2 for more details (a copy is included in the LICENSE file that
286N/A * accompanied this code).
286N/A *
286N/A * You should have received a copy of the GNU General Public License version
286N/A * 2 along with this work; if not, write to the Free Software Foundation,
286N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
286N/A *
286N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
286N/A * or visit www.oracle.com if you need additional information or have any
286N/A * questions.
286N/A */
286N/A
286N/A/*
286N/A * This file is available under and governed by the GNU General Public
286N/A * License version 2 only, as published by the Free Software Foundation.
286N/A * However, the following notice accompanied the original version of this
286N/A * file and, per its terms, should not be removed:
286N/A *
286N/A * Copyright (c) 2000 World Wide Web Consortium,
286N/A * (Massachusetts Institute of Technology, Institut National de
286N/A * Recherche en Informatique et en Automatique, Keio University). All
286N/A * Rights Reserved. This program is distributed under the W3C's Software
286N/A * Intellectual Property License. This program is distributed in the
286N/A * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
286N/A * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
286N/A * PURPOSE.
286N/A * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
286N/A */
286N/A
286N/Apackage org.w3c.dom.traversal;
286N/A
286N/Aimport org.w3c.dom.Node;
286N/Aimport org.w3c.dom.DOMException;
286N/A
286N/A/**
286N/A * <code>TreeWalker</code> objects are used to navigate a document tree or
286N/A * subtree using the view of the document defined by their
286N/A * <code>whatToShow</code> flags and filter (if any). Any function which
286N/A * performs navigation using a <code>TreeWalker</code> will automatically
286N/A * support any view defined by a <code>TreeWalker</code>.
286N/A * <p>Omitting nodes from the logical view of a subtree can result in a
286N/A * structure that is substantially different from the same subtree in the
286N/A * complete, unfiltered document. Nodes that are siblings in the
286N/A * <code>TreeWalker</code> view may be children of different, widely
286N/A * separated nodes in the original view. For instance, consider a
286N/A * <code>NodeFilter</code> that skips all nodes except for Text nodes and
286N/A * the root node of a document. In the logical view that results, all text
286N/A * nodes will be siblings and appear as direct children of the root node, no
286N/A * matter how deeply nested the structure of the original document.
286N/A * <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>.
286N/A * @since DOM Level 2
286N/A */
286N/Apublic interface TreeWalker {
286N/A /**
286N/A * The <code>root</code> node of the <code>TreeWalker</code>, as specified
286N/A * when it was created.
286N/A */
286N/A public Node getRoot();
286N/A
286N/A /**
286N/A * This attribute determines which node types are presented via the
286N/A * <code>TreeWalker</code>. The available set of constants is defined in
286N/A * the <code>NodeFilter</code> interface. Nodes not accepted by
286N/A * <code>whatToShow</code> will be skipped, but their children may still
286N/A * be considered. Note that this skip takes precedence over the filter,
286N/A * if any.
286N/A */
286N/A public int getWhatToShow();
286N/A
286N/A /**
286N/A * The filter used to screen nodes.
286N/A */
286N/A public NodeFilter getFilter();
286N/A
286N/A /**
286N/A * The value of this flag determines whether the children of entity
286N/A * reference nodes are visible to the <code>TreeWalker</code>. If false,
286N/A * these children and their descendants will be rejected. Note that
286N/A * this rejection takes precedence over <code>whatToShow</code> and the
286N/A * filter, if any.
286N/A * <br> To produce a view of the document that has entity references
286N/A * expanded and does not expose the entity reference node itself, use
286N/A * the <code>whatToShow</code> flags to hide the entity reference node
286N/A * and set <code>expandEntityReferences</code> to true when creating the
286N/A * <code>TreeWalker</code>. To produce a view of the document that has
286N/A * entity reference nodes but no entity expansion, use the
286N/A * <code>whatToShow</code> flags to show the entity reference node and
286N/A * set <code>expandEntityReferences</code> to false.
286N/A */
286N/A public boolean getExpandEntityReferences();
286N/A
286N/A /**
286N/A * The node at which the <code>TreeWalker</code> is currently positioned.
286N/A * <br>Alterations to the DOM tree may cause the current node to no longer
286N/A * be accepted by the <code>TreeWalker</code>'s associated filter.
286N/A * <code>currentNode</code> may also be explicitly set to any node,
286N/A * whether or not it is within the subtree specified by the
286N/A * <code>root</code> node or would be accepted by the filter and
286N/A * <code>whatToShow</code> flags. Further traversal occurs relative to
286N/A * <code>currentNode</code> even if it is not part of the current view,
286N/A * by applying the filters in the requested direction; if no traversal
286N/A * is possible, <code>currentNode</code> is not changed.
286N/A */
286N/A public Node getCurrentNode();
286N/A /**
286N/A * The node at which the <code>TreeWalker</code> is currently positioned.
286N/A * <br>Alterations to the DOM tree may cause the current node to no longer
286N/A * be accepted by the <code>TreeWalker</code>'s associated filter.
286N/A * <code>currentNode</code> may also be explicitly set to any node,
286N/A * whether or not it is within the subtree specified by the
286N/A * <code>root</code> node or would be accepted by the filter and
286N/A * <code>whatToShow</code> flags. Further traversal occurs relative to
286N/A * <code>currentNode</code> even if it is not part of the current view,
286N/A * by applying the filters in the requested direction; if no traversal
286N/A * is possible, <code>currentNode</code> is not changed.
286N/A * @exception DOMException
286N/A * NOT_SUPPORTED_ERR: Raised if an attempt is made to set
286N/A * <code>currentNode</code> to <code>null</code>.
286N/A */
286N/A public void setCurrentNode(Node currentNode)
286N/A throws DOMException;
286N/A
286N/A /**
286N/A * Moves to and returns the closest visible ancestor node of the current
286N/A * node. If the search for <code>parentNode</code> attempts to step
286N/A * upward from the <code>TreeWalker</code>'s <code>root</code> node, or
286N/A * if it fails to find a visible ancestor node, this method retains the
286N/A * current position and returns <code>null</code>.
286N/A * @return The new parent node, or <code>null</code> if the current node
286N/A * has no parent in the <code>TreeWalker</code>'s logical view.
286N/A */
286N/A public Node parentNode();
286N/A
286N/A /**
286N/A * Moves the <code>TreeWalker</code> to the first visible child of the
286N/A * current node, and returns the new node. If the current node has no
286N/A * visible children, returns <code>null</code>, and retains the current
286N/A * node.
286N/A * @return The new node, or <code>null</code> if the current node has no
286N/A * visible children in the <code>TreeWalker</code>'s logical view.
286N/A */
286N/A public Node firstChild();
286N/A
286N/A /**
286N/A * Moves the <code>TreeWalker</code> to the last visible child of the
286N/A * current node, and returns the new node. If the current node has no
286N/A * visible children, returns <code>null</code>, and retains the current
286N/A * node.
286N/A * @return The new node, or <code>null</code> if the current node has no
286N/A * children in the <code>TreeWalker</code>'s logical view.
286N/A */
286N/A public Node lastChild();
286N/A
286N/A /**
286N/A * Moves the <code>TreeWalker</code> to the previous sibling of the
286N/A * current node, and returns the new node. If the current node has no
286N/A * visible previous sibling, returns <code>null</code>, and retains the
286N/A * current node.
286N/A * @return The new node, or <code>null</code> if the current node has no
286N/A * previous sibling. in the <code>TreeWalker</code>'s logical view.
286N/A */
286N/A public Node previousSibling();
286N/A
286N/A /**
286N/A * Moves the <code>TreeWalker</code> to the next sibling of the current
286N/A * node, and returns the new node. If the current node has no visible
286N/A * next sibling, returns <code>null</code>, and retains the current node.
286N/A * @return The new node, or <code>null</code> if the current node has no
286N/A * next sibling. in the <code>TreeWalker</code>'s logical view.
286N/A */
286N/A public Node nextSibling();
286N/A
286N/A /**
286N/A * Moves the <code>TreeWalker</code> to the previous visible node in
286N/A * document order relative to the current node, and returns the new
286N/A * node. If the current node has no previous node, or if the search for
286N/A * <code>previousNode</code> attempts to step upward from the
286N/A * <code>TreeWalker</code>'s <code>root</code> node, returns
286N/A * <code>null</code>, and retains the current node.
286N/A * @return The new node, or <code>null</code> if the current node has no
286N/A * previous node in the <code>TreeWalker</code>'s logical view.
286N/A */
286N/A public Node previousNode();
286N/A
286N/A /**
286N/A * Moves the <code>TreeWalker</code> to the next visible node in document
286N/A * order relative to the current node, and returns the new node. If the
286N/A * current node has no next node, or if the search for nextNode attempts
286N/A * to step upward from the <code>TreeWalker</code>'s <code>root</code>
286N/A * node, returns <code>null</code>, and retains the current node.
286N/A * @return The new node, or <code>null</code> if the current node has no
286N/A * next node in the <code>TreeWalker</code>'s logical view.
286N/A */
286N/A public Node nextNode();
286N/A
286N/A}