KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > xml > AttrImpl


1 /*
2  * @(#)HashMapNode.java 1.36 02/03/21
3  *
4  * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 package org.enhydra.xml;
8
9 import org.w3c.dom.Attr JavaDoc;
10 import org.w3c.dom.DOMException JavaDoc;
11 import org.w3c.dom.Element JavaDoc;
12 import org.w3c.dom.Node JavaDoc;
13 import org.w3c.dom.TypeInfo JavaDoc;
14 import org.w3c.dom.UserDataHandler JavaDoc;
15
16
17 /**
18  * @author Tweety
19  *
20  * A class representing a node in a meta-data tree, which implements
21  * the <a HREF="../../../../api/org/w3c/dom/Attr.html">
22  *
23  * <p> Namespaces are ignored in this implementation. The terms "tag
24  * name" and "node name" are always considered to be synonymous.
25  *
26  * @version 1.0
27  */

28 public class AttrImpl extends NodeImpl implements Attr JavaDoc {
29
30     /**
31      * If this attribute was explicitly given a value in the original
32      * document, this is <code>true</code>; otherwise, it is
33      * <code>false</code>.
34      */

35     boolean specified = true;
36
37     /**
38      * Document owner.
39      */

40     Element JavaDoc owner;
41     
42     /**
43      * Attribute name.
44      */

45     String JavaDoc name;
46     
47     /**
48      * Attribute value.
49      */

50     String JavaDoc value;
51
52
53     
54     /**
55      * Constructs an empty <code>AttrImpl</code>.
56      *
57      * @param owner document owner.
58      * @param name node name.
59      * @param value node value.
60      */

61     public AttrImpl(Element JavaDoc owner, String JavaDoc name, String JavaDoc value) {
62         this.owner = owner;
63         this.name = name;
64         this.value = value;
65     }
66
67     /**
68      * Constructs a <code>AttrImpl</code> from the given node.
69      *
70      * @param node, as a <code>AttrImpl</code>.
71      */

72     public AttrImpl(Attr JavaDoc attr) {
73         this.owner = attr.getOwnerElement();
74         this.name = attr.getName();
75         this.value = attr.getValue();
76     }
77
78     /**
79      * Returns the attribute name associated with this node.
80      *
81      * @return the attribute name, as a <code>String</code>.
82      */

83     public String JavaDoc getName() {
84         return name;
85     }
86
87     /**
88      * Returns the name associated with this node.
89      *
90      * @return the name, as a <code>String</code>.
91      */

92     public String JavaDoc getNodeName() {
93         return name;
94     }
95
96     /**
97      * Returns the node type.
98      *
99      * @return the <code>ATTRIBUTE_NODE</code> node type.
100      */

101     public short getNodeType() {
102         return ATTRIBUTE_NODE;
103     }
104
105
106     /**
107      * If this attribute was explicitly given a value in the original
108      * document, this is <code>true</code>; otherwise, it is
109      * <code>false</code>. Note that the implementation is in charge of this
110      * attribute, not the user. If the user changes the value of the
111      * attribute (even if it ends up having the same value as the default
112      * value) then the <code>specified</code> flag is automatically flipped
113      * to <code>true</code>. To re-specify the attribute as the default
114      * value from the DTD, the user must delete the attribute. The
115      * implementation will then make a new attribute available with
116      * <code>specified</code> set to <code>false</code> and the default
117      * value (if one exists).
118      * <br>In summary: If the attribute has an assigned value in the document
119      * then <code>specified</code> is <code>true</code>, and the value is
120      * the assigned value.If the attribute has no assigned value in the
121      * document and has a default value in the DTD, then
122      * <code>specified</code> is <code>false</code>, and the value is the
123      * default value in the DTD.If the attribute has no assigned value in
124      * the document and has a value of #IMPLIED in the DTD, then the
125      * attribute does not appear in the structure model of the document.If
126      * the <code>ownerElement</code> attribute is <code>null</code> (i.e.
127      * because it was just created or was set to <code>null</code> by the
128      * various removal and cloning operations) <code>specified</code> is
129      * <code>true</code>.
130      *
131      * Retuns always <code>true</code>.
132      */

133     public boolean getSpecified() {
134         return specified;
135     }
136
137     /**
138      * Returns the value associated with this attributes.
139      *
140      * @return the node attributes, as a <code>String</code>.
141      */

142     public String JavaDoc getValue() {
143         return value;
144     }
145
146     /**
147      * Returns the value associated with this node.
148      *
149      * @return the node value, as a <code>String</code>.
150      */

151     public String JavaDoc getNodeValue() {
152         return value;
153     }
154
155     /**
156      * Sets the value of this attribute to the given one.
157      *
158      * @param value the new attribute value, as a <code>String</code>.
159      */

160     public void setValue(String JavaDoc value) {
161         this.value = value;
162     }
163
164     /**
165      * Sets the value of this node to the given one.
166      *
167      * @return the node value, as a <code>String</code>.
168      */

169     public void setNodeValue(String JavaDoc value) {
170         this.value = value;
171     }
172
173     /**
174      * Returns the owner of this attribute.
175      *
176      * @return the attribute owner node.
177      */

178     public Element JavaDoc getOwnerElement() {
179         return owner;
180     }
181
182     /* (non-Javadoc)
183      * @see org.w3c.dom.Attr#getSchemaTypeInfo()
184      */

185     public TypeInfo JavaDoc getSchemaTypeInfo() {
186         // TODO Auto-generated method stub
187
return null;
188     }
189
190     /* (non-Javadoc)
191      * @see org.w3c.dom.Attr#isId()
192      */

193     public boolean isId() {
194         // TODO Auto-generated method stub
195
return false;
196     }
197
198     /* (non-Javadoc)
199      * @see org.w3c.dom.Node#getNamespaceURI()
200      */

201     public String JavaDoc getNamespaceURI() {
202         // TODO Auto-generated method stub
203
return null;
204     }
205
206     /* (non-Javadoc)
207      * @see org.w3c.dom.Node#getBaseURI()
208      */

209     public String JavaDoc getBaseURI() {
210         // TODO Auto-generated method stub
211
return null;
212     }
213
214     /* (non-Javadoc)
215      * @see org.w3c.dom.Node#compareDocumentPosition(org.w3c.dom.Node)
216      */

217     public short compareDocumentPosition(Node JavaDoc arg0) throws DOMException JavaDoc {
218         // TODO Auto-generated method stub
219
return 0;
220     }
221
222     /* (non-Javadoc)
223      * @see org.w3c.dom.Node#getTextContent()
224      */

225     public String JavaDoc getTextContent() throws DOMException JavaDoc {
226         // TODO Auto-generated method stub
227
return null;
228     }
229
230     /* (non-Javadoc)
231      * @see org.w3c.dom.Node#setTextContent(java.lang.String)
232      */

233     public void setTextContent(String JavaDoc arg0) throws DOMException JavaDoc {
234         // TODO Auto-generated method stub
235

236     }
237
238     /* (non-Javadoc)
239      * @see org.w3c.dom.Node#isSameNode(org.w3c.dom.Node)
240      */

241     public boolean isSameNode(Node JavaDoc arg0) {
242         // TODO Auto-generated method stub
243
return false;
244     }
245
246     /* (non-Javadoc)
247      * @see org.w3c.dom.Node#lookupPrefix(java.lang.String)
248      */

249     public String JavaDoc lookupPrefix(String JavaDoc arg0) {
250         // TODO Auto-generated method stub
251
return null;
252     }
253
254     /* (non-Javadoc)
255      * @see org.w3c.dom.Node#isDefaultNamespace(java.lang.String)
256      */

257     public boolean isDefaultNamespace(String JavaDoc arg0) {
258         // TODO Auto-generated method stub
259
return false;
260     }
261
262     /* (non-Javadoc)
263      * @see org.w3c.dom.Node#lookupNamespaceURI(java.lang.String)
264      */

265     public String JavaDoc lookupNamespaceURI(String JavaDoc arg0) {
266         // TODO Auto-generated method stub
267
return null;
268     }
269
270     /* (non-Javadoc)
271      * @see org.w3c.dom.Node#isEqualNode(org.w3c.dom.Node)
272      */

273     public boolean isEqualNode(Node JavaDoc arg0) {
274         // TODO Auto-generated method stub
275
return false;
276     }
277
278     /* (non-Javadoc)
279      * @see org.w3c.dom.Node#getFeature(java.lang.String, java.lang.String)
280      */

281     public Object JavaDoc getFeature(String JavaDoc arg0, String JavaDoc arg1) {
282         // TODO Auto-generated method stub
283
return null;
284     }
285
286     /* (non-Javadoc)
287      * @see org.w3c.dom.Node#setUserData(java.lang.String, java.lang.Object, org.w3c.dom.UserDataHandler)
288      */

289     public Object JavaDoc setUserData(String JavaDoc arg0, Object JavaDoc arg1, UserDataHandler JavaDoc arg2) {
290         // TODO Auto-generated method stub
291
return null;
292     }
293
294     /* (non-Javadoc)
295      * @see org.w3c.dom.Node#getUserData(java.lang.String)
296      */

297     public Object JavaDoc getUserData(String JavaDoc arg0) {
298         // TODO Auto-generated method stub
299
return null;
300     }
301 }
Popular Tags