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