KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > w3c > tidy > DOMElementImpl


1 /*
2  * @(#)DOMElementImpl.java 1.11 2000/08/16
3  *
4  */

5
6 package org.w3c.tidy;
7
8 import org.w3c.dom.DOMException JavaDoc;
9
10 /**
11  *
12  * DOMElementImpl
13  *
14  * (c) 1998-2000 (W3C) MIT, INRIA, Keio University
15  * See Tidy.java for the copyright notice.
16  * Derived from <a HREF="http://www.w3.org/People/Raggett/tidy">
17  * HTML Tidy Release 4 Aug 2000</a>
18  *
19  * @author Dave Raggett <dsr@w3.org>
20  * @author Andy Quick <ac.quick@sympatico.ca> (translation to Java)
21  * @version 1.4, 1999/09/04 DOM Support
22  * @version 1.5, 1999/10/23 Tidy Release 27 Sep 1999
23  * @version 1.6, 1999/11/01 Tidy Release 22 Oct 1999
24  * @version 1.7, 1999/12/06 Tidy Release 30 Nov 1999
25  * @version 1.8, 2000/01/22 Tidy Release 13 Jan 2000
26  * @version 1.9, 2000/06/03 Tidy Release 30 Apr 2000
27  * @version 1.10, 2000/07/22 Tidy Release 8 Jul 2000
28  * @version 1.11, 2000/08/16 Tidy Release 4 Aug 2000
29  */

