2 * @(#)DOMElementImpl.java 1.11 2000/08/16
6 package net.sourceforge.phpdt.tidy.w3c;
8 import org.w3c.dom.DOMException;
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>
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
31 public class DOMElementImpl extends DOMNodeImpl
32 implements org.w3c.dom.Element {
34 protected DOMElementImpl(Node adaptee)
40 /* --------------------- DOM ---------------------------- */
43 * @see org.w3c.dom.Node#getNodeType
45 public short getNodeType()
47 return org.w3c.dom.Node.ELEMENT_NODE;
51 * @see org.w3c.dom.Element#getTagName
53 public String getTagName()
55 return super.getNodeName();
59 * @see org.w3c.dom.Element#getAttribute
61 public String getAttribute(String name)
63 if (this.adaptee == null)
66 AttVal att = this.adaptee.attributes;
68 if (att.attribute.equals(name)) break;
78 * @see org.w3c.dom.Element#setAttribute
80 public void setAttribute(String name,
84 if (this.adaptee == null)
87 AttVal att = this.adaptee.attributes;
89 if (att.attribute.equals(name)) break;
95 att = new AttVal(null, null, (int)'"', name, value);
97 AttributeTable.getDefaultAttributeTable().findAttribute(att);
98 if (this.adaptee.attributes == null) {
99 this.adaptee.attributes = att;
101 att.next = this.adaptee.attributes;
102 this.adaptee.attributes = att;
108 * @see org.w3c.dom.Element#removeAttribute
110 public void removeAttribute(String name)
113 if (this.adaptee == null)
116 AttVal att = this.adaptee.attributes;
118 while (att != null) {
119 if (att.attribute.equals(name)) break;
125 this.adaptee.attributes = att.next;
133 * @see org.w3c.dom.Element#getAttributeNode
135 public org.w3c.dom.Attr getAttributeNode(String name)
137 if (this.adaptee == null)
140 AttVal att = this.adaptee.attributes;
141 while (att != null) {
142 if (att.attribute.equals(name)) break;
146 return att.getAdapter();
152 * @see org.w3c.dom.Element#setAttributeNode
154 public org.w3c.dom.Attr setAttributeNode(org.w3c.dom.Attr newAttr)
159 if (!(newAttr instanceof DOMAttrImpl)) {
160 throw new DOMExceptionImpl(DOMException.WRONG_DOCUMENT_ERR,
161 "newAttr not instanceof DOMAttrImpl");
164 DOMAttrImpl newatt = (DOMAttrImpl)newAttr;
165 String name = newatt.avAdaptee.attribute;
166 org.w3c.dom.Attr result = null;
168 AttVal att = this.adaptee.attributes;
169 while (att != null) {
170 if (att.attribute.equals(name)) break;
174 result = att.getAdapter();
175 att.adapter = newAttr;
177 if (this.adaptee.attributes == null) {
178 this.adaptee.attributes = newatt.avAdaptee;
180 newatt.avAdaptee.next = this.adaptee.attributes;
181 this.adaptee.attributes = newatt.avAdaptee;
188 * @see org.w3c.dom.Element#removeAttributeNode
190 public org.w3c.dom.Attr removeAttributeNode(org.w3c.dom.Attr oldAttr)
196 org.w3c.dom.Attr result = null;
197 AttVal att = this.adaptee.attributes;
199 while (att != null) {
200 if (att.getAdapter() == oldAttr) break;
206 this.adaptee.attributes = att.next;
212 throw new DOMExceptionImpl(DOMException.NOT_FOUND_ERR,
213 "oldAttr not found");
219 * @see org.w3c.dom.Element#getElementsByTagName
221 public org.w3c.dom.NodeList getElementsByTagName(String name)
223 return new DOMNodeListByTagNameImpl(this.adaptee, name);
227 * @see org.w3c.dom.Element#normalize
229 public void normalize()
235 * DOM2 - not implemented.
237 public String getAttributeNS(String namespaceURI, String localName)
243 * DOM2 - not implemented.
244 * @exception org.w3c.dom.DOMException
246 public void setAttributeNS(String namespaceURI,
247 String qualifiedName,
249 throws org.w3c.dom.DOMException
254 * DOM2 - not implemented.
255 * @exception org.w3c.dom.DOMException
257 public void removeAttributeNS(String namespaceURI, String localName)
258 throws org.w3c.dom.DOMException
263 * DOM2 - not implemented.
265 public org.w3c.dom.Attr getAttributeNodeNS(String namespaceURI,
272 * DOM2 - not implemented.
273 * @exception org.w3c.dom.DOMException
275 public org.w3c.dom.Attr setAttributeNodeNS(org.w3c.dom.Attr newAttr)
276 throws org.w3c.dom.DOMException
282 * DOM2 - not implemented.
284 public org.w3c.dom.NodeList getElementsByTagNameNS(String namespaceURI,
291 * DOM2 - not implemented.
293 public boolean hasAttribute(String name)
299 * DOM2 - not implemented.
301 public boolean hasAttributeNS(String namespaceURI,