View Javadoc
1   /*
2    * Copyright (c) 2002-2026 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="https://developer.mozilla.org/en-US/docs/Web/API/NodeFilter">MDN Documentation</a>
26   * @see <a href="http://www.w3.org/TR/DOM-Level-2-Traversal-Range/traversal.html">
27   *     DOM-Level-2-Traversal-Range</a>
28   *
29   * @author Mike Dirolf
30   * @author Ahmed Ashour
31   * @author Ronald Brill
32   */
33  @JsxClass
34  public class NodeFilter extends HtmlUnitScriptable {
35  
36      /**
37       * Accept the node.
38       */
39      @JsxConstant
40      public static final int FILTER_ACCEPT = org.w3c.dom.traversal.NodeFilter.FILTER_ACCEPT;
41  
42      /**
43       * Reject the node.
44       */
45      @JsxConstant
46      public static final int FILTER_REJECT = org.w3c.dom.traversal.NodeFilter.FILTER_REJECT;
47  
48      /**
49       * Skip the node.
50       */
51      @JsxConstant
52      public static final int FILTER_SKIP = org.w3c.dom.traversal.NodeFilter.FILTER_SKIP;
53  
54      /** Show all nodes. */
55      @JsxConstant
56      public static final long SHOW_ALL = 0xFFFFFFFFL;
57  
58      /** Show Element nodes. */
59      @JsxConstant
60      public static final int SHOW_ELEMENT = org.w3c.dom.traversal.NodeFilter.SHOW_ELEMENT;
61  
62      /**
63       * Show Attr nodes. Only useful when creating a TreeWalker with an
64       * attribute node as its root. */
65      @JsxConstant
66      public static final int SHOW_ATTRIBUTE = org.w3c.dom.traversal.NodeFilter.SHOW_ATTRIBUTE;
67  
68      /** Show Text nodes. */
69      @JsxConstant
70      public static final int SHOW_TEXT = org.w3c.dom.traversal.NodeFilter.SHOW_TEXT;
71  
72      /** Show CDATASection nodes. */
73      @JsxConstant
74      public static final int SHOW_CDATA_SECTION = org.w3c.dom.traversal.NodeFilter.SHOW_CDATA_SECTION;
75  
76      /** Show EntityReference nodes. */
77      @JsxConstant
78      public static final int SHOW_ENTITY_REFERENCE = org.w3c.dom.traversal.NodeFilter.SHOW_ENTITY_REFERENCE;
79  
80      /** Show Entity nodes. */
81      @JsxConstant
82      public static final int SHOW_ENTITY = org.w3c.dom.traversal.NodeFilter.SHOW_ENTITY;
83  
84      /** Show ProcessingInstruction nodes. */
85      @JsxConstant
86      public static final int SHOW_PROCESSING_INSTRUCTION = org.w3c.dom.traversal.NodeFilter.SHOW_PROCESSING_INSTRUCTION;
87  
88      /** Show Comment nodes. */
89      @JsxConstant
90      public static final int SHOW_COMMENT = org.w3c.dom.traversal.NodeFilter.SHOW_COMMENT;
91  
92      /** Show Document nodes. */
93      @JsxConstant
94      public static final int SHOW_DOCUMENT = org.w3c.dom.traversal.NodeFilter.SHOW_DOCUMENT;
95  
96      /** Show DocumentType nodes. */
97      @JsxConstant
98      public static final int SHOW_DOCUMENT_TYPE = org.w3c.dom.traversal.NodeFilter.SHOW_DOCUMENT_TYPE;
99  
100     /** Show DocumentFragment nodes. */
101     @JsxConstant
102     public static final int SHOW_DOCUMENT_FRAGMENT = org.w3c.dom.traversal.NodeFilter.SHOW_DOCUMENT_FRAGMENT;
103 
104     /**
105      * Show Notation nodes. Only useful when creating a TreeWalker with a
106      * Notation node as its root.
107      */
108     @JsxConstant
109     public static final int SHOW_NOTATION = org.w3c.dom.traversal.NodeFilter.SHOW_NOTATION;
110 
111     /**
112      * JavaScript constructor.
113      */
114     @JsxConstructor
115     public void jsConstructor() {
116         // nothing to do
117     }
118 }