KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > impl > xs > opti > DefaultText


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.xerces.impl.xs.opti;
18
19 import org.w3c.dom.Text JavaDoc;
20 import org.w3c.dom.DOMException JavaDoc;
21
22 /*
23  * @author Neil Graham, IBM
24  * @version $Id: DefaultText.java,v 1.5 2004/10/06 15:14:49 mrglavas Exp $
25  */

26 /**
27  * The <code>Text</code> interface inherits from <code>CharacterData</code>
28  * and represents the textual content (termed character data in XML) of an
29  * <code>Element</code> or <code>Attr</code>. If there is no markup inside
30  * an element's content, the text is contained in a single object
31  * implementing the <code>Text</code> interface that is the only child of
32  * the element. If there is markup, it is parsed into the information items
33  * (elements, comments, etc.) and <code>Text</code> nodes that form the list
34  * of children of the element.
35  * <p>When a document is first made available via the DOM, there is only one
36  * <code>Text</code> node for each block of text. Users may create adjacent
37  * <code>Text</code> nodes that represent the contents of a given element
38  * without any intervening markup, but should be aware that there is no way
39  * to represent the separations between these nodes in XML or HTML, so they
40  * will not (in general) persist between DOM editing sessions. The
41  * <code>normalize()</code> method on <code>Node</code> merges any such
42  * adjacent <code>Text</code> objects into a single node for each block of
43  * text.
44  * <p>See also the <a HREF='http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113'>Document Object Model (DOM) Level 2 Core Specification</a>.
45  *
46  * This is an empty implementation.
47  *
48  * @xerces.internal
49  */

50 public class DefaultText extends NodeImpl implements Text JavaDoc {
51
52     // CharacterData methods
53

54     /**
55      * The character data of the node that implements this interface. The DOM
56      * implementation may not put arbitrary limits on the amount of data
57      * that may be stored in a <code>CharacterData</code> node. However,
58      * implementation limits may mean that the entirety of a node's data may
59      * not fit into a single <code>DOMString</code>. In such cases, the user
60      * may call <code>substringData</code> to retrieve the data in
61      * appropriately sized pieces.
62      * @exception DOMException
63      * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
64      * @exception DOMException
65      * DOMSTRING_SIZE_ERR: Raised when it would return more characters than
66      * fit in a <code>DOMString</code> variable on the implementation
67      * platform.
68      */

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

89     public void setData(String JavaDoc data)
90                             throws DOMException JavaDoc {
91         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
92     }
93
94     /**
95      * The number of 16-bit units that are available through <code>data</code>
96      * and the <code>substringData</code> method below. This may have the
97      * value zero, i.e., <code>CharacterData</code> nodes may be empty.
98      */

99     public int getLength() {
100         return 0;
101     }
102
103     /**
104      * Extracts a range of data from the node.
105      * @param offset Start offset of substring to extract.
106      * @param count The number of 16-bit units to extract.
107      * @return The specified substring. If the sum of <code>offset</code> and
108      * <code>count</code> exceeds the <code>length</code>, then all 16-bit
109      * units to the end of the data are returned.
110      * @exception DOMException
111      * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
112      * negative or greater than the number of 16-bit units in
113      * <code>data</code>, or if the specified <code>count</code> is
114      * negative.
115      * <br>DOMSTRING_SIZE_ERR: Raised if the specified range of text does
116      * not fit into a <code>DOMString</code>.
117      */

118     public String JavaDoc substringData(int offset,
119                                 int count)
120                                 throws DOMException JavaDoc {
121         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
122     }
123
124     /**
125      * Append the string to the end of the character data of the node. Upon
126      * success, <code>data</code> provides access to the concatenation of
127      * <code>data</code> and the <code>DOMString</code> specified.
128      * @param arg The <code>DOMString</code> to append.
129      * @exception DOMException
130      * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
131      */

132     public void appendData(String JavaDoc arg)
133                            throws DOMException JavaDoc {
134         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
135     }
136
137     /**
138      * Insert a string at the specified 16-bit unit offset.
139      * @param offset The character offset at which to insert.
140      * @param arg The <code>DOMString</code> to insert.
141      * @exception DOMException
142      * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
143      * negative or greater than the number of 16-bit units in
144      * <code>data</code>.
145      * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
146      */

147     public void insertData(int offset,
148                            String JavaDoc arg)
149                            throws DOMException JavaDoc {
150         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
151     }
152
153     /**
154      * Remove a range of 16-bit units from the node. Upon success,
155      * <code>data</code> and <code>length</code> reflect the change.
156      * @param offset The offset from which to start removing.
157      * @param count The number of 16-bit units to delete. If the sum of
158      * <code>offset</code> and <code>count</code> exceeds
159      * <code>length</code> then all 16-bit units from <code>offset</code>
160      * to the end of the data are deleted.
161      * @exception DOMException
162      * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
163      * negative or greater than the number of 16-bit units in
164      * <code>data</code>, or if the specified <code>count</code> is
165      * negative.
166      * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
167      */

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

193     public void replaceData(int offset,
194                             int count,
195                             String JavaDoc arg)
196                             throws DOMException JavaDoc {
197         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
198     }
199
200     // Text node methods
201
/**
202      * Breaks this node into two nodes at the specified <code>offset</code>,
203      * keeping both in the tree as siblings. After being split, this node
204      * will contain all the content up to the <code>offset</code> point. A
205      * new node of the same type, which contains all the content at and
206      * after the <code>offset</code> point, is returned. If the original
207      * node had a parent node, the new node is inserted as the next sibling
208      * of the original node. When the <code>offset</code> is equal to the
209      * length of this node, the new node has no data.
210      * @param offset The 16-bit unit offset at which to split, starting from
211      * <code>0</code>.
212      * @return The new node, of the same type as this node.
213      * @exception DOMException
214      * INDEX_SIZE_ERR: Raised if the specified offset is negative or greater
215      * than the number of 16-bit units in <code>data</code>.
216      * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
217      */

218     public Text JavaDoc splitText(int offset)
219                           throws DOMException JavaDoc {
220         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
221     }
222
223     /** DOM Level 3 CR */
224     public boolean isElementContentWhitespace(){
225         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
226     }
227     
228     public String JavaDoc getWholeText(){
229         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
230     }
231     
232     public Text JavaDoc replaceWholeText(String JavaDoc content) throws DOMException JavaDoc {
233         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
234     }
235 }
236
Popular Tags