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