1/* 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * 4 * This code is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License version 2 only, as 6 * published by the Free Software Foundation. Oracle designates this 7 * particular file as subject to the "Classpath" exception as provided 8 * by Oracle in the LICENSE file that accompanied this code. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 */ 24 25/* 26 * This file is available under and governed by the GNU General Public 27 * License version 2 only, as published by the Free Software Foundation. 28 * However, the following notice accompanied the original version of this 29 * file and, per its terms, should not be removed: 30 * 31 * Copyright (c) 2004 World Wide Web Consortium, 32 * 33 * (Massachusetts Institute of Technology, European Research Consortium for 34 * Informatics and Mathematics, Keio University). All Rights Reserved. This 35 * work is distributed under the W3C(r) Software License [1] in the hope that 36 * it will be useful, but WITHOUT ANY WARRANTY; without even the implied 37 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 38 * 39 * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 40 */ 41 42package org.w3c.dom; 43 44/** 45 * The <code>CharacterData</code> interface extends Node with a set of 46 * attributes and methods for accessing character data in the DOM. For 47 * clarity this set is defined here rather than on each object that uses 48 * these attributes and methods. No DOM objects correspond directly to 49 * <code>CharacterData</code>, though <code>Text</code> and others do 50 * inherit the interface from it. All <code>offsets</code> in this interface 51 * start from <code>0</code>. 52 * <p>As explained in the <code>DOMString</code> interface, text strings in 53 * the DOM are represented in UTF-16, i.e. as a sequence of 16-bit units. In 54 * the following, the term 16-bit units is used whenever necessary to 55 * indicate that indexing on CharacterData is done in 16-bit units. 56 * <p>See also the <a href='http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407'>Document Object Model (DOM) Level 3 Core Specification</a>. 57 */ 58public interface CharacterData extends Node { 59 /** 60 * The character data of the node that implements this interface. The DOM 61 * implementation may not put arbitrary limits on the amount of data 62 * that may be stored in a <code>CharacterData</code> node. However, 63 * implementation limits may mean that the entirety of a node's data may 64 * not fit into a single <code>DOMString</code>. In such cases, the user 65 * may call <code>substringData</code> to retrieve the data in 66 * appropriately sized pieces. 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 /** 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 */ 85 public void setData(String data) 86 throws DOMException; 87 88 /** 89 * The number of 16-bit units that are available through <code>data</code> 90 * and the <code>substringData</code> method below. This may have the 91 * value zero, i.e., <code>CharacterData</code> nodes may be empty. 92 */ 93 public int getLength(); 94 95 /** 96 * Extracts a range of data from the node. 97 * @param offset Start offset of substring to extract. 98 * @param count The number of 16-bit units to extract. 99 * @return The specified substring. If the sum of <code>offset</code> and 100 * <code>count</code> exceeds the <code>length</code>, then all 16-bit 101 * units to the end of the data are returned. 102 * @exception DOMException 103 * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is 104 * negative or greater than the number of 16-bit units in 105 * <code>data</code>, or if the specified <code>count</code> is 106 * negative. 107 * <br>DOMSTRING_SIZE_ERR: Raised if the specified range of text does 108 * not fit into a <code>DOMString</code>. 109 */ 110 public String substringData(int offset, 111 int count) 112 throws DOMException; 113 114 /** 115 * Append the string to the end of the character data of the node. Upon 116 * success, <code>data</code> provides access to the concatenation of 117 * <code>data</code> and the <code>DOMString</code> specified. 118 * @param arg The <code>DOMString</code> to append. 119 * @exception DOMException 120 * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. 121 */ 122 public void appendData(String arg) 123 throws DOMException; 124 125 /** 126 * Insert a string at the specified 16-bit unit offset. 127 * @param offset The character offset at which to insert. 128 * @param arg The <code>DOMString</code> to insert. 129 * @exception DOMException 130 * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is 131 * negative or greater than the number of 16-bit units in 132 * <code>data</code>. 133 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. 134 */ 135 public void insertData(int offset, 136 String arg) 137 throws DOMException; 138 139 /** 140 * Remove a range of 16-bit units from the node. Upon success, 141 * <code>data</code> and <code>length</code> reflect the change. 142 * @param offset The offset from which to start removing. 143 * @param count The number of 16-bit units to delete. If the sum of 144 * <code>offset</code> and <code>count</code> exceeds 145 * <code>length</code> then all 16-bit units from <code>offset</code> 146 * to the end of the data are deleted. 147 * @exception DOMException 148 * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is 149 * negative or greater than the number of 16-bit units in 150 * <code>data</code>, or if the specified <code>count</code> is 151 * negative. 152 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. 153 */ 154 public void deleteData(int offset, 155 int count) 156 throws DOMException; 157 158 /** 159 * Replace the characters starting at the specified 16-bit unit offset 160 * with the specified string. 161 * @param offset The offset from which to start replacing. 162 * @param count The number of 16-bit units to replace. If the sum of 163 * <code>offset</code> and <code>count</code> exceeds 164 * <code>length</code>, then all 16-bit units to the end of the data 165 * are replaced; (i.e., the effect is the same as a <code>remove</code> 166 * method call with the same range, followed by an <code>append</code> 167 * method invocation). 168 * @param arg The <code>DOMString</code> with which the range must be 169 * replaced. 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>, or if the specified <code>count</code> is 174 * negative. 175 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. 176 */ 177 public void replaceData(int offset, 178 int count, 179 String arg) 180 throws DOMException; 181 182} 183