001: /*
002: * @(#)HashMapNode.java 1.36 02/03/21
003: *
004: * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
005: * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
006: */
007: package org.enhydra.xml;
008:
009: import org.w3c.dom.Attr;
010: import org.w3c.dom.DOMException;
011: import org.w3c.dom.Element;
012: import org.w3c.dom.Node;
013: import org.w3c.dom.TypeInfo;
014: import org.w3c.dom.UserDataHandler;
015:
016: /**
017: * @author Tweety
018: *
019: * A class representing a node in a meta-data tree, which implements
020: * the <a href="../../../../api/org/w3c/dom/Attr.html">
021: *
022: * <p> Namespaces are ignored in this implementation. The terms "tag
023: * name" and "node name" are always considered to be synonymous.
024: *
025: * @version 1.0
026: */
027: public class AttrImpl extends NodeImpl implements Attr {
028:
029: /**
030: * If this attribute was explicitly given a value in the original
031: * document, this is <code>true</code>; otherwise, it is
032: * <code>false</code>.
033: */
034: boolean specified = true;
035:
036: /**
037: * Document owner.
038: */
039: Element owner;
040:
041: /**
042: * Attribute name.
043: */
044: String name;
045:
046: /**
047: * Attribute value.
048: */
049: String value;
050:
051: /**
052: * Constructs an empty <code>AttrImpl</code>.
053: *
054: * @param owner document owner.
055: * @param name node name.
056: * @param value node value.
057: */
058: public AttrImpl(Element owner, String name, String value) {
059: this .owner = owner;
060: this .name = name;
061: this .value = value;
062: }
063:
064: /**
065: * Constructs a <code>AttrImpl</code> from the given node.
066: *
067: * @param node, as a <code>AttrImpl</code>.
068: */
069: public AttrImpl(Attr attr) {
070: this .owner = attr.getOwnerElement();
071: this .name = attr.getName();
072: this .value = attr.getValue();
073: }
074:
075: /**
076: * Returns the attribute name associated with this node.
077: *
078: * @return the attribute name, as a <code>String</code>.
079: */
080: public String getName() {
081: return name;
082: }
083:
084: /**
085: * Returns the name associated with this node.
086: *
087: * @return the name, as a <code>String</code>.
088: */
089: public String getNodeName() {
090: return name;
091: }
092:
093: /**
094: * Returns the node type.
095: *
096: * @return the <code>ATTRIBUTE_NODE</code> node type.
097: */
098: public short getNodeType() {
099: return ATTRIBUTE_NODE;
100: }
101:
102: /**
103: * If this attribute was explicitly given a value in the original
104: * document, this is <code>true</code>; otherwise, it is
105: * <code>false</code>. Note that the implementation is in charge of this
106: * attribute, not the user. If the user changes the value of the
107: * attribute (even if it ends up having the same value as the default
108: * value) then the <code>specified</code> flag is automatically flipped
109: * to <code>true</code>. To re-specify the attribute as the default
110: * value from the DTD, the user must delete the attribute. The
111: * implementation will then make a new attribute available with
112: * <code>specified</code> set to <code>false</code> and the default
113: * value (if one exists).
114: * <br>In summary: If the attribute has an assigned value in the document
115: * then <code>specified</code> is <code>true</code>, and the value is
116: * the assigned value.If the attribute has no assigned value in the
117: * document and has a default value in the DTD, then
118: * <code>specified</code> is <code>false</code>, and the value is the
119: * default value in the DTD.If the attribute has no assigned value in
120: * the document and has a value of #IMPLIED in the DTD, then the
121: * attribute does not appear in the structure model of the document.If
122: * the <code>ownerElement</code> attribute is <code>null</code> (i.e.
123: * because it was just created or was set to <code>null</code> by the
124: * various removal and cloning operations) <code>specified</code> is
125: * <code>true</code>.
126: *
127: * Retuns always <code>true</code>.
128: */
129: public boolean getSpecified() {
130: return specified;
131: }
132:
133: /**
134: * Returns the value associated with this attributes.
135: *
136: * @return the node attributes, as a <code>String</code>.
137: */
138: public String getValue() {
139: return value;
140: }
141:
142: /**
143: * Returns the value associated with this node.
144: *
145: * @return the node value, as a <code>String</code>.
146: */
147: public String getNodeValue() {
148: return value;
149: }
150:
151: /**
152: * Sets the value of this attribute to the given one.
153: *
154: * @param value the new attribute value, as a <code>String</code>.
155: */
156: public void setValue(String value) {
157: this .value = value;
158: }
159:
160: /**
161: * Sets the value of this node to the given one.
162: *
163: * @return the node value, as a <code>String</code>.
164: */
165: public void setNodeValue(String value) {
166: this .value = value;
167: }
168:
169: /**
170: * Returns the owner of this attribute.
171: *
172: * @return the attribute owner node.
173: */
174: public Element getOwnerElement() {
175: return owner;
176: }
177:
178: /* (non-Javadoc)
179: * @see org.w3c.dom.Attr#getSchemaTypeInfo()
180: */
181: public TypeInfo getSchemaTypeInfo() {
182: // TODO Auto-generated method stub
183: return null;
184: }
185:
186: /* (non-Javadoc)
187: * @see org.w3c.dom.Attr#isId()
188: */
189: public boolean isId() {
190: // TODO Auto-generated method stub
191: return false;
192: }
193:
194: /* (non-Javadoc)
195: * @see org.w3c.dom.Node#getNamespaceURI()
196: */
197: public String getNamespaceURI() {
198: // TODO Auto-generated method stub
199: return null;
200: }
201:
202: /* (non-Javadoc)
203: * @see org.w3c.dom.Node#getBaseURI()
204: */
205: public String getBaseURI() {
206: // TODO Auto-generated method stub
207: return null;
208: }
209:
210: /* (non-Javadoc)
211: * @see org.w3c.dom.Node#compareDocumentPosition(org.w3c.dom.Node)
212: */
213: public short compareDocumentPosition(Node arg0) throws DOMException {
214: // TODO Auto-generated method stub
215: return 0;
216: }
217:
218: /* (non-Javadoc)
219: * @see org.w3c.dom.Node#getTextContent()
220: */
221: public String getTextContent() throws DOMException {
222: // TODO Auto-generated method stub
223: return null;
224: }
225:
226: /* (non-Javadoc)
227: * @see org.w3c.dom.Node#setTextContent(java.lang.String)
228: */
229: public void setTextContent(String arg0) throws DOMException {
230: // TODO Auto-generated method stub
231:
232: }
233:
234: /* (non-Javadoc)
235: * @see org.w3c.dom.Node#isSameNode(org.w3c.dom.Node)
236: */
237: public boolean isSameNode(Node arg0) {
238: // TODO Auto-generated method stub
239: return false;
240: }
241:
242: /* (non-Javadoc)
243: * @see org.w3c.dom.Node#lookupPrefix(java.lang.String)
244: */
245: public String lookupPrefix(String arg0) {
246: // TODO Auto-generated method stub
247: return null;
248: }
249:
250: /* (non-Javadoc)
251: * @see org.w3c.dom.Node#isDefaultNamespace(java.lang.String)
252: */
253: public boolean isDefaultNamespace(String arg0) {
254: // TODO Auto-generated method stub
255: return false;
256: }
257:
258: /* (non-Javadoc)
259: * @see org.w3c.dom.Node#lookupNamespaceURI(java.lang.String)
260: */
261: public String lookupNamespaceURI(String arg0) {
262: // TODO Auto-generated method stub
263: return null;
264: }
265:
266: /* (non-Javadoc)
267: * @see org.w3c.dom.Node#isEqualNode(org.w3c.dom.Node)
268: */
269: public boolean isEqualNode(Node arg0) {
270: // TODO Auto-generated method stub
271: return false;
272: }
273:
274: /* (non-Javadoc)
275: * @see org.w3c.dom.Node#getFeature(java.lang.String, java.lang.String)
276: */
277: public Object getFeature(String arg0, String arg1) {
278: // TODO Auto-generated method stub
279: return null;
280: }
281:
282: /* (non-Javadoc)
283: * @see org.w3c.dom.Node#setUserData(java.lang.String, java.lang.Object, org.w3c.dom.UserDataHandler)
284: */
285: public Object setUserData(String arg0, Object arg1,
286: UserDataHandler arg2) {
287: // TODO Auto-generated method stub
288: return null;
289: }
290:
291: /* (non-Javadoc)
292: * @see org.w3c.dom.Node#getUserData(java.lang.String)
293: */
294: public Object getUserData(String arg0) {
295: // TODO Auto-generated method stub
296: return null;
297: }
298: }
|