View Javadoc
1   /*
2    * Copyright (c) 2002-2025 Gargoyle Software Inc.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * https://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software
10   * distributed under the License is distributed on an "AS IS" BASIS,
11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   * See the License for the specific language governing permissions and
13   * limitations under the License.
14   */
15  package org.htmlunit.javascript.host.dom;
16  
17  import org.htmlunit.javascript.HtmlUnitScriptable;
18  import org.htmlunit.javascript.configuration.JsxClass;
19  import org.htmlunit.javascript.configuration.JsxConstant;
20  import org.htmlunit.javascript.configuration.JsxConstructor;
21  
22  /**
23   * A JavaScript object for {@code NodeFilter}.
24   *
25   * @see <a href="http://www.w3.org/TR/DOM-Level-2-Traversal-Range/traversal.html">
26   * DOM-Level-2-Traversal-Range</a>
27   *
28   * @author <a href="mailto:mike@10gen.com">Mike Dirolf</a>
29   * @author Ahmed Ashour
30   * @author Ronald Brill
31   */
32  @JsxClass
33  public class NodeFilter extends HtmlUnitScriptable {
34  
35      /**
36       * Accept the node.
37       */
38      @JsxConstant
39      public static final int FILTER_ACCEPT = org.w3c.dom.traversal.NodeFilter.FILTER_ACCEPT;
40  
41      /**
42       * Reject the node.
43       */
44      @JsxConstant
45      public static final int FILTER_REJECT = org.w3c.dom.traversal.NodeFilter.FILTER_REJECT;
46  
47      /**
48       * Skip the node.
49       */
50      @JsxConstant
51      public static final int FILTER_SKIP = org.w3c.dom.traversal.NodeFilter.FILTER_SKIP;
52  
53      /** Show all nodes. */
54      @JsxConstant
55      public static final long SHOW_ALL = 0xFFFFFFFFL;
56  
57      /** Show Element nodes. */
58      @JsxConstant
59      public static final int SHOW_ELEMENT = org.w3c.dom.traversal.NodeFilter.SHOW_ELEMENT;
60  
61      /**
62       * Show Attr nodes. Only useful when creating a TreeWalker with an
63       * attribute node as its root. */
64      @JsxConstant
65      public static final int SHOW_ATTRIBUTE = org.w3c.dom.traversal.NodeFilter.SHOW_ATTRIBUTE;
66  
67      /** Show Text nodes. */
68      @JsxConstant
69      public static final int SHOW_TEXT = org.w3c.dom.traversal.NodeFilter.SHOW_TEXT;
70  
71      /** Show CDATASection nodes. */
72      @JsxConstant
73      public static final int SHOW_CDATA_SECTION = org.w3c.dom.traversal.NodeFilter.SHOW_CDATA_SECTION;
74  
75      /** Show EntityReference nodes. */
76      @JsxConstant
77      public static final int SHOW_ENTITY_REFERENCE = org.w3c.dom.traversal.NodeFilter.SHOW_ENTITY_REFERENCE;
78  
79      /** Show Entity nodes. */
80      @JsxConstant
81      public static final int SHOW_ENTITY = org.w3c.dom.traversal.NodeFilter.SHOW_ENTITY;
82  
83      /** Show ProcessingInstruction nodes. */
84      @JsxConstant
85      public static final int SHOW_PROCESSING_INSTRUCTION = org.w3c.dom.traversal.NodeFilter.SHOW_PROCESSING_INSTRUCTION;
86  
87      /** Show Comment nodes. */
88      @JsxConstant
89      public static final int SHOW_COMMENT = org.w3c.dom.traversal.NodeFilter.SHOW_COMMENT;
90  
91      /** Show Document nodes. */
92      @JsxConstant
93      public static final int SHOW_DOCUMENT = org.w3c.dom.traversal.NodeFilter.SHOW_DOCUMENT;
94  
95      /** Show DocumentType nodes. */
96      @JsxConstant
97      public static final int SHOW_DOCUMENT_TYPE = org.w3c.dom.traversal.NodeFilter.SHOW_DOCUMENT_TYPE;
98  
99      /** Show DocumentFragment nodes. */
100     @JsxConstant
101     public static final int SHOW_DOCUMENT_FRAGMENT = org.w3c.dom.traversal.NodeFilter.SHOW_DOCUMENT_FRAGMENT;
102 
103     /**
104      * Show Notation nodes. Only useful when creating a TreeWalker with a
105      * Notation node as its root.
106      */
107     @JsxConstant
108     public static final int SHOW_NOTATION = org.w3c.dom.traversal.NodeFilter.SHOW_NOTATION;
109 
110     /**
111      * JavaScript constructor.
112      */
113     @JsxConstructor
114     public void jsConstructor() {
115         // nothing to do
116     }
117 }