1
2
3
4
5
6
7
8
9
10 package org.dom4j.dom;
11
12 import java.util.Map;
13
14 import org.dom4j.Element;
15 import org.dom4j.tree.DefaultProcessingInstruction;
16 import org.w3c.dom.DOMException;
17 import org.w3c.dom.Document;
18 import org.w3c.dom.NamedNodeMap;
19 import org.w3c.dom.NodeList;
20
21 /*** <p><code>DOMProcessingInstruction</code> implements a ProcessingInstruction node which
22 * supports the W3C DOM API.</p>
23 *
24 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
25 * @version $Revision: 1.10 $
26 */
27 public class DOMProcessingInstruction extends DefaultProcessingInstruction implements org.w3c.dom.ProcessingInstruction {
28
29 public DOMProcessingInstruction(String target, Map values) {
30 super(target, values);
31 }
32
33 public DOMProcessingInstruction(String target, String values) {
34 super(target, values);
35 }
36
37 public DOMProcessingInstruction(Element parent, String target, String values) {
38 super(parent, target, values);
39 }
40
41
42
43
44 public boolean supports(String feature, String version) {
45 return DOMNodeHelper.supports(this, feature, version);
46 }
47
48 public String getNamespaceURI() {
49 return DOMNodeHelper.getNamespaceURI(this);
50 }
51
52 public String getPrefix() {
53 return DOMNodeHelper.getPrefix(this);
54 }
55
56 public void setPrefix(String prefix) throws DOMException {
57 DOMNodeHelper.setPrefix(this, prefix);
58 }
59
60 public String getLocalName() {
61 return DOMNodeHelper.getLocalName(this);
62 }
63
64 public String getNodeName() {
65 return getName();
66 }
67
68
69
70
71
72
73
74 public String getNodeValue() throws DOMException {
75 return DOMNodeHelper.getNodeValue(this);
76 }
77
78 public void setNodeValue(String nodeValue) throws DOMException {
79 DOMNodeHelper.setNodeValue(this, nodeValue);
80 }
81
82
83 public org.w3c.dom.Node getParentNode() {
84 return DOMNodeHelper.getParentNode(this);
85 }
86
87 public NodeList getChildNodes() {
88 return DOMNodeHelper.getChildNodes(this);
89 }
90
91 public org.w3c.dom.Node getFirstChild() {
92 return DOMNodeHelper.getFirstChild(this);
93 }
94
95 public org.w3c.dom.Node getLastChild() {
96 return DOMNodeHelper.getLastChild(this);
97 }
98
99 public org.w3c.dom.Node getPreviousSibling() {
100 return DOMNodeHelper.getPreviousSibling(this);
101 }
102
103 public org.w3c.dom.Node getNextSibling() {
104 return DOMNodeHelper.getNextSibling(this);
105 }
106
107 public NamedNodeMap getAttributes() {
108 return null;
109 }
110
111 public Document getOwnerDocument() {
112 return DOMNodeHelper.getOwnerDocument(this);
113 }
114
115 public org.w3c.dom.Node insertBefore(
116 org.w3c.dom.Node newChild,
117 org.w3c.dom.Node refChild
118 ) throws DOMException {
119 checkNewChildNode(newChild);
120 return DOMNodeHelper.insertBefore(this, newChild, refChild);
121 }
122
123 public org.w3c.dom.Node replaceChild(
124 org.w3c.dom.Node newChild,
125 org.w3c.dom.Node oldChild
126 ) throws DOMException {
127 checkNewChildNode(newChild);
128 return DOMNodeHelper.replaceChild(this, newChild, oldChild);
129 }
130
131 public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild) throws DOMException {
132 return DOMNodeHelper.removeChild(this, oldChild);
133 }
134
135 public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild) throws DOMException {
136 checkNewChildNode(newChild);
137 return DOMNodeHelper.appendChild(this, newChild);
138 }
139
140 private void checkNewChildNode(org.w3c.dom.Node newChild) throws DOMException {
141 throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR,
142 "ProcessingInstruction nodes cannot have children");
143 }
144
145
146 public boolean hasChildNodes() {
147 return DOMNodeHelper.hasChildNodes(this);
148 }
149
150 public org.w3c.dom.Node cloneNode(boolean deep) {
151 return DOMNodeHelper.cloneNode(this, deep);
152 }
153
154 public void normalize() {
155 DOMNodeHelper.normalize(this);
156 }
157
158 public boolean isSupported(String feature, String version) {
159 return DOMNodeHelper.isSupported(this, feature, version);
160 }
161
162 public boolean hasAttributes() {
163 return DOMNodeHelper.hasAttributes(this);
164 }
165
166
167
168
169
170
171 public String getData() {
172 return getText();
173 }
174
175 public void setData(String data) throws DOMException {
176 if ( isReadOnly() ) {
177 throw new DOMException(
178 DOMException.NO_MODIFICATION_ALLOWED_ERR,
179 "This ProcessingInstruction is read only"
180 );
181 }
182 else {
183 setText(data);
184 }
185 }
186
187
188
189 }
190
191
192
193
194
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