001: /*
002: * Copyright (c) 2000 World Wide Web Consortium,
003: * (Massachusetts Institute of Technology, Institut National de
004: * Recherche en Informatique et en Automatique, Keio University). All
005: * Rights Reserved. This program is distributed under the W3C's Software
006: * Intellectual Property License. This program is distributed in the
007: * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
008: * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
009: * PURPOSE.
010: * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
011: */
012:
013: package org.w3c.dom;
014:
015: /**
016: * The <code>CharacterData</code> interface extends Node with a set of
017: * attributes and methods for accessing character data in the DOM. For
018: * clarity this set is defined here rather than on each object that uses
019: * these attributes and methods. No DOM objects correspond directly to
020: * <code>CharacterData</code>, though <code>Text</code> and others do
021: * inherit the interface from it. All <code>offsets</code> in this interface
022: * start from <code>0</code>.
023: * <p>As explained in the <code>DOMString</code> interface, text strings in
024: * the DOM are represented in UTF-16, i.e. as a sequence of 16-bit units. In
025: * the following, the term 16-bit units is used whenever necessary to
026: * indicate that indexing on CharacterData is done in 16-bit units.
027: * <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>.
028: */
029: public interface CharacterData extends Node {
030: /**
031: * The character data of the node that implements this interface. The DOM
032: * implementation may not put arbitrary limits on the amount of data
033: * that may be stored in a <code>CharacterData</code> node. However,
034: * implementation limits may mean that the entirety of a node's data may
035: * not fit into a single <code>DOMString</code>. In such cases, the user
036: * may call <code>substringData</code> to retrieve the data in
037: * appropriately sized pieces.
038: * @exception DOMException
039: * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
040: * @exception DOMException
041: * DOMSTRING_SIZE_ERR: Raised when it would return more characters than
042: * fit in a <code>DOMString</code> variable on the implementation
043: * platform.
044: */
045: public String getData() throws DOMException;
046:
047: /**
048: * The character data of the node that implements this interface. The DOM
049: * implementation may not put arbitrary limits on the amount of data
050: * that may be stored in a <code>CharacterData</code> node. However,
051: * implementation limits may mean that the entirety of a node's data may
052: * not fit into a single <code>DOMString</code>. In such cases, the user
053: * may call <code>substringData</code> to retrieve the data in
054: * appropriately sized pieces.
055: * @exception DOMException
056: * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
057: * @exception DOMException
058: * DOMSTRING_SIZE_ERR: Raised when it would return more characters than
059: * fit in a <code>DOMString</code> variable on the implementation
060: * platform.
061: */
062: public void setData(String data) throws DOMException;
063:
064: /**
065: * The number of 16-bit units that are available through <code>data</code>
066: * and the <code>substringData</code> method below. This may have the
067: * value zero, i.e., <code>CharacterData</code> nodes may be empty.
068: */
069: public int getLength();
070:
071: /**
072: * Extracts a range of data from the node.
073: * @param offset Start offset of substring to extract.
074: * @param count The number of 16-bit units to extract.
075: * @return The specified substring. If the sum of <code>offset</code> and
076: * <code>count</code> exceeds the <code>length</code>, then all 16-bit
077: * units to the end of the data are returned.
078: * @exception DOMException
079: * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
080: * negative or greater than the number of 16-bit units in
081: * <code>data</code>, or if the specified <code>count</code> is
082: * negative.
083: * <br>DOMSTRING_SIZE_ERR: Raised if the specified range of text does
084: * not fit into a <code>DOMString</code>.
085: */
086: public String substringData(int offset, int count)
087: throws DOMException;
088:
089: /**
090: * Append the string to the end of the character data of the node. Upon
091: * success, <code>data</code> provides access to the concatenation of
092: * <code>data</code> and the <code>DOMString</code> specified.
093: * @param arg The <code>DOMString</code> to append.
094: * @exception DOMException
095: * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
096: */
097: public void appendData(String arg) throws DOMException;
098:
099: /**
100: * Insert a string at the specified 16-bit unit offset.
101: * @param offset The character offset at which to insert.
102: * @param arg The <code>DOMString</code> to insert.
103: * @exception DOMException
104: * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
105: * negative or greater than the number of 16-bit units in
106: * <code>data</code>.
107: * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
108: */
109: public void insertData(int offset, String arg) throws DOMException;
110:
111: /**
112: * Remove a range of 16-bit units from the node. Upon success,
113: * <code>data</code> and <code>length</code> reflect the change.
114: * @param offset The offset from which to start removing.
115: * @param count The number of 16-bit units to delete. If the sum of
116: * <code>offset</code> and <code>count</code> exceeds
117: * <code>length</code> then all 16-bit units from <code>offset</code>
118: * to the end of the data are deleted.
119: * @exception DOMException
120: * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
121: * negative or greater than the number of 16-bit units in
122: * <code>data</code>, or if the specified <code>count</code> is
123: * negative.
124: * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
125: */
126: public void deleteData(int offset, int count) throws DOMException;
127:
128: /**
129: * Replace the characters starting at the specified 16-bit unit offset
130: * with the specified string.
131: * @param offset The offset from which to start replacing.
132: * @param count The number of 16-bit units to replace. If the sum of
133: * <code>offset</code> and <code>count</code> exceeds
134: * <code>length</code>, then all 16-bit units to the end of the data
135: * are replaced; (i.e., the effect is the same as a <code>remove</code>
136: * method call with the same range, followed by an <code>append</code>
137: * method invocation).
138: * @param arg The <code>DOMString</code> with which the range must be
139: * replaced.
140: * @exception DOMException
141: * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
142: * negative or greater than the number of 16-bit units in
143: * <code>data</code>, or if the specified <code>count</code> is
144: * negative.
145: * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
146: */
147: public void replaceData(int offset, int count, String arg)
148: throws DOMException;
149:
150: }
|