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.DOMException;
57 import org.w3c.dom.TypeInfo;
58
59
60 /**
61 * Tidy implementation of org.w3c.dom.DOMAttrImpl.
62 * @author Dave Raggett <a href="mailto:dsr@w3.org">dsr@w3.org </a>
63 * @author Andy Quick <a href="mailto:ac.quick@sympatico.ca">ac.quick@sympatico.ca </a> (translation to Java)
64 * @author Fabrizio Giustina
65 * @version $Revision: 779 $ ($Author: fgiust $)
66 */
67 public class DOMAttrImpl extends DOMNodeImpl implements org.w3c.dom.Attr, Cloneable
68 {
69
70 /**
71 * wrapped org.w3c.tidy.AttVal.
72 */
73 protected AttVal avAdaptee;
74
75 /**
76 * instantiates a new DOMAttrImpl which wraps the given AttVal.
77 * @param adaptee wrapped AttVal
78 */
79 protected DOMAttrImpl(AttVal adaptee)
80 {
81 super(null);
82 this.avAdaptee = adaptee;
83 }
84
85 /**
86 * @see org.w3c.dom.Node#getNodeValue()
87 */
88 public String getNodeValue() throws DOMException
89 {
90 return getValue();
91 }
92
93 /**
94 * @see org.w3c.dom.Node#setNodeValue(java.lang.String)
95 */
96 public void setNodeValue(String nodeValue) throws DOMException
97 {
98 setValue(nodeValue);
99 }
100
101 /**
102 * @see org.w3c.dom.Node#getNodeName()
103 */
104 public String getNodeName()
105 {
106 return getName();
107 }
108
109 /**
110 * @see org.w3c.dom.Node#getNodeType()
111 */
112 public short getNodeType()
113 {
114 return org.w3c.dom.Node.ATTRIBUTE_NODE;
115 }
116
117 /**
118 * @see org.w3c.dom.Attr#getName
119 */
120 public String getName()
121 {
122 return avAdaptee.attribute;
123 }
124
125 /**
126 * @see org.w3c.dom.Attr#getSpecified
127 */
128 public boolean getSpecified()
129 {
130 return avAdaptee.value != null;
131 }
132
133 /**
134 * @see org.w3c.dom.Attr#getValue
135 */
136 public String getValue()
137 {
138
139 return (avAdaptee.value == null) ? avAdaptee.attribute : avAdaptee.value;
140 }
141
142 /**
143 * @see org.w3c.dom.Attr#setValue(java.lang.String)
144 */
145 public void setValue(String value)
146 {
147 avAdaptee.value = value;
148 }
149
150 /**
151 * @see org.w3c.dom.Node#getParentNode()
152 */
153 public org.w3c.dom.Node getParentNode()
154 {
155
156
157 return null;
158 }
159
160 /**
161 * @todo DOM level 2 getChildNodes() Not implemented. Returns an empty NodeList.
162 * @see org.w3c.dom.Node#getChildNodes()
163 */
164 public org.w3c.dom.NodeList getChildNodes()
165 {
166
167
168 return new DOMNodeListImpl(null);
169 }
170
171 /**
172 * @todo DOM level 2 getFirstChild() Not implemented. Returns null.
173 * @see org.w3c.dom.Node#getFirstChild()
174 */
175 public org.w3c.dom.Node getFirstChild()
176 {
177 return null;
178 }
179
180 /**
181 * @todo DOM level 2 getLastChild() Not implemented. Returns null.
182 * @see org.w3c.dom.Node#getLastChild()
183 */
184 public org.w3c.dom.Node getLastChild()
185 {
186 return null;
187 }
188
189 /**
190 * @see org.w3c.dom.Node#getPreviousSibling()
191 */
192 public org.w3c.dom.Node getPreviousSibling()
193 {
194
195 return null;
196 }
197
198 /**
199 * @see org.w3c.dom.Node#getNextSibling()
200 */
201 public org.w3c.dom.Node getNextSibling()
202 {
203
204 return null;
205 }
206
207 /**
208 * @see org.w3c.dom.Node#getAttributes()
209 */
210 public org.w3c.dom.NamedNodeMap getAttributes()
211 {
212 return null;
213 }
214
215 /**
216 * @todo DOM level 2 getOwnerDocument() Not implemented. Returns null.
217 * @see org.w3c.dom.Node#getOwnerDocument()
218 */
219 public org.w3c.dom.Document getOwnerDocument()
220 {
221 return null;
222 }
223
224 /**
225 * Not supported.
226 * @see org.w3c.dom.Node#insertBefore(org.w3c.dom.Node, org.w3c.dom.Node)
227 */
228 public org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild) throws DOMException
229 {
230 throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, "Not supported");
231 }
232
233 /**
234 * Not supported.
235 * @see org.w3c.dom.Node#replaceChild(org.w3c.dom.Node, org.w3c.dom.Node)
236 */
237 public org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild, org.w3c.dom.Node oldChild) throws DOMException
238 {
239 throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, "Not supported");
240 }
241
242 /**
243 * Not supported.
244 * @see org.w3c.dom.Node#removeChild(org.w3c.dom.Node)
245 */
246 public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild) throws DOMException
247 {
248 throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, "Not supported");
249 }
250
251 /**
252 * Not supported.
253 * @see org.w3c.dom.Node#appendChild(org.w3c.dom.Node)
254 */
255 public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild) throws DOMException
256 {
257 throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, "Not supported");
258 }
259
260 /**
261 * @see org.w3c.dom.Node#hasChildNodes()
262 */
263 public boolean hasChildNodes()
264 {
265 return false;
266 }
267
268 /**
269 * @see org.w3c.dom.Node#cloneNode(boolean)
270 */
271 public org.w3c.dom.Node cloneNode(boolean deep)
272 {
273
274
275
276 return (org.w3c.dom.Node) clone();
277 }
278
279 /**
280 * @todo DOM level 2 getOwnerElement() Not implemented. Returns null.
281 * @see org.w3c.dom.Attr#getOwnerElement()
282 */
283 public org.w3c.dom.Element getOwnerElement()
284 {
285 return null;
286 }
287
288 /**
289 * @todo DOM level 3 getSchemaTypeInfo() Not implemented. Returns null.
290 * @see org.w3c.dom.Attr#getSchemaTypeInfo()
291 */
292 public TypeInfo getSchemaTypeInfo()
293 {
294 return null;
295 }
296
297 /**
298 * @see org.w3c.dom.Attr#isId()
299 */
300 public boolean isId()
301 {
302 return "id".equals(this.avAdaptee.getAttribute());
303 }
304
305 /**
306 * @see java.lang.Object#clone()
307 */
308 protected Object clone()
309 {
310 DOMAttrImpl clone;
311 try
312 {
313 clone = (DOMAttrImpl) super.clone();
314 }
315 catch (CloneNotSupportedException e)
316 {
317
318 throw new RuntimeException("Clone not supported");
319 }
320 clone.avAdaptee = (AttVal) this.avAdaptee.clone();
321 return clone;
322 }
323 }