1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| |
19 |
| |
20 |
| |
21 |
| |
22 |
| |
23 |
| |
24 |
| |
25 |
| |
26 |
| |
27 |
| |
28 |
| |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| |
34 |
| |
35 |
| |
36 |
| |
37 |
| |
38 |
| |
39 |
| |
40 |
| |
41 |
| |
42 |
| |
43 |
| |
44 |
| |
45 |
| |
46 |
| |
47 |
| |
48 |
| |
49 |
| |
50 |
| |
51 |
| |
52 |
| |
53 |
| |
54 |
| package org.w3c.tidy; |
55 |
| |
56 |
| import org.w3c.dom.Attr; |
57 |
| import org.w3c.dom.DOMException; |
58 |
| import org.w3c.dom.TypeInfo; |
59 |
| |
60 |
| |
61 |
| |
62 |
| |
63 |
| |
64 |
| |
65 |
| |
66 |
| |
67 |
| |
68 |
| public class DOMElementImpl extends DOMNodeImpl implements org.w3c.dom.Element |
69 |
| { |
70 |
| |
71 |
| |
72 |
| |
73 |
| |
74 |
| |
75 |
0
| protected DOMElementImpl(Node adaptee)
|
76 |
| { |
77 |
0
| super(adaptee);
|
78 |
| } |
79 |
| |
80 |
| |
81 |
| |
82 |
| |
83 |
0
| public short getNodeType()
|
84 |
| { |
85 |
0
| return org.w3c.dom.Node.ELEMENT_NODE;
|
86 |
| } |
87 |
| |
88 |
| |
89 |
| |
90 |
| |
91 |
0
| public String getTagName()
|
92 |
| { |
93 |
0
| return super.getNodeName();
|
94 |
| } |
95 |
| |
96 |
| |
97 |
| |
98 |
| |
99 |
0
| public String getAttribute(String name)
|
100 |
| { |
101 |
0
| if (this.adaptee == null)
|
102 |
| { |
103 |
0
| return null;
|
104 |
| } |
105 |
| |
106 |
0
| AttVal att = this.adaptee.attributes;
|
107 |
0
| while (att != null)
|
108 |
| { |
109 |
0
| if (att.attribute.equals(name))
|
110 |
| { |
111 |
0
| break;
|
112 |
| } |
113 |
0
| att = att.next;
|
114 |
| } |
115 |
0
| if (att != null)
|
116 |
| { |
117 |
0
| return att.value;
|
118 |
| } |
119 |
| |
120 |
0
| return "";
|
121 |
| } |
122 |
| |
123 |
| |
124 |
| |
125 |
| |
126 |
0
| public void setAttribute(String name, String value) throws DOMException
|
127 |
| { |
128 |
0
| if (this.adaptee == null)
|
129 |
| { |
130 |
0
| return;
|
131 |
| } |
132 |
| |
133 |
0
| AttVal att = this.adaptee.attributes;
|
134 |
0
| while (att != null)
|
135 |
| { |
136 |
0
| if (att.attribute.equals(name))
|
137 |
| { |
138 |
0
| break;
|
139 |
| } |
140 |
0
| att = att.next;
|
141 |
| } |
142 |
0
| if (att != null)
|
143 |
| { |
144 |
0
| att.value = value;
|
145 |
| } |
146 |
| else |
147 |
| { |
148 |
0
| att = new AttVal(null, null, '"', name, value);
|
149 |
0
| att.dict = AttributeTable.getDefaultAttributeTable().findAttribute(att);
|
150 |
0
| if (this.adaptee.attributes == null)
|
151 |
| { |
152 |
0
| this.adaptee.attributes = att;
|
153 |
| } |
154 |
| else |
155 |
| { |
156 |
0
| att.next = this.adaptee.attributes;
|
157 |
0
| this.adaptee.attributes = att;
|
158 |
| } |
159 |
| } |
160 |
| } |
161 |
| |
162 |
| |
163 |
| |
164 |
| |
165 |
0
| public void removeAttribute(String name) throws DOMException
|
166 |
| { |
167 |
0
| if (this.adaptee == null)
|
168 |
| { |
169 |
0
| return;
|
170 |
| } |
171 |
| |
172 |
0
| AttVal att = this.adaptee.attributes;
|
173 |
0
| AttVal pre = null;
|
174 |
0
| while (att != null)
|
175 |
| { |
176 |
0
| if (att.attribute.equals(name))
|
177 |
| { |
178 |
0
| break;
|
179 |
| } |
180 |
0
| pre = att;
|
181 |
0
| att = att.next;
|
182 |
| } |
183 |
0
| if (att != null)
|
184 |
| { |
185 |
0
| if (pre == null)
|
186 |
| { |
187 |
0
| this.adaptee.attributes = att.next;
|
188 |
| } |
189 |
| else |
190 |
| { |
191 |
0
| pre.next = att.next;
|
192 |
| } |
193 |
| } |
194 |
| } |
195 |
| |
196 |
| |
197 |
| |
198 |
| |
199 |
0
| public org.w3c.dom.Attr getAttributeNode(String name)
|
200 |
| { |
201 |
0
| if (this.adaptee == null)
|
202 |
| { |
203 |
0
| return null;
|
204 |
| } |
205 |
| |
206 |
0
| AttVal att = this.adaptee.attributes;
|
207 |
0
| while (att != null)
|
208 |
| { |
209 |
0
| if (att.attribute.equals(name))
|
210 |
| { |
211 |
0
| break;
|
212 |
| } |
213 |
0
| att = att.next;
|
214 |
| } |
215 |
0
| if (att != null)
|
216 |
| { |
217 |
0
| return att.getAdapter();
|
218 |
| } |
219 |
| |
220 |
0
| return null;
|
221 |
| } |
222 |
| |
223 |
| |
224 |
| |
225 |
| |
226 |
0
| public org.w3c.dom.Attr setAttributeNode(org.w3c.dom.Attr newAttr) throws DOMException
|
227 |
| { |
228 |
0
| if (newAttr == null)
|
229 |
| { |
230 |
0
| return null;
|
231 |
| } |
232 |
0
| if (!(newAttr instanceof DOMAttrImpl))
|
233 |
| { |
234 |
0
| throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, "newAttr not instanceof DOMAttrImpl");
|
235 |
| } |
236 |
| |
237 |
0
| DOMAttrImpl newatt = (DOMAttrImpl) newAttr;
|
238 |
0
| String name = newatt.avAdaptee.attribute;
|
239 |
0
| org.w3c.dom.Attr result = null;
|
240 |
| |
241 |
0
| AttVal att = this.adaptee.attributes;
|
242 |
0
| while (att != null)
|
243 |
| { |
244 |
0
| if (att.attribute.equals(name))
|
245 |
| { |
246 |
0
| break;
|
247 |
| } |
248 |
0
| att = att.next;
|
249 |
| } |
250 |
0
| if (att != null)
|
251 |
| { |
252 |
0
| result = att.getAdapter();
|
253 |
0
| att.adapter = newAttr;
|
254 |
| } |
255 |
| else |
256 |
| { |
257 |
0
| if (this.adaptee.attributes == null)
|
258 |
| { |
259 |
0
| this.adaptee.attributes = newatt.avAdaptee;
|
260 |
| } |
261 |
| else |
262 |
| { |
263 |
0
| newatt.avAdaptee.next = this.adaptee.attributes;
|
264 |
0
| this.adaptee.attributes = newatt.avAdaptee;
|
265 |
| } |
266 |
| } |
267 |
0
| return result;
|
268 |
| } |
269 |
| |
270 |
| |
271 |
| |
272 |
| |
273 |
0
| public org.w3c.dom.Attr removeAttributeNode(org.w3c.dom.Attr oldAttr) throws DOMException
|
274 |
| { |
275 |
0
| if (oldAttr == null)
|
276 |
| { |
277 |
0
| return null;
|
278 |
| } |
279 |
| |
280 |
0
| org.w3c.dom.Attr result = null;
|
281 |
0
| AttVal att = this.adaptee.attributes;
|
282 |
0
| AttVal pre = null;
|
283 |
0
| while (att != null)
|
284 |
| { |
285 |
0
| if (att.getAdapter() == oldAttr)
|
286 |
| { |
287 |
0
| break;
|
288 |
| } |
289 |
0
| pre = att;
|
290 |
0
| att = att.next;
|
291 |
| } |
292 |
0
| if (att != null)
|
293 |
| { |
294 |
0
| if (pre == null)
|
295 |
| { |
296 |
0
| this.adaptee.attributes = att.next;
|
297 |
| } |
298 |
| else |
299 |
| { |
300 |
0
| pre.next = att.next;
|
301 |
| } |
302 |
0
| result = oldAttr;
|
303 |
| } |
304 |
| else |
305 |
| { |
306 |
0
| throw new DOMException(DOMException.NOT_FOUND_ERR, "oldAttr not found");
|
307 |
| } |
308 |
0
| return result;
|
309 |
| } |
310 |
| |
311 |
| |
312 |
| |
313 |
| |
314 |
0
| public org.w3c.dom.NodeList getElementsByTagName(String name)
|
315 |
| { |
316 |
0
| return new DOMNodeListByTagNameImpl(this.adaptee, name);
|
317 |
| } |
318 |
| |
319 |
| |
320 |
| |
321 |
| |
322 |
| |
323 |
0
| public void normalize()
|
324 |
| { |
325 |
| |
326 |
| } |
327 |
| |
328 |
| |
329 |
| |
330 |
| |
331 |
| |
332 |
0
| public String getAttributeNS(String namespaceURI, String localName)
|
333 |
| { |
334 |
| |
335 |
| |
336 |
0
| throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "DOM method not supported");
|
337 |
| } |
338 |
| |
339 |
| |
340 |
| |
341 |
| |
342 |
| |
343 |
0
| public void setAttributeNS(String namespaceURI, String qualifiedName, String value) throws org.w3c.dom.DOMException
|
344 |
| { |
345 |
0
| throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "DOM method not supported");
|
346 |
| } |
347 |
| |
348 |
| |
349 |
| |
350 |
| |
351 |
| |
352 |
0
| public void removeAttributeNS(String namespaceURI, String localName) throws org.w3c.dom.DOMException
|
353 |
| { |
354 |
0
| throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "DOM method not supported");
|
355 |
| } |
356 |
| |
357 |
| |
358 |
| |
359 |
| |
360 |
| |
361 |
0
| public org.w3c.dom.Attr getAttributeNodeNS(String namespaceURI, String localName)
|
362 |
| { |
363 |
0
| throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "DOM method not supported");
|
364 |
| } |
365 |
| |
366 |
| |
367 |
| |
368 |
| |
369 |
| |
370 |
0
| public org.w3c.dom.Attr setAttributeNodeNS(org.w3c.dom.Attr newAttr) throws org.w3c.dom.DOMException
|
371 |
| { |
372 |
0
| throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "DOM method not supported");
|
373 |
| } |
374 |
| |
375 |
| |
376 |
| |
377 |
| |
378 |
| |
379 |
0
| public org.w3c.dom.NodeList getElementsByTagNameNS(String namespaceURI, String localName)
|
380 |
| { |
381 |
0
| throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "DOM method not supported");
|
382 |
| } |
383 |
| |
384 |
| |
385 |
| |
386 |
| |
387 |
| |
388 |
0
| public boolean hasAttribute(String name)
|
389 |
| { |
390 |
0
| return false;
|
391 |
| } |
392 |
| |
393 |
| |
394 |
| |
395 |
| |
396 |
| |
397 |
0
| public boolean hasAttributeNS(String namespaceURI, String localName)
|
398 |
| { |
399 |
0
| return false;
|
400 |
| } |
401 |
| |
402 |
| |
403 |
| |
404 |
| |
405 |
| |
406 |
0
| public TypeInfo getSchemaTypeInfo()
|
407 |
| { |
408 |
0
| return null;
|
409 |
| } |
410 |
| |
411 |
| |
412 |
| |
413 |
| |
414 |
| |
415 |
0
| public void setIdAttribute(String name, boolean isId) throws DOMException
|
416 |
| { |
417 |
0
| throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "DOM method not supported");
|
418 |
| } |
419 |
| |
420 |
| |
421 |
| |
422 |
| |
423 |
| |
424 |
0
| public void setIdAttributeNode(Attr idAttr, boolean isId) throws DOMException
|
425 |
| { |
426 |
0
| throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "DOM method not supported");
|
427 |
| } |
428 |
| |
429 |
| |
430 |
| |
431 |
| |
432 |
| |
433 |
0
| public void setIdAttributeNS(String namespaceURI, String localName, boolean isId) throws DOMException
|
434 |
| { |
435 |
0
| throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "DOM method not supported");
|
436 |
| } |
437 |
| } |