30
31 public class DOMElementImpl extends DOMNodeImpl
32                             implements org.w3c.dom.Element JavaDoc {
33
34     protected DOMElementImpl(Node adaptee)
35     {
36         super(adaptee);
37     }
38
39
40     /* --------------------- DOM ---------------------------- */
41
42     /**
43      * @see org.w3c.dom.Node#getNodeType
44      */

45     public short getNodeType()
46     {
47         return org.w3c.dom.Node.ELEMENT_NODE;
48     }
49
50     /**
51      * @see org.w3c.dom.Element#getTagName
52      */

53     public String JavaDoc getTagName()
54     {
55         return super.getNodeName();
56     }
57
58     /**
59      * @see org.w3c.dom.Element#getAttribute
60      */

61     public String JavaDoc getAttribute(String JavaDoc name)
62     {
63         if (this.adaptee == null)
64             return null;
65
66         AttVal att = this.adaptee.attributes;
67         while (att != null) {
68             if (att.attribute.equals(name)) break;
69             att = att.next;
70         }
71         if (att != null)
72             return att.value;
73         else
74             return "";
75     }
76
77     /**
78      * @see org.w3c.dom.Element#setAttribute
79      */

80     public void setAttribute(String JavaDoc name,
81                                            String JavaDoc value)
82                                            throws DOMException JavaDoc
83     {
84         if (this.adaptee == null)
85             return;
86
87         AttVal att = this.adaptee.attributes;
88         while (att != null) {
89             if (att.attribute.equals(name)) break;
90             att = att.next;
91         }
92         if (att != null) {
93             att.value = value;
94         } else {
95             att = new AttVal(null, null, (int)'"', name, value);
96             att.dict =
97               AttributeTable.getDefaultAttributeTable().findAttribute(att);
98             if (this.adaptee.attributes == null) {
99                 this.adaptee.attributes = att;
100             } else {
101                 att.next = this.adaptee.attributes;
102                 this.adaptee.attributes = att;
103             }
104         }
105     }
106
107     /**
108      * @see org.w3c.dom.Element#removeAttribute
109      */

110     public void removeAttribute(String JavaDoc name)
111                                               throws DOMException JavaDoc
112     {
113         if (this.adaptee == null)
114             return;
115
116         AttVal att = this.adaptee.attributes;
117         AttVal pre = null;
118         while (att != null) {
119             if (att.attribute.equals(name)) break;
120             pre = att;
121             att = att.next;
122         }
123         if (att != null) {
124             if (pre == null) {
125                 this.adaptee.attributes = att.next;
126             } else {
127                 pre.next = att.next;
128             }
129         }
130     }
131
132     /**
133      * @see org.w3c.dom.Element#getAttributeNode
134      */

135     public org.w3c.dom.Attr JavaDoc getAttributeNode(String JavaDoc name)
136     {
137         if (this.adaptee == null)
138             return null;
139
140         AttVal att = this.adaptee.attributes;
141         while (att != null) {
142             if (att.attribute.equals(name)) break;
143             att = att.next;
144         }
145         if (att != null)
146             return att.getAdapter();
147         else
148             return null;
149     }
150
151     /**
152      * @see org.w3c.dom.Element#setAttributeNode
153      */

154     public org.w3c.dom.Attr JavaDoc setAttributeNode(org.w3c.dom.Attr JavaDoc newAttr)
155                                                throws DOMException JavaDoc
156     {
157         if (newAttr == null)
158             return null;
159         if (!(newAttr instanceof DOMAttrImpl)) {
160             throw new DOMExceptionImpl(DOMException.WRONG_DOCUMENT_ERR,
161                                        "newAttr not instanceof DOMAttrImpl");
162         }
163
164         DOMAttrImpl newatt = (DOMAttrImpl)newAttr;
165         String JavaDoc name = newatt.avAdaptee.attribute;
166         org.w3c.dom.Attr JavaDoc result = null;
167
168         AttVal att = this.adaptee.attributes;
169         while (att != null) {
170             if (att.attribute.equals(name)) break;
171             att = att.next;
172         }
173         if (att != null) {
174             result = att.getAdapter();
175             att.adapter = newAttr;
176         } else {
177             if (this.adaptee.attributes == null) {
178                 this.adaptee.attributes = newatt.avAdaptee;
179             } else {
180                 newatt.avAdaptee.next = this.adaptee.attributes;
181                 this.adaptee.attributes = newatt.avAdaptee;
182             }
183         }
184         return result;
185     }
186
187     /**
188      * @see org.w3c.dom.Element#removeAttributeNode
189      */

190     public org.w3c.dom.Attr JavaDoc removeAttributeNode(org.w3c.dom.Attr JavaDoc oldAttr)
191                                                   throws DOMException JavaDoc
192     {
193         if (oldAttr == null)
194             return null;
195
196         org.w3c.dom.Attr JavaDoc result = null;
197         AttVal att = this.adaptee.attributes;
198         AttVal pre = null;
199         while (att != null) {
200             if (att.getAdapter() == oldAttr) break;
201             pre = att;
202             att = att.next;
203         }
204         if (att != null) {
205             if (pre == null) {
206                 this.adaptee.attributes = att.next;
207             } else {
208                 pre.next = att.next;
209             }
210             result = oldAttr;
211         } else {
212             throw new DOMExceptionImpl(DOMException.NOT_FOUND_ERR,
213                                        "oldAttr not found");
214         }
215         return result;
216     }
217
218     /**
219      * @see org.w3c.dom.Element#getElementsByTagName
220      */

221     public org.w3c.dom.NodeList JavaDoc getElementsByTagName(String JavaDoc name)
222     {
223         return new DOMNodeListByTagNameImpl(this.adaptee, name);
224     }
225
226     /**
227      * @see org.w3c.dom.Element#normalize
228      */

229     public void normalize()
230     {
231         // NOT SUPPORTED
232
}
233
234     /**
235      * DOM2 - not implemented.
236      */

237     public String JavaDoc getAttributeNS(String JavaDoc namespaceURI, String JavaDoc localName)
238     {
239     return null;
240     }
241
242     /**
243      * DOM2 - not implemented.
244      * @exception org.w3c.dom.DOMException
245      */

246     public void setAttributeNS(String JavaDoc namespaceURI,
247                                String JavaDoc qualifiedName,
248                                String JavaDoc value)
249         throws org.w3c.dom.DOMException JavaDoc
250     {
251     }
252
253     /**
254      * DOM2 - not implemented.
255      * @exception org.w3c.dom.DOMException
256      */

257     public void removeAttributeNS(String JavaDoc namespaceURI, String JavaDoc localName)
258         throws org.w3c.dom.DOMException JavaDoc
259     {
260     }
261
262     /**
263      * DOM2 - not implemented.
264      */

265     public org.w3c.dom.Attr JavaDoc getAttributeNodeNS(String JavaDoc namespaceURI,
266                                                String JavaDoc localName)
267     {
268     return null;
269     }
270
271     /**
272      * DOM2 - not implemented.
273      * @exception org.w3c.dom.DOMException
274      */

275     public org.w3c.dom.Attr JavaDoc setAttributeNodeNS(org.w3c.dom.Attr JavaDoc newAttr)
276         throws org.w3c.dom.DOMException JavaDoc
277     {
278     return null;
279     }
280
281     /**
282      * DOM2 - not implemented.
283      */

284     public org.w3c.dom.NodeList JavaDoc getElementsByTagNameNS(String JavaDoc namespaceURI,
285                                                        String JavaDoc localName)
286     {
287     return null;
288     }
289
290     /**
291      * DOM2 - not implemented.
292      */

293     public boolean hasAttribute(String JavaDoc name)
294     {
295         return false;
296     }
297
298     /**
299      * DOM2 - not implemented.
300      */

301     public boolean hasAttributeNS(String JavaDoc namespaceURI,
302                                   String JavaDoc localName)
303     {
304         return false;
305     }
306
307     public org.w3c.dom.TypeInfo JavaDoc getSchemaTypeInfo() {
308       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl getSchemaTypeInfo() Not implemented");
309     }
310
311     public void setIdAttributeNode(org.w3c.dom.Attr JavaDoc oAttr, boolean bSet) {
312       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl setIdAttributeNode() Not implemented");
313     }
314
315     public void setIdAttribute(String JavaDoc sStr1, boolean bSet) {
316       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl setIdAttributeNode() Not implemented");
317     }
318
319     public void setIdAttributeNS(String JavaDoc sStr1, String JavaDoc sStr2, boolean bSet) {
320       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl setIdAttributeNS() Not implemented");
321     }
322
323     public org.w3c.dom.Node JavaDoc adoptNode (org.w3c.dom.Node JavaDoc oNode) {
324       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl adoptNode() Not implemented");
325     }
326
327     public short compareDocumentPosition (org.w3c.dom.Node JavaDoc oNode) {
328       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl compareDocumentPosition() Not implemented");
329     }
330
331     public boolean isDefaultNamespace(String JavaDoc sStr1) {
332       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl isDefaultNamespace() Not implemented");
333     }
334
335     public boolean isEqualNode(org.w3c.dom.Node JavaDoc oNode) {
336       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl isEqualNode() Not implemented");
337     }
338
339     public boolean isSameNode(org.w3c.dom.Node JavaDoc oNode) {
340       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl isSameNode() Not implemented");
341     }
342
343     public String JavaDoc lookupPrefix(String JavaDoc sStr1) {
344       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl lookupPreffix() Not implemented");
345     }
346
347     public String JavaDoc lookupNamespaceURI(String JavaDoc sStr1) {
348       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl lookupNamespaceURI() Not implemented");
349     }
350
351     public String JavaDoc getDocumentURI() {
352       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl getDocumentURI() Not implemented");
353     }
354
355     public void setDocumentURI(String JavaDoc sStr1) {
356       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl setDocumentURI() Not implemented");
357     }
358
359     public boolean getStrictErrorChecking() {
360       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl getStrictErrorChecking() Not implemented");
361     }
362
363     public void setStrictErrorChecking(boolean bStrictCheck) {
364       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl setStrictErrorChecking() Not implemented");
365     }
366
367     public boolean getXmlStandalone() {
368       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl getXmlStandalone() Not implemented");
369     }
370
371     public void setXmlStandalone(boolean bXmlStandalone) {
372       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl setXmlStandalone() Not implemented");
373     }
374
375     public Object JavaDoc getFeature(String JavaDoc sStr1, String JavaDoc sStr2) {
376       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl getFeature() Not implemented");
377     }
378
379     public String JavaDoc getInputEncoding() {
380       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl getInputEncoding() Not implemented");
381     }
382
383     public String JavaDoc getXmlEncoding() {
384       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl getXmlEncoding() Not implemented");
385     }
386
387     public String JavaDoc getXmlVersion() {
388       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl getXmlVersion() Not implemented");
389     }
390
391     public void setXmlVersion(String JavaDoc sStr1) {
392       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl setXmlVersion() Not implemented");
393     }
394
395     public Object JavaDoc getUserData(String JavaDoc sStr1) {
396       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl getUserData() Not implemented");
397     }
398
399     public Object JavaDoc setUserData(String JavaDoc sStr1, Object JavaDoc oObj2, org.w3c.dom.UserDataHandler JavaDoc oHndlr) {
400       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl setUserData() Not implemented");
401     }
402
403     public org.w3c.dom.DOMConfiguration JavaDoc getDomConfig () {
404       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl getDomConfig() Not implemented");
405     }
406
407     public void normalizeDocument () {
408       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl normalizeDocument() Not implemented");
409     }
410
411     public org.w3c.dom.Node JavaDoc renameNode (org.w3c.dom.Node JavaDoc oNode, String JavaDoc sStr1, String JavaDoc sStr2) {
412       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl renameNode() Not implemented");
413     }
414
415     public String JavaDoc getBaseURI() {
416       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl getBaseURI() Not implemented");
417     }
418
419     public String JavaDoc getTextContent() {
420       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl getTextContent() Not implemented");
421     }
422
423     public void setTextContent(String JavaDoc sStr1) {
424       throw new UnsupportedOperationException JavaDoc("org.w3c.tidy.DOMElementImpl setTextContent() Not implemented");
425     }
426
427 }
428
Popular Tags