KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  *
5  * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
6  * reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in
17  * the documentation and/or other materials provided with the
18  * distribution.
19  *
20  * 3. The end-user documentation included with the redistribution,
21  * if any, must include the following acknowledgment:
22  * "This product includes software developed by the
23  * Apache Software Foundation (http://www.apache.org/)."
24  * Alternately, this acknowledgment may appear in the software itself,
25  * if and wherever such third-party acknowledgments normally appear.
26  *
27  * 4. The names "Xerces" and "Apache Software Foundation" must
28  * not be used to endorse or promote products derived from this
29  * software without prior written permission. For written
30  * permission, please contact apache@apache.org.
31  *
32  * 5. Products derived from this software may not be called "Apache",
33  * nor may "Apache" appear in their name, without prior written
34  * permission of the Apache Software Foundation.
35  *
36  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47  * SUCH DAMAGE.
48  * ====================================================================
49  *
50  * This software consists of voluntary contributions made by many
51  * individuals on behalf of the Apache Software Foundation and was
52  * originally based on software copyright (c) 2001, International
53  * Business Machines, Inc., http://www.apache.org. For more
54  * information on the Apache Software Foundation, please see
55  * <http://www.apache.org/>.
56  */

57
58 package com.sun.org.apache.xerces.internal.impl.xs.opti;
59
60 import org.w3c.dom.Text JavaDoc;
61 import org.w3c.dom.DOMException JavaDoc;
62
63 /*
64  * @author Neil Graham, IBM
65  * @version $Id: DefaultText.java,v 1.3 2003/11/18 00:22:58 kk122374 Exp $
66  */

67 /**
68  * The <code>Text</code> interface inherits from <code>CharacterData</code>
69  * and represents the textual content (termed character data in XML) of an
70  * <code>Element</code> or <code>Attr</code>. If there is no markup inside
71  * an element's content, the text is contained in a single object
72  * implementing the <code>Text</code> interface that is the only child of
73  * the element. If there is markup, it is parsed into the information items
74  * (elements, comments, etc.) and <code>Text</code> nodes that form the list
75  * of children of the element.
76  * <p>When a document is first made available via the DOM, there is only one
77  * <code>Text</code> node for each block of text. Users may create adjacent
78  * <code>Text</code> nodes that represent the contents of a given element
79  * without any intervening markup, but should be aware that there is no way
80  * to represent the separations between these nodes in XML or HTML, so they
81  * will not (in general) persist between DOM editing sessions. The
82  * <code>normalize()</code> method on <code>Node</code> merges any such
83  * adjacent <code>Text</code> objects into a single node for each block of
84  * text.
85  * <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>.
86  *
87  * This is an empty implementation.
88  */

89 public class DefaultText extends NodeImpl implements Text JavaDoc {
90
91     // CharacterData methods
92

93     /**
94      * The character data of the node that implements this interface. The DOM
95      * implementation may not put arbitrary limits on the amount of data
96      * that may be stored in a <code>CharacterData</code> node. However,
97      * implementation limits may mean that the entirety of a node's data may
98      * not fit into a single <code>DOMString</code>. In such cases, the user
99      * may call <code>substringData</code> to retrieve the data in
100      * appropriately sized pieces.
101      * @exception DOMException
102      * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
103      * @exception DOMException
104      * DOMSTRING_SIZE_ERR: Raised when it would return more characters than
105      * fit in a <code>DOMString</code> variable on the implementation
106      * platform.
107      */

108     public String JavaDoc getData()
109                             throws DOMException JavaDoc {
110         return null;
111     }
112
113     /**
114      * The character data of the node that implements this interface. The DOM
115      * implementation may not put arbitrary limits on the amount of data
116      * that may be stored in a <code>CharacterData</code> node. However,
117      * implementation limits may mean that the entirety of a node's data may
118      * not fit into a single <code>DOMString</code>. In such cases, the user
119      * may call <code>substringData</code> to retrieve the data in
120      * appropriately sized pieces.
121      * @exception DOMException
122      * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
123      * @exception DOMException
124      * DOMSTRING_SIZE_ERR: Raised when it would return more characters than
125      * fit in a <code>DOMString</code> variable on the implementation
126      * platform.
127      */

128     public void setData(String JavaDoc data)
129                             throws DOMException JavaDoc {
130         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
131     }
132
133     /**
134      * The number of 16-bit units that are available through <code>data</code>
135      * and the <code>substringData</code> method below. This may have the
136      * value zero, i.e., <code>CharacterData</code> nodes may be empty.
137      */

138     public int getLength() {
139         return 0;
140     }
141
142     /**
143      * Extracts a range of data from the node.
144      * @param offset Start offset of substring to extract.
145      * @param count The number of 16-bit units to extract.
146      * @return The specified substring. If the sum of <code>offset</code> and
147      * <code>count</code> exceeds the <code>length</code>, then all 16-bit
148      * units to the end of the data are returned.
149      * @exception DOMException
150      * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
151      * negative or greater than the number of 16-bit units in
152      * <code>data</code>, or if the specified <code>count</code> is
153      * negative.
154      * <br>DOMSTRING_SIZE_ERR: Raised if the specified range of text does
155      * not fit into a <code>DOMString</code>.
156      */

157     public String JavaDoc substringData(int offset,
158                                 int count)
159                                 throws DOMException JavaDoc {
160         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
161     }
162
163     /**
164      * Append the string to the end of the character data of the node. Upon
165      * success, <code>data</code> provides access to the concatenation of
166      * <code>data</code> and the <code>DOMString</code> specified.
167      * @param arg The <code>DOMString</code> to append.
168      * @exception DOMException
169      * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
170      */

171     public void appendData(String JavaDoc arg)
172                            throws DOMException JavaDoc {
173         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
174     }
175
176     /**
177      * Insert a string at the specified 16-bit unit offset.
178      * @param offset The character offset at which to insert.
179      * @param arg The <code>DOMString</code> to insert.
180      * @exception DOMException
181      * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
182      * negative or greater than the number of 16-bit units in
183      * <code>data</code>.
184      * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
185      */

186     public void insertData(int offset,
187                            String JavaDoc arg)
188                            throws DOMException JavaDoc {
189         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
190     }
191
192     /**
193      * Remove a range of 16-bit units from the node. Upon success,
194      * <code>data</code> and <code>length</code> reflect the change.
195      * @param offset The offset from which to start removing.
196      * @param count The number of 16-bit units to delete. If the sum of
197      * <code>offset</code> and <code>count</code> exceeds
198      * <code>length</code> then all 16-bit units from <code>offset</code>
199      * to the end of the data are deleted.
200      * @exception DOMException
201      * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
202      * negative or greater than the number of 16-bit units in
203      * <code>data</code>, or if the specified <code>count</code> is
204      * negative.
205      * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
206      */

207     public void deleteData(int offset,
208                            int count)
209                            throws DOMException JavaDoc {
210         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
211     }
212
213     /**
214      * Replace the characters starting at the specified 16-bit unit offset
215      * with the specified string.
216      * @param offset The offset from which to start replacing.
217      * @param count The number of 16-bit units to replace. If the sum of
218      * <code>offset</code> and <code>count</code> exceeds
219      * <code>length</code>, then all 16-bit units to the end of the data
220      * are replaced; (i.e., the effect is the same as a <code>remove</code>
221      * method call with the same range, followed by an <code>append</code>
222      * method invocation).
223      * @param arg The <code>DOMString</code> with which the range must be
224      * replaced.
225      * @exception DOMException
226      * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
227      * negative or greater than the number of 16-bit units in
228      * <code>data</code>, or if the specified <code>count</code> is
229      * negative.
230      * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
231      */

232     public void replaceData(int offset,
233                             int count,
234                             String JavaDoc arg)
235                             throws DOMException JavaDoc {
236         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
237     }
238
239     // Text node methods
240
/**
241      * Breaks this node into two nodes at the specified <code>offset</code>,
242      * keeping both in the tree as siblings. After being split, this node
243      * will contain all the content up to the <code>offset</code> point. A
244      * new node of the same type, which contains all the content at and
245      * after the <code>offset</code> point, is returned. If the original
246      * node had a parent node, the new node is inserted as the next sibling
247      * of the original node. When the <code>offset</code> is equal to the
248      * length of this node, the new node has no data.
249      * @param offset The 16-bit unit offset at which to split, starting from
250      * <code>0</code>.
251      * @return The new node, of the same type as this node.
252      * @exception DOMException
253      * INDEX_SIZE_ERR: Raised if the specified offset is negative or greater
254      * than the number of 16-bit units in <code>data</code>.
255      * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
256      */

257     public Text JavaDoc splitText(int offset)
258                           throws DOMException JavaDoc {
259         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
260     }
261
262     public boolean isWhitespaceInElementContent() {
263         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
264     }
265     
266     /** DOM Level 3 CR */
267     public boolean isElementContentWhitespace(){
268         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
269     }
270
271     public String JavaDoc getWholeText() {
272         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
273     }
274
275     public Text JavaDoc replaceWholeText(String JavaDoc content)
276                                  throws DOMException JavaDoc {
277         throw new DOMException JavaDoc(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
278     }
279
280
281 }
282
Popular Tags