1
2
3
4
5
6
7
8
9
10 package org.dom4j.dom;
11
12 import org.dom4j.Element;
13 import org.dom4j.tree.DefaultComment;
14 import org.w3c.dom.DOMException;
15 import org.w3c.dom.Document;
16 import org.w3c.dom.NamedNodeMap;
17 import org.w3c.dom.NodeList;
18
19 /*** <p><code>DOMText</code> implements a Text node which
20 * supports the W3C DOM API.</p>
21 *
22 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
23 * @version $Revision: 1.10 $
24 */
25 public class DOMComment extends DefaultComment implements org.w3c.dom.Comment {
26
27 public DOMComment(String text) {
28 super(text);
29 }
30
31 public DOMComment(Element parent,String text) {
32 super(parent, text);
33 }
34
35
36
37
38
39 public boolean supports(String feature, String version) {
40 return DOMNodeHelper.supports(this, feature, version);
41 }
42
43 public String getNamespaceURI() {
44 return DOMNodeHelper.getNamespaceURI(this);
45 }
46
47 public String getPrefix() {
48 return DOMNodeHelper.getPrefix(this);
49 }
50
51 public void setPrefix(String prefix) throws DOMException {
52 DOMNodeHelper.setPrefix(this, prefix);
53 }
54
55 public String getLocalName() {
56 return DOMNodeHelper.getLocalName(this);
57 }
58
59 public String getNodeName() {
60 return "#comment";
61 }
62
63
64
65
66
67
68
69 public String getNodeValue() throws DOMException {
70 return DOMNodeHelper.getNodeValue(this);
71 }
72
73 public void setNodeValue(String nodeValue) throws DOMException {
74 DOMNodeHelper.setNodeValue(this, nodeValue);
75 }
76
77
78 public org.w3c.dom.Node getParentNode() {
79 return DOMNodeHelper.getParentNode(this);
80 }
81
82 public NodeList getChildNodes() {
83 return DOMNodeHelper.getChildNodes(this);
84 }
85
86 public org.w3c.dom.Node getFirstChild() {
87 return DOMNodeHelper.getFirstChild(this);
88 }
89
90 public org.w3c.dom.Node getLastChild() {
91 return DOMNodeHelper.getLastChild(this);
92 }
93
94 public org.w3c.dom.Node getPreviousSibling() {
95 return DOMNodeHelper.getPreviousSibling(this);
96 }
97
98 public org.w3c.dom.Node getNextSibling() {
99 return DOMNodeHelper.getNextSibling(this);
100 }
101
102 public NamedNodeMap getAttributes() {
103 return null;
104 }
105
106 public Document getOwnerDocument() {
107 return DOMNodeHelper.getOwnerDocument(this);
108 }
109
110 public org.w3c.dom.Node insertBefore(
111 org.w3c.dom.Node newChild,
112 org.w3c.dom.Node refChild
113 ) throws DOMException {
114 checkNewChildNode(newChild);
115 return DOMNodeHelper.insertBefore(this, newChild, refChild);
116 }
117
118 public org.w3c.dom.Node replaceChild(
119 org.w3c.dom.Node newChild,
120 org.w3c.dom.Node oldChild
121 ) throws DOMException {
122 checkNewChildNode(newChild);
123 return DOMNodeHelper.replaceChild(this, newChild, oldChild);
124 }
125
126 public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild) throws DOMException {
127 return DOMNodeHelper.removeChild(this, oldChild);
128 }
129
130 public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild) throws DOMException {
131 checkNewChildNode(newChild);
132 return DOMNodeHelper.appendChild(this, newChild);
133 }
134
135 private final void checkNewChildNode(org.w3c.dom.Node newChild) throws DOMException {
136 throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR,
137 "Comment nodes cannot have children");
138 }
139
140
141 public boolean hasChildNodes() {
142 return DOMNodeHelper.hasChildNodes(this);
143 }
144
145 public org.w3c.dom.Node cloneNode(boolean deep) {
146 return DOMNodeHelper.cloneNode(this, deep);
147 }
148
149 public void normalize() {
150 DOMNodeHelper.normalize(this);
151 }
152
153 public boolean isSupported(String feature, String version) {
154 return DOMNodeHelper.isSupported(this, feature, version);
155 }
156
157 public boolean hasAttributes() {
158 return DOMNodeHelper.hasAttributes(this);
159 }
160
161
162
163 public String getData() throws DOMException {
164 return DOMNodeHelper.getData(this);
165 }
166
167 public void setData(String data) throws DOMException {
168 DOMNodeHelper.setData(this, data);
169 }
170
171 public int getLength() {
172 return DOMNodeHelper.getLength(this);
173 }
174
175 public String substringData( int offset, int count) throws DOMException {
176 return DOMNodeHelper.substringData(this, offset, count);
177 }
178
179 public void appendData(String arg) throws DOMException {
180 DOMNodeHelper.appendData(this, arg);
181 }
182
183 public void insertData(int offset, String arg) throws DOMException {
184 DOMNodeHelper.insertData(this, offset, arg);
185 }
186
187 public void deleteData(int offset, int count) throws DOMException {
188 DOMNodeHelper.deleteData(this, offset, count);
189 }
190
191 public void replaceData(
192 int offset, int count, String arg
193 ) throws DOMException {
194 DOMNodeHelper.replaceData(this, offset, count, arg);
195 }
196 }
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244