KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > text > syntax > 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.modules.xml.text.syntax.dom;
21
22 import org.w3c.dom.*;
23 import org.netbeans.modules.xml.text.syntax.*;
24 import org.netbeans.modules.xml.spi.dom.*;
25 import org.netbeans.editor.*;
26
27 /**
28  * Read-only DOM Comment node.
29  *
30  * @author Petr Kuzel
31  */

32 public class CommentImpl extends SyntaxNode implements Comment {
33
34     public CommentImpl(XMLSyntaxSupport support, TokenItem from, int to) {
35         super( support, from, to );
36     }
37
38     public String JavaDoc toString() {
39         return "Comment" + super.toString() + "<!--" + getData() + "-->";
40     }
41     
42     public String JavaDoc getNodeValue() throws org.w3c.dom.DOMException JavaDoc {
43         return getData();
44     }
45     
46     public String JavaDoc getNodeName() {
47         return "#comment"; //NOI18N
48
}
49     
50     public short getNodeType() {
51         return Node.COMMENT_NODE;
52     }
53     
54     public Text splitText(int offset) {
55         throw new ROException();
56     }
57  
58     /**
59      * @return data without delimiters
60      */

61     public String JavaDoc getData() {
62         String JavaDoc data = first.getImage(); //??? it is always one image
63
return data.substring(("<!--".length() - 1) , (data.length() - "-->".length() -1 )); //NOI18N
64
}
65
66     public void setData(String JavaDoc data) {
67         throw new ROException();
68     }
69     
70     public int getLength() {
71         return getData().length();
72     }
73     
74     public String JavaDoc substringData(int offset, int count) {
75         return getData().substring(offset, offset + count + 1);
76     }
77
78     public void appendData(String JavaDoc arg) {
79         throw new ROException();
80     }
81     
82     public void insertData(int offset, String JavaDoc arg) {
83         throw new ROException();
84     }
85
86
87     public void deleteData(int offset, int count) {
88         throw new ROException();
89     }
90
91     public void replaceData(int offset, int count, String JavaDoc arg) {
92         throw new ROException();
93     }
94
95     
96 }
97
98
Popular Tags