Path: blob/master/src/java.xml/share/classes/org/w3c/dom/CharacterData.java
40948 views
/*1* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.2*3* This code is free software; you can redistribute it and/or modify it4* under the terms of the GNU General Public License version 2 only, as5* published by the Free Software Foundation. Oracle designates this6* particular file as subject to the "Classpath" exception as provided7* by Oracle in the LICENSE file that accompanied this code.8*9* This code is distributed in the hope that it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License12* version 2 for more details (a copy is included in the LICENSE file that13* accompanied this code).14*15* You should have received a copy of the GNU General Public License version16* 2 along with this work; if not, write to the Free Software Foundation,17* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.18*19* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA20* or visit www.oracle.com if you need additional information or have any21* questions.22*/2324/*25* This file is available under and governed by the GNU General Public26* License version 2 only, as published by the Free Software Foundation.27* However, the following notice accompanied the original version of this28* file and, per its terms, should not be removed:29*30* Copyright (c) 2004 World Wide Web Consortium,31*32* (Massachusetts Institute of Technology, European Research Consortium for33* Informatics and Mathematics, Keio University). All Rights Reserved. This34* work is distributed under the W3C(r) Software License [1] in the hope that35* it will be useful, but WITHOUT ANY WARRANTY; without even the implied36* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.37*38* [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-2002123139*/4041package org.w3c.dom;4243/**44* The <code>CharacterData</code> interface extends Node with a set of45* attributes and methods for accessing character data in the DOM. For46* clarity this set is defined here rather than on each object that uses47* these attributes and methods. No DOM objects correspond directly to48* <code>CharacterData</code>, though <code>Text</code> and others do49* inherit the interface from it. All <code>offsets</code> in this interface50* start from <code>0</code>.51* <p>As explained in the <code>DOMString</code> interface, text strings in52* the DOM are represented in UTF-16, i.e. as a sequence of 16-bit units. In53* the following, the term 16-bit units is used whenever necessary to54* indicate that indexing on CharacterData is done in 16-bit units.55* <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>.56*/57public interface CharacterData extends Node {58/**59* The character data of the node that implements this interface. The DOM60* implementation may not put arbitrary limits on the amount of data61* that may be stored in a <code>CharacterData</code> node. However,62* implementation limits may mean that the entirety of a node's data may63* not fit into a single <code>DOMString</code>. In such cases, the user64* may call <code>substringData</code> to retrieve the data in65* appropriately sized pieces.66* @exception DOMException67* DOMSTRING_SIZE_ERR: Raised when it would return more characters than68* fit in a <code>DOMString</code> variable on the implementation69* platform.70*/71public String getData()72throws DOMException;73/**74* The character data of the node that implements this interface. The DOM75* implementation may not put arbitrary limits on the amount of data76* that may be stored in a <code>CharacterData</code> node. However,77* implementation limits may mean that the entirety of a node's data may78* not fit into a single <code>DOMString</code>. In such cases, the user79* may call <code>substringData</code> to retrieve the data in80* appropriately sized pieces.81* @exception DOMException82* NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.83*/84public void setData(String data)85throws DOMException;8687/**88* The number of 16-bit units that are available through <code>data</code>89* and the <code>substringData</code> method below. This may have the90* value zero, i.e., <code>CharacterData</code> nodes may be empty.91*/92public int getLength();9394/**95* Extracts a range of data from the node.96* @param offset Start offset of substring to extract.97* @param count The number of 16-bit units to extract.98* @return The specified substring. If the sum of <code>offset</code> and99* <code>count</code> exceeds the <code>length</code>, then all 16-bit100* units to the end of the data are returned.101* @exception DOMException102* INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is103* negative or greater than the number of 16-bit units in104* <code>data</code>, or if the specified <code>count</code> is105* negative.106* <br>DOMSTRING_SIZE_ERR: Raised if the specified range of text does107* not fit into a <code>DOMString</code>.108*/109public String substringData(int offset,110int count)111throws DOMException;112113/**114* Append the string to the end of the character data of the node. Upon115* success, <code>data</code> provides access to the concatenation of116* <code>data</code> and the <code>DOMString</code> specified.117* @param arg The <code>DOMString</code> to append.118* @exception DOMException119* NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.120*/121public void appendData(String arg)122throws DOMException;123124/**125* Insert a string at the specified 16-bit unit offset.126* @param offset The character offset at which to insert.127* @param arg The <code>DOMString</code> to insert.128* @exception DOMException129* INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is130* negative or greater than the number of 16-bit units in131* <code>data</code>.132* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.133*/134public void insertData(int offset,135String arg)136throws DOMException;137138/**139* Remove a range of 16-bit units from the node. Upon success,140* <code>data</code> and <code>length</code> reflect the change.141* @param offset The offset from which to start removing.142* @param count The number of 16-bit units to delete. If the sum of143* <code>offset</code> and <code>count</code> exceeds144* <code>length</code> then all 16-bit units from <code>offset</code>145* to the end of the data are deleted.146* @exception DOMException147* INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is148* negative or greater than the number of 16-bit units in149* <code>data</code>, or if the specified <code>count</code> is150* negative.151* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.152*/153public void deleteData(int offset,154int count)155throws DOMException;156157/**158* Replace the characters starting at the specified 16-bit unit offset159* with the specified string.160* @param offset The offset from which to start replacing.161* @param count The number of 16-bit units to replace. If the sum of162* <code>offset</code> and <code>count</code> exceeds163* <code>length</code>, then all 16-bit units to the end of the data164* are replaced; (i.e., the effect is the same as a <code>remove</code>165* method call with the same range, followed by an <code>append</code>166* method invocation).167* @param arg The <code>DOMString</code> with which the range must be168* replaced.169* @exception DOMException170* INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is171* negative or greater than the number of 16-bit units in172* <code>data</code>, or if the specified <code>count</code> is173* negative.174* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.175*/176public void replaceData(int offset,177int count,178String arg)179throws DOMException;180181}182183184