KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > tax > dom > AttrImpl


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.tax.dom;
21
22 import org.w3c.dom.*;
23 import org.netbeans.tax.*;
24
25 /**
26  *
27  * @author Petr Kuzel
28  */

29 class AttrImpl extends NodeImpl implements Attr {
30
31     private final TreeAttribute peer;
32
33     /** Creates a new instance of AttrImpl */
34     public AttrImpl(TreeAttribute peer) {
35         this.peer = peer;
36     }
37
38     /** The name of this node, depending on its type; see the table above.
39      *
40      */

41     public String JavaDoc getNodeName() {
42         return getName();
43     }
44
45     /** A code representing the type of the underlying object, as defined above.
46      *
47      */

48     public short getNodeType() {
49         return Node.ATTRIBUTE_NODE;
50     }
51     
52     /** The value of this node, depending on its type; see the table above.
53      * When it is defined to be <code>null</code>, setting it has no effect.
54      * @exception DOMException
55      * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
56      * @exception DOMException
57      * DOMSTRING_SIZE_ERR: Raised when it would return more characters than
58      * fit in a <code>DOMString</code> variable on the implementation
59      * platform.
60      *
61      */

62     public String JavaDoc getNodeValue() throws DOMException {
63         return getValue();
64     }
65     
66     /** The parent of this node. All nodes, except <code>Attr</code>,
67      * <code>Document</code>, <code>DocumentFragment</code>,
68      * <code>Entity</code>, and <code>Notation</code> may have a parent.
69      * However, if a node has just been created and not yet added to the
70      * tree, or if it has been removed from the tree, this is
71      * <code>null</code>.
72      *
73      */

74     public Node getParentNode() {
75         return null;
76     }
77     
78     /** Returns the name of this attribute.
79      *
80      */

81     public String JavaDoc getName() {
82         return peer.getQName();
83     }
84     
85     /** The <code>Element</code> node this attribute is attached to or
86      * <code>null</code> if this attribute is not in use.
87      * @since DOM Level 2
88      *
89      */

90     public Element getOwnerElement() {
91         return Wrapper.wrap(peer.getOwnerElement());
92     }
93     
94     /** If this attribute was explicitly given a value in the original
95      * document, this is <code>true</code>; otherwise, it is
96      * <code>false</code>. Note that the implementation is in charge of this
97      * attribute, not the user. If the user changes the value of the
98      * attribute (even if it ends up having the same value as the default
99      * value) then the <code>specified</code> flag is automatically flipped
100      * to <code>true</code>. To re-specify the attribute as the default
101      * value from the DTD, the user must delete the attribute. The
102      * implementation will then make a new attribute available with
103      * <code>specified</code> set to <code>false</code> and the default
104      * value (if one exists).
105      * <br>In summary: If the attribute has an assigned value in the document
106      * then <code>specified</code> is <code>true</code>, and the value is
107      * the assigned value.If the attribute has no assigned value in the
108      * document and has a default value in the DTD, then
109      * <code>specified</code> is <code>false</code>, and the value is the
110      * default value in the DTD.If the attribute has no assigned value in
111      * the document and has a value of #IMPLIED in the DTD, then the
112      * attribute does not appear in the structure model of the document.If
113      * the <code>ownerElement</code> attribute is <code>null</code> (i.e.
114      * because it was just created or was set to <code>null</code> by the
115      * various removal and cloning operations) <code>specified</code> is
116      * <code>true</code>.
117      *
118      */

119     public boolean getSpecified() {
120         return peer.isSpecified();
121     }
122     
123     /** On retrieval, the value of the attribute is returned as a string.
124      * Character and general entity references are replaced with their
125      * values. See also the method <code>getAttribute</code> on the
126      * <code>Element</code> interface.
127      * <br>On setting, this creates a <code>Text</code> node with the unparsed
128      * contents of the string. I.e. any characters that an XML processor
129      * would recognize as markup are instead treated as literal text. See
130      * also the method <code>setAttribute</code> on the <code>Element</code>
131      * interface.
132      * @exception DOMException
133      * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
134      *
135      */

136     public String JavaDoc getValue() {
137         return peer.getValue();
138     }
139     
140     /** On retrieval, the value of the attribute is returned as a string.
141      * Character and general entity references are replaced with their
142      * values. See also the method <code>getAttribute</code> on the
143      * <code>Element</code> interface.
144      * <br>On setting, this creates a <code>Text</code> node with the unparsed
145      * contents of the string. I.e. any characters that an XML processor
146      * would recognize as markup are instead treated as literal text. See
147      * also the method <code>setAttribute</code> on the <code>Element</code>
148      * interface.
149      * @exception DOMException
150      * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
151      *
152      */

153     public void setValue(String JavaDoc value) throws DOMException {
154         throw new ROException();
155     }
156     
157 }
158
Popular Tags