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.corejs.javascript.Context;
18  import org.htmlunit.corejs.javascript.Function;
19  import org.htmlunit.corejs.javascript.Scriptable;
20  import org.htmlunit.corejs.javascript.VarScope;
21  import org.htmlunit.html.DomDocumentType;
22  import org.htmlunit.javascript.JavaScriptEngine;
23  import org.htmlunit.javascript.configuration.JsxClass;
24  import org.htmlunit.javascript.configuration.JsxConstructor;
25  import org.htmlunit.javascript.configuration.JsxFunction;
26  import org.htmlunit.javascript.configuration.JsxGetter;
27  
28  /**
29   * A JavaScript object for {@code DocumentType}.
30   *
31   * @author Ahmed Ashour
32   * @author Frank Danek
33   * @author Ronald Brill
34   * @see <a href="http://msdn.microsoft.com/en-us/library/ms762752.aspx">MSDN documentation</a>
35   * @see <a href="http://www.xulplanet.com/references/objref/DocumentType.html">XUL Planet</a>
36   */
37  @JsxClass(domClass = DomDocumentType.class)
38  public class DocumentType extends Node {
39  
40      /**
41       * Creates an instance.
42       */
43      @Override
44      @JsxConstructor
45      public void jsConstructor() {
46          throw JavaScriptEngine.typeErrorIllegalConstructor();
47      }
48  
49      /**
50       * Returns the name.
51       * @return the name
52       */
53      @JsxGetter
54      public String getName() {
55          return ((DomDocumentType) getDomNodeOrDie()).getName();
56      }
57  
58      /**
59       * {@inheritDoc}
60       */
61      @Override
62      public String getNodeName() {
63          return getName();
64      }
65  
66      /**
67       * Returns the publicId.
68       * @return the publicId
69       */
70      @JsxGetter
71      public String getPublicId() {
72          return ((DomDocumentType) getDomNodeOrDie()).getPublicId();
73      }
74  
75      /**
76       * Returns the systemId.
77       * @return the systemId
78       */
79      @JsxGetter
80      public String getSystemId() {
81          return ((DomDocumentType) getDomNodeOrDie()).getSystemId();
82      }
83  
84      /**
85       * {@inheritDoc}
86       */
87      @Override
88      @JsxFunction
89      public void remove() {
90          super.remove();
91      }
92  
93      /**
94       * Inserts a set of Node or DOMString objects in the children list of this ChildNode's parent,
95       * just before this ChildNode.
96       * @param context the context
97       * @param scope the scope
98       * @param thisObj this object
99       * @param args the arguments
100      * @param function the function
101      */
102     @JsxFunction
103     public static void before(final Context context, final VarScope scope,
104             final Scriptable thisObj, final Object[] args, final Function function) {
105         Node.before(context, thisObj, args, function);
106     }
107 
108     /**
109      * Inserts a set of Node or DOMString objects in the children list of this ChildNode's parent,
110      * just after this ChildNode.
111      * @param context the context
112      * @param scope the scope
113      * @param thisObj this object
114      * @param args the arguments
115      * @param function the function
116      */
117     @JsxFunction
118     public static void after(final Context context, final VarScope scope,
119             final Scriptable thisObj, final Object[] args, final Function function) {
120         Node.after(context, thisObj, args, function);
121     }
122 
123     /**
124      * Replaces the node wit a set of Node or DOMString objects.
125      * @param context the context
126      * @param scope the scope
127      * @param thisObj this object
128      * @param args the arguments
129      * @param function the function
130      */
131     @JsxFunction
132     public static void replaceWith(final Context context, final VarScope scope,
133             final Scriptable thisObj, final Object[] args, final Function function) {
134         Node.replaceWith(context, thisObj, args, function);
135     }
136 }