001: /*
002: * @(#)DOMElementImpl.java 1.11 2000/08/16
003: *
004: */
005:
006: package org.w3c.tidy;
007:
008: import org.w3c.dom.DOMException;
009:
010: /**
011: *
012: * DOMElementImpl
013: *
014: * (c) 1998-2000 (W3C) MIT, INRIA, Keio University
015: * See Tidy.java for the copyright notice.
016: * Derived from <a href="http://www.w3.org/People/Raggett/tidy">
017: * HTML Tidy Release 4 Aug 2000</a>
018: *
019: * @author Dave Raggett <dsr@w3.org>
020: * @author Andy Quick <ac.quick@sympatico.ca> (translation to Java)
021: * @version 1.4, 1999/09/04 DOM Support
022: * @version 1.5, 1999/10/23 Tidy Release 27 Sep 1999
023: * @version 1.6, 1999/11/01 Tidy Release 22 Oct 1999
024: * @version 1.7, 1999/12/06 Tidy Release 30 Nov 1999
025: * @version 1.8, 2000/01/22 Tidy Release 13 Jan 2000
026: * @version 1.9, 2000/06/03 Tidy Release 30 Apr 2000
027: * @version 1.10, 2000/07/22 Tidy Release 8 Jul 2000
028: * @version 1.11, 2000/08/16 Tidy Release 4 Aug 2000
029: */
030:
031: public class DOMElementImpl extends DOMNodeImpl implements
032: org.w3c.dom.Element {
033:
034: protected DOMElementImpl(Node adaptee) {
035: super (adaptee);
036: }
037:
038: /* --------------------- DOM ---------------------------- */
039:
040: /**
041: * @see org.w3c.dom.Node#getNodeType
042: */
043: public short getNodeType() {
044: return org.w3c.dom.Node.ELEMENT_NODE;
045: }
046:
047: /**
048: * @see org.w3c.dom.Element#getTagName
049: */
050: public String getTagName() {
051: return super .getNodeName();
052: }
053:
054: /**
055: * @see org.w3c.dom.Element#getAttribute
056: */
057: public String getAttribute(String name) {
058: if (this .adaptee == null)
059: return null;
060:
061: AttVal att = this .adaptee.attributes;
062: while (att != null) {
063: if (att.attribute.equals(name))
064: break;
065: att = att.next;
066: }
067: if (att != null)
068: return att.value;
069: else
070: return "";
071: }
072:
073: /**
074: * @see org.w3c.dom.Element#setAttribute
075: */
076: public void setAttribute(String name, String value)
077: throws DOMException {
078: if (this .adaptee == null)
079: return;
080:
081: AttVal att = this .adaptee.attributes;
082: while (att != null) {
083: if (att.attribute.equals(name))
084: break;
085: att = att.next;
086: }
087: if (att != null) {
088: att.value = value;
089: } else {
090: att = new AttVal(null, null, (int) '"', name, value);
091: att.dict = AttributeTable.getDefaultAttributeTable()
092: .findAttribute(att);
093: if (this .adaptee.attributes == null) {
094: this .adaptee.attributes = att;
095: } else {
096: att.next = this .adaptee.attributes;
097: this .adaptee.attributes = att;
098: }
099: }
100: }
101:
102: /**
103: * @see org.w3c.dom.Element#removeAttribute
104: */
105: public void removeAttribute(String name) throws DOMException {
106: if (this .adaptee == null)
107: return;
108:
109: AttVal att = this .adaptee.attributes;
110: AttVal pre = null;
111: while (att != null) {
112: if (att.attribute.equals(name))
113: break;
114: pre = att;
115: att = att.next;
116: }
117: if (att != null) {
118: if (pre == null) {
119: this .adaptee.attributes = att.next;
120: } else {
121: pre.next = att.next;
122: }
123: }
124: }
125:
126: /**
127: * @see org.w3c.dom.Element#getAttributeNode
128: */
129: public org.w3c.dom.Attr getAttributeNode(String name) {
130: if (this .adaptee == null)
131: return null;
132:
133: AttVal att = this .adaptee.attributes;
134: while (att != null) {
135: if (att.attribute.equals(name))
136: break;
137: att = att.next;
138: }
139: if (att != null)
140: return att.getAdapter();
141: else
142: return null;
143: }
144:
145: /**
146: * @see org.w3c.dom.Element#setAttributeNode
147: */
148: public org.w3c.dom.Attr setAttributeNode(org.w3c.dom.Attr newAttr)
149: throws DOMException {
150: if (newAttr == null)
151: return null;
152: if (!(newAttr instanceof DOMAttrImpl)) {
153: throw new DOMExceptionImpl(DOMException.WRONG_DOCUMENT_ERR,
154: "newAttr not instanceof DOMAttrImpl");
155: }
156:
157: DOMAttrImpl newatt = (DOMAttrImpl) newAttr;
158: String name = newatt.avAdaptee.attribute;
159: org.w3c.dom.Attr result = null;
160:
161: AttVal att = this .adaptee.attributes;
162: while (att != null) {
163: if (att.attribute.equals(name))
164: break;
165: att = att.next;
166: }
167: if (att != null) {
168: result = att.getAdapter();
169: att.adapter = newAttr;
170: } else {
171: if (this .adaptee.attributes == null) {
172: this .adaptee.attributes = newatt.avAdaptee;
173: } else {
174: newatt.avAdaptee.next = this .adaptee.attributes;
175: this .adaptee.attributes = newatt.avAdaptee;
176: }
177: }
178: return result;
179: }
180:
181: /**
182: * @see org.w3c.dom.Element#removeAttributeNode
183: */
184: public org.w3c.dom.Attr removeAttributeNode(org.w3c.dom.Attr oldAttr)
185: throws DOMException {
186: if (oldAttr == null)
187: return null;
188:
189: org.w3c.dom.Attr result = null;
190: AttVal att = this .adaptee.attributes;
191: AttVal pre = null;
192: while (att != null) {
193: if (att.getAdapter() == oldAttr)
194: break;
195: pre = att;
196: att = att.next;
197: }
198: if (att != null) {
199: if (pre == null) {
200: this .adaptee.attributes = att.next;
201: } else {
202: pre.next = att.next;
203: }
204: result = oldAttr;
205: } else {
206: throw new DOMExceptionImpl(DOMException.NOT_FOUND_ERR,
207: "oldAttr not found");
208: }
209: return result;
210: }
211:
212: /**
213: * @see org.w3c.dom.Element#getElementsByTagName
214: */
215: public org.w3c.dom.NodeList getElementsByTagName(String name) {
216: return new DOMNodeListByTagNameImpl(this .adaptee, name);
217: }
218:
219: /**
220: * @see org.w3c.dom.Element#normalize
221: */
222: public void normalize() {
223: // NOT SUPPORTED
224: }
225:
226: /**
227: * DOM2 - not implemented.
228: */
229: public String getAttributeNS(String namespaceURI, String localName) {
230: return null;
231: }
232:
233: /**
234: * DOM2 - not implemented.
235: * @exception org.w3c.dom.DOMException
236: */
237: public void setAttributeNS(String namespaceURI,
238: String qualifiedName, String value)
239: throws org.w3c.dom.DOMException {
240: }
241:
242: /**
243: * DOM2 - not implemented.
244: * @exception org.w3c.dom.DOMException
245: */
246: public void removeAttributeNS(String namespaceURI, String localName)
247: throws org.w3c.dom.DOMException {
248: }
249:
250: /**
251: * DOM2 - not implemented.
252: */
253: public org.w3c.dom.Attr getAttributeNodeNS(String namespaceURI,
254: String localName) {
255: return null;
256: }
257:
258: /**
259: * DOM2 - not implemented.
260: * @exception org.w3c.dom.DOMException
261: */
262: public org.w3c.dom.Attr setAttributeNodeNS(org.w3c.dom.Attr newAttr)
263: throws org.w3c.dom.DOMException {
264: return null;
265: }
266:
267: /**
268: * DOM2 - not implemented.
269: */
270: public org.w3c.dom.NodeList getElementsByTagNameNS(
271: String namespaceURI, String localName) {
272: return null;
273: }
274:
275: /**
276: * DOM2 - not implemented.
277: */
278: public boolean hasAttribute(String name) {
279: return false;
280: }
281:
282: /**
283: * DOM2 - not implemented.
284: */
285: public boolean hasAttributeNS(String namespaceURI, String localName) {
286: return false;
287: }
288:
289: public org.w3c.dom.TypeInfo getSchemaTypeInfo() {
290: throw new UnsupportedOperationException(
291: "org.w3c.tidy.DOMElementImpl getSchemaTypeInfo() Not implemented");
292: }
293:
294: public void setIdAttributeNode(org.w3c.dom.Attr oAttr, boolean bSet) {
295: throw new UnsupportedOperationException(
296: "org.w3c.tidy.DOMElementImpl setIdAttributeNode() Not implemented");
297: }
298:
299: public void setIdAttribute(String sStr1, boolean bSet) {
300: throw new UnsupportedOperationException(
301: "org.w3c.tidy.DOMElementImpl setIdAttributeNode() Not implemented");
302: }
303:
304: public void setIdAttributeNS(String sStr1, String sStr2,
305: boolean bSet) {
306: throw new UnsupportedOperationException(
307: "org.w3c.tidy.DOMElementImpl setIdAttributeNS() Not implemented");
308: }
309:
310: public org.w3c.dom.Node adoptNode(org.w3c.dom.Node oNode) {
311: throw new UnsupportedOperationException(
312: "org.w3c.tidy.DOMElementImpl adoptNode() Not implemented");
313: }
314:
315: public short compareDocumentPosition(org.w3c.dom.Node oNode) {
316: throw new UnsupportedOperationException(
317: "org.w3c.tidy.DOMElementImpl compareDocumentPosition() Not implemented");
318: }
319:
320: public boolean isDefaultNamespace(String sStr1) {
321: throw new UnsupportedOperationException(
322: "org.w3c.tidy.DOMElementImpl isDefaultNamespace() Not implemented");
323: }
324:
325: public boolean isEqualNode(org.w3c.dom.Node oNode) {
326: throw new UnsupportedOperationException(
327: "org.w3c.tidy.DOMElementImpl isEqualNode() Not implemented");
328: }
329:
330: public boolean isSameNode(org.w3c.dom.Node oNode) {
331: throw new UnsupportedOperationException(
332: "org.w3c.tidy.DOMElementImpl isSameNode() Not implemented");
333: }
334:
335: public String lookupPrefix(String sStr1) {
336: throw new UnsupportedOperationException(
337: "org.w3c.tidy.DOMElementImpl lookupPreffix() Not implemented");
338: }
339:
340: public String lookupNamespaceURI(String sStr1) {
341: throw new UnsupportedOperationException(
342: "org.w3c.tidy.DOMElementImpl lookupNamespaceURI() Not implemented");
343: }
344:
345: public String getDocumentURI() {
346: throw new UnsupportedOperationException(
347: "org.w3c.tidy.DOMElementImpl getDocumentURI() Not implemented");
348: }
349:
350: public void setDocumentURI(String sStr1) {
351: throw new UnsupportedOperationException(
352: "org.w3c.tidy.DOMElementImpl setDocumentURI() Not implemented");
353: }
354:
355: public boolean getStrictErrorChecking() {
356: throw new UnsupportedOperationException(
357: "org.w3c.tidy.DOMElementImpl getStrictErrorChecking() Not implemented");
358: }
359:
360: public void setStrictErrorChecking(boolean bStrictCheck) {
361: throw new UnsupportedOperationException(
362: "org.w3c.tidy.DOMElementImpl setStrictErrorChecking() Not implemented");
363: }
364:
365: public boolean getXmlStandalone() {
366: throw new UnsupportedOperationException(
367: "org.w3c.tidy.DOMElementImpl getXmlStandalone() Not implemented");
368: }
369:
370: public void setXmlStandalone(boolean bXmlStandalone) {
371: throw new UnsupportedOperationException(
372: "org.w3c.tidy.DOMElementImpl setXmlStandalone() Not implemented");
373: }
374:
375: public Object getFeature(String sStr1, String sStr2) {
376: throw new UnsupportedOperationException(
377: "org.w3c.tidy.DOMElementImpl getFeature() Not implemented");
378: }
379:
380: public String getInputEncoding() {
381: throw new UnsupportedOperationException(
382: "org.w3c.tidy.DOMElementImpl getInputEncoding() Not implemented");
383: }
384:
385: public String getXmlEncoding() {
386: throw new UnsupportedOperationException(
387: "org.w3c.tidy.DOMElementImpl getXmlEncoding() Not implemented");
388: }
389:
390: public String getXmlVersion() {
391: throw new UnsupportedOperationException(
392: "org.w3c.tidy.DOMElementImpl getXmlVersion() Not implemented");
393: }
394:
395: public void setXmlVersion(String sStr1) {
396: throw new UnsupportedOperationException(
397: "org.w3c.tidy.DOMElementImpl setXmlVersion() Not implemented");
398: }
399:
400: public Object getUserData(String sStr1) {
401: throw new UnsupportedOperationException(
402: "org.w3c.tidy.DOMElementImpl getUserData() Not implemented");
403: }
404:
405: public Object setUserData(String sStr1, Object oObj2,
406: org.w3c.dom.UserDataHandler oHndlr) {
407: throw new UnsupportedOperationException(
408: "org.w3c.tidy.DOMElementImpl setUserData() Not implemented");
409: }
410:
411: public org.w3c.dom.DOMConfiguration getDomConfig() {
412: throw new UnsupportedOperationException(
413: "org.w3c.tidy.DOMElementImpl getDomConfig() Not implemented");
414: }
415:
416: public void normalizeDocument() {
417: throw new UnsupportedOperationException(
418: "org.w3c.tidy.DOMElementImpl normalizeDocument() Not implemented");
419: }
420:
421: public org.w3c.dom.Node renameNode(org.w3c.dom.Node oNode,
422: String sStr1, String sStr2) {
423: throw new UnsupportedOperationException(
424: "org.w3c.tidy.DOMElementImpl renameNode() Not implemented");
425: }
426:
427: public String getBaseURI() {
428: throw new UnsupportedOperationException(
429: "org.w3c.tidy.DOMElementImpl getBaseURI() Not implemented");
430: }
431:
432: public String getTextContent() {
433: throw new UnsupportedOperationException(
434: "org.w3c.tidy.DOMElementImpl getTextContent() Not implemented");
435: }
436:
437: public void setTextContent(String sStr1) {
438: throw new UnsupportedOperationException(
439: "org.w3c.tidy.DOMElementImpl setTextContent() Not implemented");
440: }
441:
442: }
|