14c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson/*
24c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Licensed to the Apache Software Foundation (ASF) under one
34c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * or more contributor license agreements. See the NOTICE file
44c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * distributed with this work for additional information
54c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * regarding copyright ownership. The ASF licenses this file
64c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * to you under the Apache License, Version 2.0 (the  "License");
74c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * you may not use this file except in compliance with the License.
84c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * You may obtain a copy of the License at
94c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson *
104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson *     http://www.apache.org/licenses/LICENSE-2.0
114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson *
124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Unless required by applicable law or agreed to in writing, software
134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * distributed under the License is distributed on an "AS IS" BASIS,
144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * See the License for the specific language governing permissions and
164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * limitations under the License.
174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */
184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson/*
194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * $Id: DTMFilter.java 468653 2006-10-28 07:07:05Z minchau $
204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */
214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonpackage org.apache.xml.dtm;
224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson
234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson/**
244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Simple filter for doing node tests.  Note the semantics of this are
254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * somewhat different that the DOM's NodeFilter.
264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */
274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonpublic interface DTMFilter
284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson{
294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson
304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  // Constants for whatToShow.  These are used to set the node type that will
314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  // be traversed. These values may be ORed together before being passed to
324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  // the DTMIterator.
334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson
344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  /**
354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * Show all <code>Nodes</code>.
364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   */
374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  public static final int SHOW_ALL = 0xFFFFFFFF;
384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson
394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  /**
404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * Show <code>Element</code> nodes.
414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   */
424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  public static final int SHOW_ELEMENT = 0x00000001;
434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson
444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  /**
454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * Show <code>Attr</code> nodes. This is meaningful only when creating an
464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * iterator or tree-walker with an attribute node as its
474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * <code>root</code>; in this case, it means that the attribute node
484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * will appear in the first position of the iteration or traversal.
494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * Since attributes are never children of other nodes, they do not
504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * appear when traversing over the main document tree.
514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   */
524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  public static final int SHOW_ATTRIBUTE = 0x00000002;
534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson
544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  /**
554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * Show <code>Text</code> nodes.
564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   */
574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  public static final int SHOW_TEXT = 0x00000004;
584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson
594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  /**
604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * Show <code>CDATASection</code> nodes.
614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   */
624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  public static final int SHOW_CDATA_SECTION = 0x00000008;
634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson
644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  /**
654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * Show <code>EntityReference</code> nodes. Note that if Entity References
664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * have been fully expanded while the tree was being constructed, these
674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * nodes will not appear and this mask has no effect.
684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   */
694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  public static final int SHOW_ENTITY_REFERENCE = 0x00000010;
704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson
714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  /**
724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * Show <code>Entity</code> nodes. This is meaningful only when creating
734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * an iterator or tree-walker with an<code> Entity</code> node as its
744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * <code>root</code>; in this case, it means that the <code>Entity</code>
754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   *  node will appear in the first position of the traversal. Since
764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * entities are not part of the document tree, they do not appear when
774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * traversing over the main document tree.
784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   */
794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  public static final int SHOW_ENTITY = 0x00000020;
804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson
814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  /**
824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * Show <code>ProcessingInstruction</code> nodes.
834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   */
844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  public static final int SHOW_PROCESSING_INSTRUCTION = 0x00000040;
854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson
864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  /**
874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * Show <code>Comment</code> nodes.
884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   */
894c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  public static final int SHOW_COMMENT = 0x00000080;
904c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson
914c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  /**
924c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * Show <code>Document</code> nodes. (Of course, as with Attributes
934c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * and such, this is meaningful only when the iteration root is the
944c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * Document itself, since Document has no parent.)
954c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   */
964c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  public static final int SHOW_DOCUMENT = 0x00000100;
974c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson
984c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  /**
994c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * Show <code>DocumentType</code> nodes.
1004c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   */
1014c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  public static final int SHOW_DOCUMENT_TYPE = 0x00000200;
1024c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson
1034c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  /**
1044c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * Show <code>DocumentFragment</code> nodes. (Of course, as with
1054c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * Attributes and such, this is meaningful only when the iteration
1064c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * root is the Document itself, since DocumentFragment has no parent.)
1074c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   */
1084c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  public static final int SHOW_DOCUMENT_FRAGMENT = 0x00000400;
1094c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson
1104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  /**
1114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * Show <code>Notation</code> nodes. This is meaningful only when creating
1124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * an iterator or tree-walker with a <code>Notation</code> node as its
1134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * <code>root</code>; in this case, it means that the
1144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * <code>Notation</code> node will appear in the first position of the
1154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * traversal. Since notations are not part of the document tree, they do
1164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * not appear when traversing over the main document tree.
1174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   */
1184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  public static final int SHOW_NOTATION = 0x00000800;
1194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson
1204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  /**
1214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson
1224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * This bit instructs the iterator to show namespace nodes, which
1234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * are modeled by DTM but not by the DOM.  Make sure this does not
1244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * conflict with {@link org.w3c.dom.traversal.NodeFilter}.
1254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * <p>
1264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * %REVIEW% Might be safer to start from higher bits and work down,
1274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * to leave room for the DOM to expand its set of constants... Or,
1284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * possibly, to create a DTM-specific field for these additional bits.
1294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   */
1304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  public static final int SHOW_NAMESPACE = 0x00001000;
1314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson
1324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  /**
1334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * Special bit for filters implementing match patterns starting with
1344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * a function.  Make sure this does not conflict with
1354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * {@link org.w3c.dom.traversal.NodeFilter}.
1364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * <p>
1374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * %REVIEW% Might be safer to start from higher bits and work down,
1384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * to leave room for the DOM to expand its set of constants... Or,
1394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * possibly, to create a DTM-specific field for these additional bits.
1404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   */
1414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  public static final int SHOW_BYFUNCTION = 0x00010000;
1424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson
1434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  /**
1444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * Test whether a specified node is visible in the logical view of a
1454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * <code>DTMIterator</code>. Normally, this function
1464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * will be called by the implementation of <code>DTMIterator</code>;
1474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * it is not normally called directly from
1484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * user code.
1494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   *
1504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * @param nodeHandle int Handle of the node.
1514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * @param whatToShow one of SHOW_XXX values.
1524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * @return one of FILTER_ACCEPT, FILTER_REJECT, or FILTER_SKIP.
1534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   */
1544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  public short acceptNode(int nodeHandle, int whatToShow);
1554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson
1564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  /**
1574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * Test whether a specified node is visible in the logical view of a
1584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * <code>DTMIterator</code>. Normally, this function
1594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * will be called by the implementation of <code>DTMIterator</code>;
1604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * it is not normally called directly from
1614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * user code.
1624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * <p>
1634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * TODO: Should this be setNameMatch(expandedName) followed by accept()?
1644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * Or will we really be testing a different name at every invocation?
1654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   *
1664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * <p>%REVIEW% Under what circumstances will this be used? The cases
1674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * I've considered are just as easy and just about as efficient if
1684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * the name test is performed in the DTMIterator... -- Joe</p>
1694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   *
1704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * <p>%REVIEW% Should that 0xFFFF have a mnemonic assigned to it?
1714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * Also: This representation is assuming the expanded name is indeed
1724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * split into high/low 16-bit halfwords. If we ever change the
1734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * balance between namespace and localname bits (eg because we
1744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * decide there are many more localnames than namespaces, which is
1754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * fairly likely), this is going to break. It might be safer to
1764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * encapsulate the details with a makeExpandedName method and make
1774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * that responsible for setting up the wildcard version as well.</p>
1784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   *
1794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * @param nodeHandle int Handle of the node.
1804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * @param whatToShow one of SHOW_XXX values.
1814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * @param expandedName a value defining the exanded name as defined in
1824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   *                     the DTM interface.  Wild cards will be defined
1834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   *                     by 0xFFFF in the namespace and/or localname
1844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   *			 portion of the expandedName.
1854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson   * @return one of FILTER_ACCEPT, FILTER_REJECT, or FILTER_SKIP.  */
1864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson  public short acceptNode(int nodeHandle, int whatToShow, int expandedName);
1874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson
1884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson}
189