Save This Page
Home » openjdk-7 » org.w3c » dom » traversal » [javadoc | source]
    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   
   46   /**
   47    * Filters are objects that know how to "filter out" nodes. If a
   48    * <code>NodeIterator</code> or <code>TreeWalker</code> is given a
   49    * <code>NodeFilter</code>, it applies the filter before it returns the next
   50    * node. If the filter says to accept the node, the traversal logic returns
   51    * it; otherwise, traversal looks for the next node and pretends that the
   52    * node that was rejected was not there.
   53    * <p>The DOM does not provide any filters. <code>NodeFilter</code> is just an
   54    * interface that users can implement to provide their own filters.
   55    * <p><code>NodeFilters</code> do not need to know how to traverse from node
   56    * to node, nor do they need to know anything about the data structure that
   57    * is being traversed. This makes it very easy to write filters, since the
   58    * only thing they have to know how to do is evaluate a single node. One
   59    * filter may be used with a number of different kinds of traversals,
   60    * encouraging code reuse.
   61    * <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>.
   62    * @since DOM Level 2
   63    */
   64   public interface NodeFilter {
   65       // Constants returned by acceptNode
   66       /**
   67        * Accept the node. Navigation methods defined for
   68        * <code>NodeIterator</code> or <code>TreeWalker</code> will return this
   69        * node.
   70        */
   71       public static final short FILTER_ACCEPT             = 1;
   72       /**
   73        * Reject the node. Navigation methods defined for
   74        * <code>NodeIterator</code> or <code>TreeWalker</code> will not return
   75        * this node. For <code>TreeWalker</code>, the children of this node
   76        * will also be rejected. <code>NodeIterators</code> treat this as a
   77        * synonym for <code>FILTER_SKIP</code>.
   78        */
   79       public static final short FILTER_REJECT             = 2;
   80       /**
   81        * Skip this single node. Navigation methods defined for
   82        * <code>NodeIterator</code> or <code>TreeWalker</code> will not return
   83        * this node. For both <code>NodeIterator</code> and
   84        * <code>TreeWalker</code>, the children of this node will still be
   85        * considered.
   86        */
   87       public static final short FILTER_SKIP               = 3;
   88   
   89       // Constants for whatToShow
   90       /**
   91        * Show all <code>Nodes</code>.
   92        */
   93       public static final int SHOW_ALL                  = 0xFFFFFFFF;
   94       /**
   95        * Show <code>Element</code> nodes.
   96        */
   97       public static final int SHOW_ELEMENT              = 0x00000001;
   98       /**
   99        * Show <code>Attr</code> nodes. This is meaningful only when creating an
  100        * <code>NodeIterator</code> or <code>TreeWalker</code> with an
  101        * attribute node as its <code>root</code>; in this case, it means that
  102        * the attribute node will appear in the first position of the iteration
  103        * or traversal. Since attributes are never children of other nodes,
  104        * they do not appear when traversing over the document tree.
  105        */
  106       public static final int SHOW_ATTRIBUTE            = 0x00000002;
  107       /**
  108        * Show <code>Text</code> nodes.
  109        */
  110       public static final int SHOW_TEXT                 = 0x00000004;
  111       /**
  112        * Show <code>CDATASection</code> nodes.
  113        */
  114       public static final int SHOW_CDATA_SECTION        = 0x00000008;
  115       /**
  116        * Show <code>EntityReference</code> nodes.
  117        */
  118       public static final int SHOW_ENTITY_REFERENCE     = 0x00000010;
  119       /**
  120        * Show <code>Entity</code> nodes. This is meaningful only when creating
  121        * an <code>NodeIterator</code> or <code>TreeWalker</code> with an
  122        * <code>Entity</code> node as its <code>root</code>; in this case, it
  123        * means that the <code>Entity</code> node will appear in the first
  124        * position of the traversal. Since entities are not part of the
  125        * document tree, they do not appear when traversing over the document
  126        * tree.
  127        */
  128       public static final int SHOW_ENTITY               = 0x00000020;
  129       /**
  130        * Show <code>ProcessingInstruction</code> nodes.
  131        */
  132       public static final int SHOW_PROCESSING_INSTRUCTION = 0x00000040;
  133       /**
  134        * Show <code>Comment</code> nodes.
  135        */
  136       public static final int SHOW_COMMENT              = 0x00000080;
  137       /**
  138        * Show <code>Document</code> nodes.
  139        */
  140       public static final int SHOW_DOCUMENT             = 0x00000100;
  141       /**
  142        * Show <code>DocumentType</code> nodes.
  143        */
  144       public static final int SHOW_DOCUMENT_TYPE        = 0x00000200;
  145       /**
  146        * Show <code>DocumentFragment</code> nodes.
  147        */
  148       public static final int SHOW_DOCUMENT_FRAGMENT    = 0x00000400;
  149       /**
  150        * Show <code>Notation</code> nodes. This is meaningful only when creating
  151        * an <code>NodeIterator</code> or <code>TreeWalker</code> with a
  152        * <code>Notation</code> node as its <code>root</code>; in this case, it
  153        * means that the <code>Notation</code> node will appear in the first
  154        * position of the traversal. Since notations are not part of the
  155        * document tree, they do not appear when traversing over the document
  156        * tree.
  157        */
  158       public static final int SHOW_NOTATION             = 0x00000800;
  159   
  160       /**
  161        * Test whether a specified node is visible in the logical view of a
  162        * <code>TreeWalker</code> or <code>NodeIterator</code>. This function
  163        * will be called by the implementation of <code>TreeWalker</code> and
  164        * <code>NodeIterator</code>; it is not normally called directly from
  165        * user code. (Though you could do so if you wanted to use the same
  166        * filter to guide your own application logic.)
  167        * @param n The node to check to see if it passes the filter or not.
  168        * @return A constant to determine whether the node is accepted,
  169        *   rejected, or skipped, as defined above.
  170        */
  171       public short acceptNode(Node n);
  172   
  173   }

Save This Page
Home » openjdk-7 » org.w3c » dom » traversal » [javadoc | source]