KickJava   Java API By Example, From Geeks To Geeks.

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


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 CommentImpl extends NodeImpl implements Comment {
30
31     private final TreeComment peer;
32
33     /** Creates a new instance of AttrImpl */
34     public CommentImpl(TreeComment peer) {
35         this.peer = peer;
36     }
37
38     /** Append the string to the end of the character data of the node. Upon
39      * success, <code>data</code> provides access to the concatenation of
40      * <code>data</code> and the <code>DOMString</code> specified.
41      * @param arg The <code>DOMString</code> to append.
42      * @exception DOMException
43      * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
44      *
45      */

46     public void appendData(String JavaDoc arg) throws DOMException {
47         throw new ROException();
48     }
49     
50     /** Remove a range of 16-bit units from the node. Upon success,
51      * <code>data</code> and <code>length</code> reflect the change.
52      * @param offset The offset from which to start removing.
53      * @param count The number of 16-bit units to delete. If the sum of
54      * <code>offset</code> and <code>count</code> exceeds
55      * <code>length</code> then all 16-bit units from <code>offset</code>
56      * to the end of the data are deleted.
57      * @exception DOMException
58      * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
59      * negative or greater than the number of 16-bit units in
60      * <code>data</code>, or if the specified <code>count</code> is
61      * negative.
62      * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
63      *
64      */

65     public void deleteData(int offset, int count) throws DOMException {
66         throw new ROException();
67     }
68     
69     /** The character data of the node that implements this interface. The DOM
70      * implementation may not put arbitrary limits on the amount of data
71      * that may be stored in a <code>CharacterData</code> node. However,
72      * implementation limits may mean that the entirety of a node's data may
73      * not fit into a single <code>DOMString</code>. In such cases, the user
74      * may call <code>substringData</code> to retrieve the data in
75      * appropriately sized pieces.
76      * @exception DOMException
77      * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
78      * @exception DOMException
79      * DOMSTRING_SIZE_ERR: Raised when it would return more characters than
80      * fit in a <code>DOMString</code> variable on the implementation
81      * platform.
82      *
83      */

84     public String JavaDoc getData() throws DOMException {
85         return peer.getData();
86     }
87     
88     /** The number of 16-bit units that are available through <code>data</code>
89      * and the <code>substringData</code> method below. This may have the
90      * value zero, i.e., <code>CharacterData</code> nodes may be empty.
91      *
92      */

93     public int getLength() {
94         return peer.getLength();
95     }
96     
97     /** The name of this node, depending on its type; see the table above.
98      *
99      */

100     public String JavaDoc getNodeName() {
101         return "#comment";
102     }
103     
104     /** A code representing the type of the underlying object, as defined above.
105      *
106      */

107     public short getNodeType() {
108         return Node.COMMENT_NODE;
109     }
110     
111     /** The value of this node, depending on its type; see the table above.
112      * When it is defined to be <code>null</code>, setting it has no effect.
113      * @exception DOMException
114      * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
115      * @exception DOMException
116      * DOMSTRING_SIZE_ERR: Raised when it would return more characters than
117      * fit in a <code>DOMString</code> variable on the implementation
118      * platform.
119      *
120      */

121     public String JavaDoc getNodeValue() throws DOMException {
122         return getData();
123     }
124     
125     /** The parent of this node. All nodes, except <code>Attr</code>,
126      * <code>Document</code>, <code>DocumentFragment</code>,
127      * <code>Entity</code>, and <code>Notation</code> may have a parent.
128      * However, if a node has just been created and not yet added to the
129      * tree, or if it has been removed from the tree, this is
130      * <code>null</code>.
131      *
132      */

133     public Node getParentNode() {
134         
135         TreeParentNode parent = peer.getParentNode();
136         if( parent == null )
137         {
138             return null;
139         }
140
141         Node result = null;
142         try
143         {
144             result = Wrapper.wrap(parent);
145         }
146         catch( RuntimeException JavaDoc ex ) {}
147
148         return result;
149     }
150     
151     /** Insert a string at the specified 16-bit unit offset.
152      * @param offset The character offset at which to insert.
153      * @param arg The <code>DOMString</code> to insert.
154      * @exception DOMException
155      * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
156      * negative or greater than the number of 16-bit units in
157      * <code>data</code>.
158      * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
159      *
160      */

161     public void insertData(int offset, String JavaDoc arg) throws DOMException {
162         throw new ROException();
163     }
164     
165     /** Replace the characters starting at the specified 16-bit unit offset
166      * with the specified string.
167      * @param offset The offset from which to start replacing.
168      * @param count The number of 16-bit units to replace. If the sum of
169      * <code>offset</code> and <code>count</code> exceeds
170      * <code>length</code>, then all 16-bit units to the end of the data
171      * are replaced; (i.e., the effect is the same as a <code>remove</code>
172      * method call with the same range, followed by an <code>append</code>
173      * method invocation).
174      * @param arg The <code>DOMString</code> with which the range must be
175      * replaced.
176      * @exception DOMException
177      * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
178      * negative or greater than the number of 16-bit units in
179      * <code>data</code>, or if the specified <code>count</code> is
180      * negative.
181      * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
182      *
183      */

184     public void replaceData(int offset, int count, String JavaDoc arg) throws DOMException {
185         throw new ROException();
186     }
187     
188     /** The character data of the node that implements this interface. The DOM
189      * implementation may not put arbitrary limits on the amount of data
190      * that may be stored in a <code>CharacterData</code> node. However,
191      * implementation limits may mean that the entirety of a node's data may
192      * not fit into a single <code>DOMString</code>. In such cases, the user
193      * may call <code>substringData</code> to retrieve the data in
194      * appropriately sized pieces.
195      * @exception DOMException
196      * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
197      * @exception DOMException
198      * DOMSTRING_SIZE_ERR: Raised when it would return more characters than
199      * fit in a <code>DOMString</code> variable on the implementation
200      * platform.
201      *
202      */

203     public void setData(String JavaDoc data) throws DOMException {
204         throw new ROException();
205     }
206     
207     /** Extracts a range of data from the node.
208      * @param offset Start offset of substring to extract.
209      * @param count The number of 16-bit units to extract.
210      * @return The specified substring. If the sum of <code>offset</code> and
211      * <code>count</code> exceeds the <code>length</code>, then all 16-bit
212      * units to the end of the data are returned.
213      * @exception DOMException
214      * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
215      * negative or greater than the number of 16-bit units in
216      * <code>data</code>, or if the specified <code>count</code> is
217      * negative.
218      * <br>DOMSTRING_SIZE_ERR: Raised if the specified range of text does
219      * not fit into a <code>DOMString</code>.
220      *
221      */

222     public String JavaDoc substringData(int offset, int count) throws DOMException {
223         try {
224             return peer.substringData(offset, count);
225         } catch (InvalidArgumentException ex) {
226             throw new UOException();
227         }
228     }
229     
230     /** The node immediately preceding this node. If there is no such node,
231      * this returns <code>null</code>.
232      *
233      */

234     public Node getPreviousSibling() {
235         return Children.getPreviousSibling(peer);
236     }
237  
238     /** The node immediately following this node. If there is no such node,
239      * this returns <code>null</code>.
240      *
241      */

242     public Node getNextSibling() {
243         return Children.getNextSibling(peer);
244     }
245     
246 }
247
Popular Tags