001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.xerces.impl.xs.opti;
019:
020: import org.w3c.dom.Text;
021: import org.w3c.dom.DOMException;
022:
023: /**
024: * The <code>Text</code> interface inherits from <code>CharacterData</code>
025: * and represents the textual content (termed character data in XML) of an
026: * <code>Element</code> or <code>Attr</code>. If there is no markup inside
027: * an element's content, the text is contained in a single object
028: * implementing the <code>Text</code> interface that is the only child of
029: * the element. If there is markup, it is parsed into the information items
030: * (elements, comments, etc.) and <code>Text</code> nodes that form the list
031: * of children of the element.
032: * <p>When a document is first made available via the DOM, there is only one
033: * <code>Text</code> node for each block of text. Users may create adjacent
034: * <code>Text</code> nodes that represent the contents of a given element
035: * without any intervening markup, but should be aware that there is no way
036: * to represent the separations between these nodes in XML or HTML, so they
037: * will not (in general) persist between DOM editing sessions. The
038: * <code>normalize()</code> method on <code>Node</code> merges any such
039: * adjacent <code>Text</code> objects into a single node for each block of
040: * text.
041: * <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>.
042: *
043: * This is an empty implementation.
044: *
045: * @xerces.internal
046: *
047: * @author Neil Graham, IBM
048: *
049: * @version $Id: DefaultText.java 446728 2006-09-15 20:43:46Z mrglavas $
050: */
051: public class DefaultText extends NodeImpl implements Text {
052:
053: // CharacterData methods
054:
055: /**
056: * The character data of the node that implements this interface. The DOM
057: * implementation may not put arbitrary limits on the amount of data
058: * that may be stored in a <code>CharacterData</code> node. However,
059: * implementation limits may mean that the entirety of a node's data may
060: * not fit into a single <code>DOMString</code>. In such cases, the user
061: * may call <code>substringData</code> to retrieve the data in
062: * appropriately sized pieces.
063: * @exception DOMException
064: * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
065: * @exception DOMException
066: * DOMSTRING_SIZE_ERR: Raised when it would return more characters than
067: * fit in a <code>DOMString</code> variable on the implementation
068: * platform.
069: */
070: public String getData() throws DOMException {
071: return null;
072: }
073:
074: /**
075: * The character data of the node that implements this interface. The DOM
076: * implementation may not put arbitrary limits on the amount of data
077: * that may be stored in a <code>CharacterData</code> node. However,
078: * implementation limits may mean that the entirety of a node's data may
079: * not fit into a single <code>DOMString</code>. In such cases, the user
080: * may call <code>substringData</code> to retrieve the data in
081: * appropriately sized pieces.
082: * @exception DOMException
083: * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
084: * @exception DOMException
085: * DOMSTRING_SIZE_ERR: Raised when it would return more characters than
086: * fit in a <code>DOMString</code> variable on the implementation
087: * platform.
088: */
089: public void setData(String data) throws DOMException {
090: throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
091: "Method not supported");
092: }
093:
094: /**
095: * The number of 16-bit units that are available through <code>data</code>
096: * and the <code>substringData</code> method below. This may have the
097: * value zero, i.e., <code>CharacterData</code> nodes may be empty.
098: */
099: 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 substringData(int offset, int count)
119: throws DOMException {
120: throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
121: "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 arg) throws DOMException {
133: throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
134: "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, String arg) throws DOMException {
148: throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
149: "Method not supported");
150: }
151:
152: /**
153: * Remove a range of 16-bit units from the node. Upon success,
154: * <code>data</code> and <code>length</code> reflect the change.
155: * @param offset The offset from which to start removing.
156: * @param count The number of 16-bit units to delete. If the sum of
157: * <code>offset</code> and <code>count</code> exceeds
158: * <code>length</code> then all 16-bit units from <code>offset</code>
159: * to the end of the data are deleted.
160: * @exception DOMException
161: * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
162: * negative or greater than the number of 16-bit units in
163: * <code>data</code>, or if the specified <code>count</code> is
164: * negative.
165: * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
166: */
167: public void deleteData(int offset, int count) throws DOMException {
168: throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
169: "Method not supported");
170: }
171:
172: /**
173: * Replace the characters starting at the specified 16-bit unit offset
174: * with the specified string.
175: * @param offset The offset from which to start replacing.
176: * @param count The number of 16-bit units to replace. If the sum of
177: * <code>offset</code> and <code>count</code> exceeds
178: * <code>length</code>, then all 16-bit units to the end of the data
179: * are replaced; (i.e., the effect is the same as a <code>remove</code>
180: * method call with the same range, followed by an <code>append</code>
181: * method invocation).
182: * @param arg The <code>DOMString</code> with which the range must be
183: * replaced.
184: * @exception DOMException
185: * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
186: * negative or greater than the number of 16-bit units in
187: * <code>data</code>, or if the specified <code>count</code> is
188: * negative.
189: * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
190: */
191: public void replaceData(int offset, int count, String arg)
192: throws DOMException {
193: throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
194: "Method not supported");
195: }
196:
197: // Text node methods
198: /**
199: * Breaks this node into two nodes at the specified <code>offset</code>,
200: * keeping both in the tree as siblings. After being split, this node
201: * will contain all the content up to the <code>offset</code> point. A
202: * new node of the same type, which contains all the content at and
203: * after the <code>offset</code> point, is returned. If the original
204: * node had a parent node, the new node is inserted as the next sibling
205: * of the original node. When the <code>offset</code> is equal to the
206: * length of this node, the new node has no data.
207: * @param offset The 16-bit unit offset at which to split, starting from
208: * <code>0</code>.
209: * @return The new node, of the same type as this node.
210: * @exception DOMException
211: * INDEX_SIZE_ERR: Raised if the specified offset is negative or greater
212: * than the number of 16-bit units in <code>data</code>.
213: * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
214: */
215: public Text splitText(int offset) throws DOMException {
216: throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
217: "Method not supported");
218: }
219:
220: /** DOM Level 3 CR */
221: public boolean isElementContentWhitespace() {
222: throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
223: "Method not supported");
224: }
225:
226: public String getWholeText() {
227: throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
228: "Method not supported");
229: }
230:
231: public Text replaceWholeText(String content) throws DOMException {
232: throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
233: "Method not supported");
234: }
235: }
|