001: /*
002: * @(#)DOMAttrImpl.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: * DOMAttrImpl
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 DOMAttrImpl extends DOMNodeImpl implements
032: org.w3c.dom.Attr {
033:
034: protected AttVal avAdaptee;
035:
036: protected DOMAttrImpl(AttVal adaptee) {
037: super (null); // must override all methods of DOMNodeImpl
038: this .avAdaptee = adaptee;
039: }
040:
041: /* --------------------- DOM ---------------------------- */
042:
043: public String getNodeValue() throws DOMException {
044: return getValue();
045: }
046:
047: public void setNodeValue(String nodeValue) throws DOMException {
048: setValue(nodeValue);
049: }
050:
051: public String getNodeName() {
052: return getName();
053: }
054:
055: public short getNodeType() {
056: return org.w3c.dom.Node.ATTRIBUTE_NODE;
057: }
058:
059: public org.w3c.dom.Node getParentNode() {
060: return null;
061: }
062:
063: public org.w3c.dom.NodeList getChildNodes() {
064: // NOT SUPPORTED
065: return null;
066: }
067:
068: public org.w3c.dom.Node getFirstChild() {
069: // NOT SUPPORTED
070: return null;
071: }
072:
073: public org.w3c.dom.Node getLastChild() {
074: // NOT SUPPORTED
075: return null;
076: }
077:
078: public org.w3c.dom.Node getPreviousSibling() {
079: return null;
080: }
081:
082: public org.w3c.dom.Node getNextSibling() {
083: return null;
084: }
085:
086: public org.w3c.dom.NamedNodeMap getAttributes() {
087: return null;
088: }
089:
090: public org.w3c.dom.Document getOwnerDocument() {
091: return null;
092: }
093:
094: public org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild,
095: org.w3c.dom.Node refChild) throws DOMException {
096: throw new DOMExceptionImpl(
097: DOMException.NO_MODIFICATION_ALLOWED_ERR,
098: "Not supported");
099: }
100:
101: public org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild,
102: org.w3c.dom.Node oldChild) throws DOMException {
103: throw new DOMExceptionImpl(
104: DOMException.NO_MODIFICATION_ALLOWED_ERR,
105: "Not supported");
106: }
107:
108: public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
109: throws DOMException {
110: throw new DOMExceptionImpl(
111: DOMException.NO_MODIFICATION_ALLOWED_ERR,
112: "Not supported");
113: }
114:
115: public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
116: throws DOMException {
117: throw new DOMExceptionImpl(
118: DOMException.NO_MODIFICATION_ALLOWED_ERR,
119: "Not supported");
120: }
121:
122: public boolean hasChildNodes() {
123: return false;
124: }
125:
126: public org.w3c.dom.Node cloneNode(boolean deep) {
127: return null;
128: }
129:
130: /**
131: * @see org.w3c.dom.Attr#getName
132: */
133: public String getName() {
134: return avAdaptee.attribute;
135: }
136:
137: /**
138: * @see org.w3c.dom.Attr#getSpecified
139: */
140: public boolean getSpecified() {
141: return true;
142: }
143:
144: /**
145: * Returns value of this attribute. If this attribute has a null value,
146: * then the attribute name is returned instead.
147: * Thanks to Brett Knights <brett@knightsofthenet.com> for this fix.
148: * @see org.w3c.dom.Attr#getValue
149: *
150: */
151: public String getValue() {
152: return (avAdaptee.value == null) ? avAdaptee.attribute
153: : avAdaptee.value;
154: }
155:
156: /**
157: * @see org.w3c.dom.Attr#setValue
158: */
159: public void setValue(String value) {
160: avAdaptee.value = value;
161: }
162:
163: /**
164: * DOM2 - not implemented.
165: */
166: public org.w3c.dom.Element getOwnerElement() {
167: return null;
168: }
169:
170: }
|