001 /*
002 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
003 *
004 * This code is free software; you can redistribute it and/or modify it
005 * under the terms of the GNU General Public License version 2 only, as
006 * published by the Free Software Foundation. Sun designates this
007 * particular file as subject to the "Classpath" exception as provided
008 * by Sun in the LICENSE file that accompanied this code.
009 *
010 * This code is distributed in the hope that it will be useful, but WITHOUT
011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
013 * version 2 for more details (a copy is included in the LICENSE file that
014 * accompanied this code).
015 *
016 * You should have received a copy of the GNU General Public License version
017 * 2 along with this work; if not, write to the Free Software Foundation,
018 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
019 *
020 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
021 * CA 95054 USA or visit www.sun.com if you need additional information or
022 * have any questions.
023 */
024
025 /*
026 * This file is available under and governed by the GNU General Public
027 * License version 2 only, as published by the Free Software Foundation.
028 * However, the following notice accompanied the original version of this
029 * file and, per its terms, should not be removed:
030 *
031 * Copyright (c) 2004 World Wide Web Consortium,
032 *
033 * (Massachusetts Institute of Technology, European Research Consortium for
034 * Informatics and Mathematics, Keio University). All Rights Reserved. This
035 * work is distributed under the W3C(r) Software License [1] in the hope that
036 * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
037 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
038 *
039 * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
040 */
041
042 package org.w3c.dom;
043
044 /**
045 * The <code>CharacterData</code> interface extends Node with a set of
046 * attributes and methods for accessing character data in the DOM. For
047 * clarity this set is defined here rather than on each object that uses
048 * these attributes and methods. No DOM objects correspond directly to
049 * <code>CharacterData</code>, though <code>Text</code> and others do
050 * inherit the interface from it. All <code>offsets</code> in this interface
051 * start from <code>0</code>.
052 * <p>As explained in the <code>DOMString</code> interface, text strings in
053 * the DOM are represented in UTF-16, i.e. as a sequence of 16-bit units. In
054 * the following, the term 16-bit units is used whenever necessary to
055 * indicate that indexing on CharacterData is done in 16-bit units.
056 * <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>.
057 */
058 public interface CharacterData extends Node {
059 /**
060 * The character data of the node that implements this interface. The DOM
061 * implementation may not put arbitrary limits on the amount of data
062 * that may be stored in a <code>CharacterData</code> node. However,
063 * implementation limits may mean that the entirety of a node's data may
064 * not fit into a single <code>DOMString</code>. In such cases, the user
065 * may call <code>substringData</code> to retrieve the data in
066 * appropriately sized pieces.
067 * @exception DOMException
068 * DOMSTRING_SIZE_ERR: Raised when it would return more characters than
069 * fit in a <code>DOMString</code> variable on the implementation
070 * platform.
071 */
072 public String getData() throws DOMException;
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 */
085 public void setData(String data) throws DOMException;
086
087 /**
088 * The number of 16-bit units that are available through <code>data</code>
089 * and the <code>substringData</code> method below. This may have the
090 * value zero, i.e., <code>CharacterData</code> nodes may be empty.
091 */
092 public int getLength();
093
094 /**
095 * Extracts a range of data from the node.
096 * @param offset Start offset of substring to extract.
097 * @param count The number of 16-bit units to extract.
098 * @return The specified substring. If the sum of <code>offset</code> and
099 * <code>count</code> exceeds the <code>length</code>, then all 16-bit
100 * units to the end of the data are returned.
101 * @exception DOMException
102 * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
103 * negative or greater than the number of 16-bit units in
104 * <code>data</code>, or if the specified <code>count</code> is
105 * negative.
106 * <br>DOMSTRING_SIZE_ERR: Raised if the specified range of text does
107 * not fit into a <code>DOMString</code>.
108 */
109 public String substringData(int offset, int count)
110 throws DOMException;
111
112 /**
113 * Append the string to the end of the character data of the node. Upon
114 * success, <code>data</code> provides access to the concatenation of
115 * <code>data</code> and the <code>DOMString</code> specified.
116 * @param arg The <code>DOMString</code> to append.
117 * @exception DOMException
118 * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
119 */
120 public void appendData(String arg) throws DOMException;
121
122 /**
123 * Insert a string at the specified 16-bit unit offset.
124 * @param offset The character offset at which to insert.
125 * @param arg The <code>DOMString</code> to insert.
126 * @exception DOMException
127 * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
128 * negative or greater than the number of 16-bit units in
129 * <code>data</code>.
130 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
131 */
132 public void insertData(int offset, String arg) throws DOMException;
133
134 /**
135 * Remove a range of 16-bit units from the node. Upon success,
136 * <code>data</code> and <code>length</code> reflect the change.
137 * @param offset The offset from which to start removing.
138 * @param count The number of 16-bit units to delete. If the sum of
139 * <code>offset</code> and <code>count</code> exceeds
140 * <code>length</code> then all 16-bit units from <code>offset</code>
141 * to the end of the data are deleted.
142 * @exception DOMException
143 * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
144 * negative or greater than the number of 16-bit units in
145 * <code>data</code>, or if the specified <code>count</code> is
146 * negative.
147 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
148 */
149 public void deleteData(int offset, int count) throws DOMException;
150
151 /**
152 * Replace the characters starting at the specified 16-bit unit offset
153 * with the specified string.
154 * @param offset The offset from which to start replacing.
155 * @param count The number of 16-bit units to replace. If the sum of
156 * <code>offset</code> and <code>count</code> exceeds
157 * <code>length</code>, then all 16-bit units to the end of the data
158 * are replaced; (i.e., the effect is the same as a <code>remove</code>
159 * method call with the same range, followed by an <code>append</code>
160 * method invocation).
161 * @param arg The <code>DOMString</code> with which the range must be
162 * replaced.
163 * @exception DOMException
164 * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
165 * negative or greater than the number of 16-bit units in
166 * <code>data</code>, or if the specified <code>count</code> is
167 * negative.
168 * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
169 */
170 public void replaceData(int offset, int count, String arg)
171 throws DOMException;
172
173 }
|