1 /*
2 Copyright (C) 2003 Together
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this library; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19 package org.enhydra.xml;
20
21 import org.w3c.dom.Attr;
22 import org.w3c.dom.DOMException;
23 import org.w3c.dom.Document;
24 import org.w3c.dom.Element;
25 import org.w3c.dom.NamedNodeMap;
26 import org.w3c.dom.Node;
27 import org.w3c.dom.NodeList;
28 import org.w3c.dom.TypeInfo;
29 import org.w3c.dom.UserDataHandler;
30
31
32 /***
33 * @author Tweety
34 *
35 * A class representing a node in a meta-data tree, which implements
36 * the <a href="../../../../api/org/w3c/dom/Attr.html">
37 *
38 * <p> Namespaces are ignored in this implementation. The terms "tag
39 * name" and "node name" are always considered to be synonymous.
40 *
41 * @version 1.0
42 */
43 public class AttrImpl extends NodeImpl implements Attr {
44
45 /***
46 * If this attribute was explicitly given a value in the original
47 * document, this is <code>true</code>; otherwise, it is
48 * <code>false</code>.
49 */
50 boolean specified = true;
51
52 /***
53 * Document owner.
54 */
55 Element owner;
56
57 /***
58 * Attribute name.
59 */
60 String name;
61
62 /***
63 * Attribute value.
64 */
65 String value;
66
67
68
69 /***
70 * Constructs an empty <code>AttrImpl</code>.
71 *
72 * @param owner document owner.
73 * @param name node name.
74 * @param value node value.
75 */
76 public AttrImpl(Element owner, String name, String value) {
77 this.owner = owner;
78 this.name = name;
79 this.value = value;
80 }
81
82 /***
83 * Constructs a <code>AttrImpl</code> from the given node.
84 *
85 * @param attr , as a <code>AttrImpl</code>.
86 */
87 public AttrImpl(Attr attr) {
88 this.owner = attr.getOwnerElement();
89 this.name = attr.getName();
90 this.value = attr.getValue();
91 }
92
93 /***
94 * Returns the attribute name associated with this node.
95 *
96 * @return the attribute name, as a <code>String</code>.
97 */
98 public String getName() {
99 return name;
100 }
101
102 /***
103 * Returns the name associated with this node.
104 *
105 * @return the name, as a <code>String</code>.
106 */
107 public String getNodeName() {
108 return name;
109 }
110
111 /***
112 * Returns the node type.
113 *
114 * @return the <code>ATTRIBUTE_NODE</code> node type.
115 */
116 public short getNodeType() {
117 return ATTRIBUTE_NODE;
118 }
119
120
121 /***
122 * If this attribute was explicitly given a value in the original
123 * document, this is <code>true</code>; otherwise, it is
124 * <code>false</code>. Note that the implementation is in charge of this
125 * attribute, not the user. If the user changes the value of the
126 * attribute (even if it ends up having the same value as the default
127 * value) then the <code>specified</code> flag is automatically flipped
128 * to <code>true</code>. To re-specify the attribute as the default
129 * value from the DTD, the user must delete the attribute. The
130 * implementation will then make a new attribute available with
131 * <code>specified</code> set to <code>false</code> and the default
132 * value (if one exists).
133 * <br>In summary: If the attribute has an assigned value in the document
134 * then <code>specified</code> is <code>true</code>, and the value is
135 * the assigned value.If the attribute has no assigned value in the
136 * document and has a default value in the DTD, then
137 * <code>specified</code> is <code>false</code>, and the value is the
138 * default value in the DTD.If the attribute has no assigned value in
139 * the document and has a value of #IMPLIED in the DTD, then the
140 * attribute does not appear in the structure model of the document.If
141 * the <code>ownerElement</code> attribute is <code>null</code> (i.e.
142 * because it was just created or was set to <code>null</code> by the
143 * various removal and cloning operations) <code>specified</code> is
144 * <code>true</code>.
145 *
146 * @return always <code>true</code>.
147 */
148 public boolean getSpecified() {
149 return specified;
150 }
151
152 /***
153 * Returns the value associated with this attributes.
154 *
155 * @return the node attributes, as a <code>String</code>.
156 */
157 public String getValue() {
158 return value;
159 }
160
161 /***
162 * Returns the value associated with this node.
163 *
164 * @return the node value, as a <code>String</code>.
165 */
166 public String getNodeValue() {
167 return value;
168 }
169
170 /***
171 * Sets the value of this attribute to the given one.
172 *
173 * @param value the new attribute value, as a <code>String</code>.
174 */
175 public void setValue(String value) {
176 this.value = value;
177 }
178
179 /***
180 * Sets the value of this node to the given one.
181 *
182 * @param value is value of the node
183 */
184 public void setNodeValue(String value) {
185 this.value = value;
186 }
187
188 /***
189 * Returns the owner of this attribute.
190 *
191 * @return the attribute owner node.
192 */
193 public Element getOwnerElement() {
194 return owner;
195 }
196
197
198 /* METHODS FROM INTERFACE IN JDK1.5 */
199
200
201 public TypeInfo getSchemaTypeInfo() {
202 // TODO Auto-generated method stub
203 return null;
204 }
205 public boolean isId() {
206 // TODO Auto-generated method stub
207 return false;
208 }
209 protected void initNodeImplChildren(Node node) {
210 // TODO Auto-generated method stub
211 super.initNodeImplChildren(node);
212 }
213 protected Node newElementInstance(Node node) {
214 // TODO Auto-generated method stub
215 return super.newElementInstance(node);
216 }
217 protected Node newTextInstance(Node node) {
218 // TODO Auto-generated method stub
219 return super.newTextInstance(node);
220 }
221 protected Node newCommentInstance(Node node) {
222 // TODO Auto-generated method stub
223 return super.newCommentInstance(node);
224 }
225 protected Node newDefaultInstance(Node node) {
226 // TODO Auto-generated method stub
227 return super.newDefaultInstance(node);
228 }
229 protected void checkNode(Node node) throws DOMException {
230 // TODO Auto-generated method stub
231 super.checkNode(node);
232 }
233 public Node getParentNode() {
234 // TODO Auto-generated method stub
235 return super.getParentNode();
236 }
237 public NodeList getChildNodes() {
238 // TODO Auto-generated method stub
239 return super.getChildNodes();
240 }
241 public Node getFirstChild() {
242 // TODO Auto-generated method stub
243 return super.getFirstChild();
244 }
245 public Node getLastChild() {
246 // TODO Auto-generated method stub
247 return super.getLastChild();
248 }
249 public Node getPreviousSibling() {
250 // TODO Auto-generated method stub
251 return super.getPreviousSibling();
252 }
253 public Node getNextSibling() {
254 // TODO Auto-generated method stub
255 return super.getNextSibling();
256 }
257 public Document getOwnerDocument() {
258 // TODO Auto-generated method stub
259 return super.getOwnerDocument();
260 }
261 public Node insertBefore(Node newChild, Node refChild) {
262 // TODO Auto-generated method stub
263 return super.insertBefore(newChild, refChild);
264 }
265 public Node replaceChild(Node newChild, Node oldChild) {
266 // TODO Auto-generated method stub
267 return super.replaceChild(newChild, oldChild);
268 }
269 public Node removeChild(Node oldChild) {
270 // TODO Auto-generated method stub
271 return super.removeChild(oldChild);
272 }
273 public Node appendChild(Node newChild) {
274 // TODO Auto-generated method stub
275 return super.appendChild(newChild);
276 }
277 public boolean hasChildNodes() {
278 // TODO Auto-generated method stub
279 return super.hasChildNodes();
280 }
281 public Node cloneNode(boolean deep) {
282 // TODO Auto-generated method stub
283 return super.cloneNode(deep);
284 }
285 public void normalize() {
286 // TODO Auto-generated method stub
287 super.normalize();
288 }
289 public boolean isSupported(String feature, String version) {
290 // TODO Auto-generated method stub
291 return super.isSupported(feature, version);
292 }
293 public String getNamespaceURI() throws DOMException {
294 // TODO Auto-generated method stub
295 return super.getNamespaceURI();
296 }
297 public String getPrefix() {
298 // TODO Auto-generated method stub
299 return super.getPrefix();
300 }
301 public void setPrefix(String prefix) {
302 // TODO Auto-generated method stub
303 super.setPrefix(prefix);
304 }
305 public String getLocalName() {
306 // TODO Auto-generated method stub
307 return super.getLocalName();
308 }
309 public NamedNodeMap getAttributes() {
310 // TODO Auto-generated method stub
311 return super.getAttributes();
312 }
313 public boolean hasAttributes() {
314 // TODO Auto-generated method stub
315 return super.hasAttributes();
316 }
317 public int getLength() {
318 // TODO Auto-generated method stub
319 return super.getLength();
320 }
321 public Node item(int index) {
322 // TODO Auto-generated method stub
323 return super.item(index);
324 }
325 public String toString() {
326 // TODO Auto-generated method stub
327 return super.toString();
328 }
329 public String toString(String tab) {
330 // TODO Auto-generated method stub
331 return super.toString(tab);
332 }
333 protected void beginToString(StringBuffer sb, Indent indent) {
334 // TODO Auto-generated method stub
335 super.beginToString(sb, indent);
336 }
337 protected void endToString(StringBuffer sb, Indent indent) {
338 // TODO Auto-generated method stub
339 super.endToString(sb, indent);
340 }
341 public short compareDocumentPosition(Node other) throws DOMException {
342 // TODO Auto-generated method stub
343 return super.compareDocumentPosition(other);
344 }
345 public String getBaseURI() {
346 // TODO Auto-generated method stub
347 return super.getBaseURI();
348 }
349 public Object getFeature(String feature, String version) {
350 // TODO Auto-generated method stub
351 return super.getFeature(feature, version);
352 }
353 public String getTextContent() throws DOMException {
354 // TODO Auto-generated method stub
355 return super.getTextContent();
356 }
357 public Object getUserData(String key) {
358 // TODO Auto-generated method stub
359 return super.getUserData(key);
360 }
361 public boolean isDefaultNamespace(String namespaceURI) {
362 // TODO Auto-generated method stub
363 return super.isDefaultNamespace(namespaceURI);
364 }
365 public boolean isEqualNode(Node arg) {
366 // TODO Auto-generated method stub
367 return super.isEqualNode(arg);
368 }
369 public boolean isSameNode(Node other) {
370 // TODO Auto-generated method stub
371 return super.isSameNode(other);
372 }
373 public String lookupNamespaceURI(String prefix) {
374 // TODO Auto-generated method stub
375 return super.lookupNamespaceURI(prefix);
376 }
377 public String lookupPrefix(String namespaceURI) {
378 // TODO Auto-generated method stub
379 return super.lookupPrefix(namespaceURI);
380 }
381 public void setTextContent(String textContent) throws DOMException {
382 // TODO Auto-generated method stub
383 super.setTextContent(textContent);
384 }
385 public Object setUserData(String key, Object data, UserDataHandler handler) {
386 // TODO Auto-generated method stub
387 return super.setUserData(key, data, handler);
388 }
389 }
This page was automatically generated by Maven