1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| package org.dom4j.dom; |
11 |
| |
12 |
| import org.dom4j.Element; |
13 |
| import org.dom4j.Text; |
14 |
| import org.dom4j.tree.DefaultText; |
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 |
| |
22 |
| |
23 |
| |
24 |
| |
25 |
| |
26 |
| public class DOMText extends DefaultText implements org.w3c.dom.Text { |
27 |
| |
28 |
424
| public DOMText(String text) {
|
29 |
424
| super(text);
|
30 |
| } |
31 |
| |
32 |
0
| public DOMText(Element parent, String text) {
|
33 |
0
| super(parent, text);
|
34 |
| } |
35 |
| |
36 |
| |
37 |
| |
38 |
| |
39 |
| |
40 |
0
| public boolean supports(String feature, String version) {
|
41 |
0
| return DOMNodeHelper.supports(this, feature, version);
|
42 |
| } |
43 |
| |
44 |
0
| public String getNamespaceURI() {
|
45 |
0
| return DOMNodeHelper.getNamespaceURI(this);
|
46 |
| } |
47 |
| |
48 |
0
| public String getPrefix() {
|
49 |
0
| return DOMNodeHelper.getPrefix(this);
|
50 |
| } |
51 |
| |
52 |
0
| public void setPrefix(String prefix) throws DOMException {
|
53 |
0
| DOMNodeHelper.setPrefix(this, prefix);
|
54 |
| } |
55 |
| |
56 |
0
| public String getLocalName() {
|
57 |
0
| return DOMNodeHelper.getLocalName(this);
|
58 |
| } |
59 |
| |
60 |
0
| public String getNodeName() {
|
61 |
0
| return "#text";
|
62 |
| } |
63 |
| |
64 |
| |
65 |
| |
66 |
| |
67 |
| |
68 |
| |
69 |
| |
70 |
132
| public String getNodeValue() throws DOMException {
|
71 |
132
| return DOMNodeHelper.getNodeValue(this);
|
72 |
| } |
73 |
| |
74 |
0
| public void setNodeValue(String nodeValue) throws DOMException {
|
75 |
0
| DOMNodeHelper.setNodeValue(this, nodeValue);
|
76 |
| } |
77 |
| |
78 |
| |
79 |
28
| public org.w3c.dom.Node getParentNode() {
|
80 |
28
| return DOMNodeHelper.getParentNode(this);
|
81 |
| } |
82 |
| |
83 |
0
| public NodeList getChildNodes() {
|
84 |
0
| return DOMNodeHelper.getChildNodes(this);
|
85 |
| } |
86 |
| |
87 |
0
| public org.w3c.dom.Node getFirstChild() {
|
88 |
0
| return DOMNodeHelper.getFirstChild(this);
|
89 |
| } |
90 |
| |
91 |
0
| public org.w3c.dom.Node getLastChild() {
|
92 |
0
| return DOMNodeHelper.getLastChild(this);
|
93 |
| } |
94 |
| |
95 |
0
| public org.w3c.dom.Node getPreviousSibling() {
|
96 |
0
| return DOMNodeHelper.getPreviousSibling(this);
|
97 |
| } |
98 |
| |
99 |
0
| public org.w3c.dom.Node getNextSibling() {
|
100 |
0
| return DOMNodeHelper.getNextSibling(this);
|
101 |
| } |
102 |
| |
103 |
0
| public NamedNodeMap getAttributes() {
|
104 |
0
| return null;
|
105 |
| } |
106 |
| |
107 |
0
| public Document getOwnerDocument() {
|
108 |
0
| return DOMNodeHelper.getOwnerDocument(this);
|
109 |
| } |
110 |
| |
111 |
0
| public org.w3c.dom.Node insertBefore(
|
112 |
| org.w3c.dom.Node newChild, |
113 |
| org.w3c.dom.Node refChild |
114 |
| ) throws DOMException { |
115 |
0
| checkNewChildNode(newChild);
|
116 |
0
| return DOMNodeHelper.insertBefore(this, newChild, refChild);
|
117 |
| } |
118 |
| |
119 |
0
| public org.w3c.dom.Node replaceChild(
|
120 |
| org.w3c.dom.Node newChild, |
121 |
| org.w3c.dom.Node oldChild |
122 |
| ) throws DOMException { |
123 |
0
| checkNewChildNode(newChild);
|
124 |
0
| return DOMNodeHelper.replaceChild(this, newChild, oldChild);
|
125 |
| } |
126 |
| |
127 |
0
| public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild) throws DOMException {
|
128 |
0
| return DOMNodeHelper.removeChild(this, oldChild);
|
129 |
| } |
130 |
| |
131 |
0
| public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild) throws DOMException {
|
132 |
0
| checkNewChildNode(newChild);
|
133 |
0
| return DOMNodeHelper.appendChild(this, newChild);
|
134 |
| } |
135 |
| |
136 |
0
| private void checkNewChildNode(org.w3c.dom.Node newChild) throws DOMException {
|
137 |
0
| throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR,
|
138 |
| "Text nodes cannot have children"); |
139 |
| } |
140 |
| |
141 |
| |
142 |
0
| public boolean hasChildNodes() {
|
143 |
0
| return DOMNodeHelper.hasChildNodes(this);
|
144 |
| } |
145 |
| |
146 |
0
| public org.w3c.dom.Node cloneNode(boolean deep) {
|
147 |
0
| return DOMNodeHelper.cloneNode(this, deep);
|
148 |
| } |
149 |
| |
150 |
0
| public void normalize() {
|
151 |
0
| DOMNodeHelper.normalize(this);
|
152 |
| } |
153 |
| |
154 |
0
| public boolean isSupported(String feature, String version) {
|
155 |
0
| return DOMNodeHelper.isSupported(this, feature, version);
|
156 |
| } |
157 |
| |
158 |
0
| public boolean hasAttributes() {
|
159 |
0
| return DOMNodeHelper.hasAttributes(this);
|
160 |
| } |
161 |
| |
162 |
| |
163 |
| |
164 |
0
| public String getData() throws DOMException {
|
165 |
0
| return DOMNodeHelper.getData(this);
|
166 |
| } |
167 |
| |
168 |
0
| public void setData(String data) throws DOMException {
|
169 |
0
| DOMNodeHelper.setData(this, data);
|
170 |
| } |
171 |
| |
172 |
0
| public int getLength() {
|
173 |
0
| return DOMNodeHelper.getLength(this);
|
174 |
| } |
175 |
| |
176 |
0
| public String substringData( int offset, int count) throws DOMException {
|
177 |
0
| return DOMNodeHelper.substringData(this, offset, count);
|
178 |
| } |
179 |
| |
180 |
0
| public void appendData(String arg) throws DOMException {
|
181 |
0
| DOMNodeHelper.appendData(this, arg);
|
182 |
| } |
183 |
| |
184 |
0
| public void insertData(int offset, String arg) throws DOMException {
|
185 |
0
| DOMNodeHelper.insertData(this, offset, arg);
|
186 |
| } |
187 |
| |
188 |
0
| public void deleteData(int offset, int count) throws DOMException {
|
189 |
0
| DOMNodeHelper.deleteData(this, offset, count);
|
190 |
| } |
191 |
| |
192 |
0
| public void replaceData(
|
193 |
| int offset, int count, String arg |
194 |
| ) throws DOMException { |
195 |
0
| DOMNodeHelper.replaceData(this, offset, count, arg);
|
196 |
| } |
197 |
| |
198 |
| |
199 |
| |
200 |
0
| public org.w3c.dom.Text splitText(int offset) throws DOMException {
|
201 |
0
| if ( isReadOnly() ) {
|
202 |
0
| throw new DOMException(
|
203 |
| DOMException.NO_MODIFICATION_ALLOWED_ERR, |
204 |
| "CharacterData node is read only: " + this |
205 |
| ); |
206 |
| } |
207 |
| else { |
208 |
0
| String text = getText();
|
209 |
0
| int length = (text != null) ? text.length() : 0;
|
210 |
0
| if ( offset < 0 || offset >= length ) {
|
211 |
0
| throw new DOMException(
|
212 |
| DOMException.INDEX_SIZE_ERR, |
213 |
| "No text at offset: " + offset |
214 |
| ); |
215 |
| } |
216 |
| else { |
217 |
0
| String start = text.substring(0, offset);
|
218 |
0
| String rest = text.substring(offset);
|
219 |
0
| setText(start);
|
220 |
0
| Element parent = getParent();
|
221 |
0
| Text newText = createText(rest);
|
222 |
0
| if ( parent != null ) {
|
223 |
0
| parent.add( newText );
|
224 |
| } |
225 |
0
| return DOMNodeHelper.asDOMText( newText );
|
226 |
| } |
227 |
| } |
228 |
| } |
229 |
| |
230 |
| |
231 |
| |
232 |
0
| protected Text createText(String text) {
|
233 |
0
| return new DOMText( text );
|
234 |
| } |
235 |
| } |
236 |
| |
237 |
| |
238 |
| |
239 |
| |
240 |
| |
241 |
| |
242 |
| |
243 |
| |
244 |
| |
245 |
| |
246 |
| |
247 |
| |
248 |
| |
249 |
| |
250 |
| |
251 |
| |
252 |
| |
253 |
| |
254 |
| |
255 |
| |
256 |
| |
257 |
| |
258 |
| |
259 |
| |
260 |
| |
261 |
| |
262 |
| |
263 |
| |
264 |
| |
265 |
| |
266 |
| |
267 |
| |
268 |
| |
269 |
| |
270 |
| |
271 |
| |
272 |
| |
273 |
| |
274 |
| |
275 |
| |
276 |
| |
277 |
| |
278 |
| |
279 |
| |
280 |
| |
281 |
| |
282 |
| |
283 |
| |