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. package com.sun.org.apache.xerces.internal.impl.xs.opti;
  58. import org.w3c.dom.Text;
  59. import org.w3c.dom.DOMException;
  60. /*
  61. * @author Neil Graham, IBM
  62. * @version $Id: DefaultText.java,v 1.3 2003/11/18 00:22:58 kk122374 Exp $
  63. */
  64. /**
  65. * The <code>Text</code> interface inherits from <code>CharacterData</code>
  66. * and represents the textual content (termed character data in XML) of an
  67. * <code>Element</code> or <code>Attr</code>. If there is no markup inside
  68. * an element's content, the text is contained in a single object
  69. * implementing the <code>Text</code> interface that is the only child of
  70. * the element. If there is markup, it is parsed into the information items
  71. * (elements, comments, etc.) and <code>Text</code> nodes that form the list
  72. * of children of the element.
  73. * <p>When a document is first made available via the DOM, there is only one
  74. * <code>Text</code> node for each block of text. Users may create adjacent
  75. * <code>Text</code> nodes that represent the contents of a given element
  76. * without any intervening markup, but should be aware that there is no way
  77. * to represent the separations between these nodes in XML or HTML, so they
  78. * will not (in general) persist between DOM editing sessions. The
  79. * <code>normalize()</code> method on <code>Node</code> merges any such
  80. * adjacent <code>Text</code> objects into a single node for each block of
  81. * text.
  82. * <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>.
  83. *
  84. * This is an empty implementation.
  85. */
  86. public class DefaultText extends NodeImpl implements Text {
  87. // CharacterData methods
  88. /**
  89. * The character data of the node that implements this interface. The DOM
  90. * implementation may not put arbitrary limits on the amount of data
  91. * that may be stored in a <code>CharacterData</code> node. However,
  92. * implementation limits may mean that the entirety of a node's data may
  93. * not fit into a single <code>DOMString</code>. In such cases, the user
  94. * may call <code>substringData</code> to retrieve the data in
  95. * appropriately sized pieces.
  96. * @exception DOMException
  97. * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
  98. * @exception DOMException
  99. * DOMSTRING_SIZE_ERR: Raised when it would return more characters than
  100. * fit in a <code>DOMString</code> variable on the implementation
  101. * platform.
  102. */
  103. public String getData()
  104. throws DOMException {
  105. return null;
  106. }
  107. /**
  108. * The character data of the node that implements this interface. The DOM
  109. * implementation may not put arbitrary limits on the amount of data
  110. * that may be stored in a <code>CharacterData</code> node. However,
  111. * implementation limits may mean that the entirety of a node's data may
  112. * not fit into a single <code>DOMString</code>. In such cases, the user
  113. * may call <code>substringData</code> to retrieve the data in
  114. * appropriately sized pieces.
  115. * @exception DOMException
  116. * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
  117. * @exception DOMException
  118. * DOMSTRING_SIZE_ERR: Raised when it would return more characters than
  119. * fit in a <code>DOMString</code> variable on the implementation
  120. * platform.
  121. */
  122. public void setData(String data)
  123. throws DOMException {
  124. throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
  125. }
  126. /**
  127. * The number of 16-bit units that are available through <code>data</code>
  128. * and the <code>substringData</code> method below. This may have the
  129. * value zero, i.e., <code>CharacterData</code> nodes may be empty.
  130. */
  131. public int getLength() {
  132. return 0;
  133. }
  134. /**
  135. * Extracts a range of data from the node.
  136. * @param offset Start offset of substring to extract.
  137. * @param count The number of 16-bit units to extract.
  138. * @return The specified substring. If the sum of <code>offset</code> and
  139. * <code>count</code> exceeds the <code>length</code>, then all 16-bit
  140. * units to the end of the data are returned.
  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>, or if the specified <code>count</code> is
  145. * negative.
  146. * <br>DOMSTRING_SIZE_ERR: Raised if the specified range of text does
  147. * not fit into a <code>DOMString</code>.
  148. */
  149. public String substringData(int offset,
  150. int count)
  151. throws DOMException {
  152. throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
  153. }
  154. /**
  155. * Append the string to the end of the character data of the node. Upon
  156. * success, <code>data</code> provides access to the concatenation of
  157. * <code>data</code> and the <code>DOMString</code> specified.
  158. * @param arg The <code>DOMString</code> to append.
  159. * @exception DOMException
  160. * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
  161. */
  162. public void appendData(String arg)
  163. throws DOMException {
  164. throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
  165. }
  166. /**
  167. * Insert a string at the specified 16-bit unit offset.
  168. * @param offset The character offset at which to insert.
  169. * @param arg The <code>DOMString</code> to insert.
  170. * @exception DOMException
  171. * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
  172. * negative or greater than the number of 16-bit units in
  173. * <code>data</code>.
  174. * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
  175. */
  176. public void insertData(int offset,
  177. String arg)
  178. throws DOMException {
  179. throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
  180. }
  181. /**
  182. * Remove a range of 16-bit units from the node. Upon success,
  183. * <code>data</code> and <code>length</code> reflect the change.
  184. * @param offset The offset from which to start removing.
  185. * @param count The number of 16-bit units to delete. If the sum of
  186. * <code>offset</code> and <code>count</code> exceeds
  187. * <code>length</code> then all 16-bit units from <code>offset</code>
  188. * to the end of the data are deleted.
  189. * @exception DOMException
  190. * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
  191. * negative or greater than the number of 16-bit units in
  192. * <code>data</code>, or if the specified <code>count</code> is
  193. * negative.
  194. * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
  195. */
  196. public void deleteData(int offset,
  197. int count)
  198. throws DOMException {
  199. throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
  200. }
  201. /**
  202. * Replace the characters starting at the specified 16-bit unit offset
  203. * with the specified string.
  204. * @param offset The offset from which to start replacing.
  205. * @param count The number of 16-bit units to replace. If the sum of
  206. * <code>offset</code> and <code>count</code> exceeds
  207. * <code>length</code>, then all 16-bit units to the end of the data
  208. * are replaced; (i.e., the effect is the same as a <code>remove</code>
  209. * method call with the same range, followed by an <code>append</code>
  210. * method invocation).
  211. * @param arg The <code>DOMString</code> with which the range must be
  212. * replaced.
  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>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
  219. */
  220. public void replaceData(int offset,
  221. int count,
  222. String arg)
  223. throws DOMException {
  224. throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
  225. }
  226. // Text node methods
  227. /**
  228. * Breaks this node into two nodes at the specified <code>offset</code>,
  229. * keeping both in the tree as siblings. After being split, this node
  230. * will contain all the content up to the <code>offset</code> point. A
  231. * new node of the same type, which contains all the content at and
  232. * after the <code>offset</code> point, is returned. If the original
  233. * node had a parent node, the new node is inserted as the next sibling
  234. * of the original node. When the <code>offset</code> is equal to the
  235. * length of this node, the new node has no data.
  236. * @param offset The 16-bit unit offset at which to split, starting from
  237. * <code>0</code>.
  238. * @return The new node, of the same type as this node.
  239. * @exception DOMException
  240. * INDEX_SIZE_ERR: Raised if the specified offset is negative or greater
  241. * than the number of 16-bit units in <code>data</code>.
  242. * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
  243. */
  244. public Text splitText(int offset)
  245. throws DOMException {
  246. throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
  247. }
  248. public boolean isWhitespaceInElementContent() {
  249. throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
  250. }
  251. /** DOM Level 3 CR */
  252. public boolean isElementContentWhitespace(){
  253. throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
  254. }
  255. public String getWholeText() {
  256. throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
  257. }
  258. public Text replaceWholeText(String content)
  259. throws DOMException {
  260. throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
  261. }
  262. }