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.html;
16
17 import org.htmlunit.SgmlPage;
18 import org.w3c.dom.DocumentType;
19 import org.w3c.dom.NamedNodeMap;
20
21 /**
22 * A DOM object for DocumentType.
23 *
24 * @author Ahmed Ashour
25 * @author Ronald Brill
26 */
27 public class DomDocumentType extends DomNode implements DocumentType {
28
29 private final String name_;
30 private final String publicId_;
31 private final String systemId_;
32
33 /**
34 * Creates a new instance.
35 * @param page the page which contains this node
36 * @param name the name
37 * @param publicId the public ID
38 * @param systemId the system ID
39 */
40 public DomDocumentType(final SgmlPage page, final String name, final String publicId, final String systemId) {
41 super(page);
42 name_ = name;
43 publicId_ = publicId;
44 systemId_ = systemId;
45 }
46
47 /**
48 * {@inheritDoc}
49 */
50 @Override
51 public String getNodeName() {
52 return name_;
53 }
54
55 /**
56 * {@inheritDoc}
57 */
58 @Override
59 public short getNodeType() {
60 return DOCUMENT_TYPE_NODE;
61 }
62
63 /**
64 * {@inheritDoc}
65 */
66 @Override
67 public NamedNodeMap getEntities() {
68 return null;
69 }
70
71 /**
72 * {@inheritDoc}
73 */
74 @Override
75 public String getInternalSubset() {
76 return "";
77 }
78
79 /**
80 * {@inheritDoc}
81 */
82 @Override
83 public String getName() {
84 return name_;
85 }
86
87 /**
88 * {@inheritDoc}
89 */
90 @Override
91 public NamedNodeMap getNotations() {
92 return null;
93 }
94
95 /**
96 * {@inheritDoc}
97 */
98 @Override
99 public String getPublicId() {
100 return publicId_;
101 }
102
103 /**
104 * {@inheritDoc}
105 */
106 @Override
107 public String getSystemId() {
108 return systemId_;
109 }
110
111 /**
112 * {@inheritDoc}
113 */
114 @Override
115 public void setNodeValue(final String value) {
116 // Default behavior is to do nothing, overridden in some subclasses
117 }
118
119 /**
120 * {@inheritDoc}
121 */
122 @Override
123 public void setPrefix(final String prefix) {
124 // Empty.
125 }
126 }