1 /*
   2  * reserved comment block
   3  * DO NOT REMOVE OR ALTER!
   4  */
   5 /*
   6  * Copyright 2001-2004 The Apache Software Foundation.
   7  *
   8  * Licensed under the Apache License, Version 2.0 (the "License");
   9  * you may not use this file except in compliance with the License.
  10  * You may obtain a copy of the License at
  11  *
  12  *      http://www.apache.org/licenses/LICENSE-2.0
  13  *
  14  * Unless required by applicable law or agreed to in writing, software
  15  * distributed under the License is distributed on an "AS IS" BASIS,
  16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17  * See the License for the specific language governing permissions and
  18  * limitations under the License.
  19  */
  20 
  21 package com.sun.org.apache.xerces.internal.impl.xs.opti;
  22 
  23 import org.w3c.dom.Text;
  24 import org.w3c.dom.DOMException;
  25 
  26 /*
  27  * @author Neil Graham, IBM
  28  */
  29 /**
  30  * The <code>Text</code> interface inherits from <code>CharacterData</code>
  31  * and represents the textual content (termed character data in XML) of an
  32  * <code>Element</code> or <code>Attr</code>. If there is no markup inside
  33  * an element's content, the text is contained in a single object
  34  * implementing the <code>Text</code> interface that is the only child of
  35  * the element. If there is markup, it is parsed into the information items
  36  * (elements, comments, etc.) and <code>Text</code> nodes that form the list
  37  * of children of the element.
  38  * <p>When a document is first made available via the DOM, there is only one
  39  * <code>Text</code> node for each block of text. Users may create adjacent
  40  * <code>Text</code> nodes that represent the contents of a given element
  41  * without any intervening markup, but should be aware that there is no way
  42  * to represent the separations between these nodes in XML or HTML, so they
  43  * will not (in general) persist between DOM editing sessions. The
  44  * <code>normalize()</code> method on <code>Node</code> merges any such
  45  * adjacent <code>Text</code> objects into a single node for each block of
  46  * text.
  47  * <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>.
  48  *
  49  * This is an empty implementation.
  50  *
  51  * @xerces.internal
  52  */
  53 public class DefaultText extends NodeImpl implements Text {
  54 
  55     // CharacterData methods
  56 
  57     /**
  58      * The character data of the node that implements this interface. The DOM
  59      * implementation may not put arbitrary limits on the amount of data
  60      * that may be stored in a <code>CharacterData</code> node. However,
  61      * implementation limits may mean that the entirety of a node's data may
  62      * not fit into a single <code>DOMString</code>. In such cases, the user
  63      * may call <code>substringData</code> to retrieve the data in
  64      * appropriately sized pieces.
  65      * @exception DOMException
  66      *   NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
  67      * @exception DOMException
  68      *   DOMSTRING_SIZE_ERR: Raised when it would return more characters than
  69      *   fit in a <code>DOMString</code> variable on the implementation
  70      *   platform.
  71      */
  72     public String getData()
  73                             throws DOMException {
  74         return null;
  75     }
  76 
  77     /**
  78      * The character data of the node that implements this interface. The DOM
  79      * implementation may not put arbitrary limits on the amount of data
  80      * that may be stored in a <code>CharacterData</code> node. However,
  81      * implementation limits may mean that the entirety of a node's data may
  82      * not fit into a single <code>DOMString</code>. In such cases, the user
  83      * may call <code>substringData</code> to retrieve the data in
  84      * appropriately sized pieces.
  85      * @exception DOMException
  86      *   NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
  87      * @exception DOMException
  88      *   DOMSTRING_SIZE_ERR: Raised when it would return more characters than
  89      *   fit in a <code>DOMString</code> variable on the implementation
  90      *   platform.
  91      */
  92     public void setData(String data)
  93                             throws DOMException {
  94         throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
  95     }
  96 
  97     /**
  98      * The number of 16-bit units that are available through <code>data</code>
  99      * and the <code>substringData</code> method below. This may have the
 100      * value zero, i.e., <code>CharacterData</code> nodes may be empty.
 101      */
 102     public int getLength() {
 103         return 0;
 104     }
 105 
 106     /**
 107      * Extracts a range of data from the node.
 108      * @param offset Start offset of substring to extract.
 109      * @param count The number of 16-bit units to extract.
 110      * @return The specified substring. If the sum of <code>offset</code> and
 111      *   <code>count</code> exceeds the <code>length</code>, then all 16-bit
 112      *   units to the end of the data are returned.
 113      * @exception DOMException
 114      *   INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
 115      *   negative or greater than the number of 16-bit units in
 116      *   <code>data</code>, or if the specified <code>count</code> is
 117      *   negative.
 118      *   <br>DOMSTRING_SIZE_ERR: Raised if the specified range of text does
 119      *   not fit into a <code>DOMString</code>.
 120      */
 121     public String substringData(int offset,
 122                                 int count)
 123                                 throws DOMException {
 124         throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
 125     }
 126 
 127     /**
 128      * Append the string to the end of the character data of the node. Upon
 129      * success, <code>data</code> provides access to the concatenation of
 130      * <code>data</code> and the <code>DOMString</code> specified.
 131      * @param arg The <code>DOMString</code> to append.
 132      * @exception DOMException
 133      *   NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
 134      */
 135     public void appendData(String arg)
 136                            throws DOMException {
 137         throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
 138     }
 139 
 140     /**
 141      * Insert a string at the specified 16-bit unit offset.
 142      * @param offset The character offset at which to insert.
 143      * @param arg The <code>DOMString</code> to insert.
 144      * @exception DOMException
 145      *   INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
 146      *   negative or greater than the number of 16-bit units in
 147      *   <code>data</code>.
 148      *   <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
 149      */
 150     public void insertData(int offset,
 151                            String arg)
 152                            throws DOMException {
 153         throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
 154     }
 155 
 156     /**
 157      * Remove a range of 16-bit units from the node. Upon success,
 158      * <code>data</code> and <code>length</code> reflect the change.
 159      * @param offset The offset from which to start removing.
 160      * @param count The number of 16-bit units to delete. If the sum of
 161      *   <code>offset</code> and <code>count</code> exceeds
 162      *   <code>length</code> then all 16-bit units from <code>offset</code>
 163      *   to the end of the data are deleted.
 164      * @exception DOMException
 165      *   INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
 166      *   negative or greater than the number of 16-bit units in
 167      *   <code>data</code>, or if the specified <code>count</code> is
 168      *   negative.
 169      *   <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
 170      */
 171     public void deleteData(int offset,
 172                            int count)
 173                            throws DOMException {
 174         throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
 175     }
 176 
 177     /**
 178      * Replace the characters starting at the specified 16-bit unit offset
 179      * with the specified string.
 180      * @param offset The offset from which to start replacing.
 181      * @param count The number of 16-bit units to replace. If the sum of
 182      *   <code>offset</code> and <code>count</code> exceeds
 183      *   <code>length</code>, then all 16-bit units to the end of the data
 184      *   are replaced; (i.e., the effect is the same as a <code>remove</code>
 185      *    method call with the same range, followed by an <code>append</code>
 186      *    method invocation).
 187      * @param arg The <code>DOMString</code> with which the range must be
 188      *   replaced.
 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 replaceData(int offset,
 197                             int count,
 198                             String arg)
 199                             throws DOMException {
 200         throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
 201     }
 202 
 203     // Text node methods
 204     /**
 205      * Breaks this node into two nodes at the specified <code>offset</code>,
 206      * keeping both in the tree as siblings. After being split, this node
 207      * will contain all the content up to the <code>offset</code> point. A
 208      * new node of the same type, which contains all the content at and
 209      * after the <code>offset</code> point, is returned. If the original
 210      * node had a parent node, the new node is inserted as the next sibling
 211      * of the original node. When the <code>offset</code> is equal to the
 212      * length of this node, the new node has no data.
 213      * @param offset The 16-bit unit offset at which to split, starting from
 214      *   <code>0</code>.
 215      * @return The new node, of the same type as this node.
 216      * @exception DOMException
 217      *   INDEX_SIZE_ERR: Raised if the specified offset is negative or greater
 218      *   than the number of 16-bit units in <code>data</code>.
 219      *   <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
 220      */
 221     public Text splitText(int offset)
 222                           throws DOMException {
 223         throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
 224     }
 225 
 226     /** DOM Level 3 CR */
 227     public boolean isElementContentWhitespace(){
 228         throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
 229     }
 230 
 231     public String getWholeText(){
 232         throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
 233     }
 234 
 235     public Text replaceWholeText(String content) throws DOMException {
 236         throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "Method not supported");
 237     }
 238 }