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