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: public void setData(String data) throws DOMException;
048:
049: /**
050: * The number of 16-bit units that are available through <code>data</code>
051: * and the <code>substringData</code> method below. This may have the
052: * value zero, i.e., <code>CharacterData</code> nodes may be empty.
053: */
054: public int getLength();
055:
056: /**
057: * Extracts a range of data from the node.
058: * @param offsetStart offset of substring to extract.
059: * @param countThe number of 16-bit units to extract.
060: * @return The specified substring. If the sum of <code>offset</code> and
061: * <code>count</code> exceeds the <code>length</code>, then all 16-bit
062: * units to the end of the data are returned.
063: * @exception DOMException
064: * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
065: * negative or greater than the number of 16-bit units in
066: * <code>data</code>, or if the specified <code>count</code> is
067: * negative.
068: * <br>DOMSTRING_SIZE_ERR: Raised if the specified range of text does
069: * not fit into a <code>DOMString</code>.
070: */
071: public String substringData(int offset, int count)
072: throws DOMException;
073:
074: /**
075: * Append the string to the end of the character data of the node. Upon
076: * success, <code>data</code> provides access to the concatenation of
077: * <code>data</code> and the <code>DOMString</code> specified.
078: * @param argThe <code>DOMString</code> to append.
079: * @exception DOMException
080: * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
081: */
082: public void appendData(String arg) throws DOMException;
083:
084: /**
085: * Insert a string at the specified 16-bit unit offset.
086: * @param offsetThe character offset at which to insert.
087: * @param argThe <code>DOMString</code> to insert.
088: * @exception DOMException
089: * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
090: * negative or greater than the number of 16-bit units in
091: * <code>data</code>.
092: * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
093: */
094: public void insertData(int offset, String arg) throws DOMException;
095:
096: /**
097: * Remove a range of 16-bit units from the node. Upon success,
098: * <code>data</code> and <code>length</code> reflect the change.
099: * @param offsetThe offset from which to start removing.
100: * @param countThe number of 16-bit units to delete. If the sum of
101: * <code>offset</code> and <code>count</code> exceeds
102: * <code>length</code> then all 16-bit units from <code>offset</code>
103: * to the end of the data are deleted.
104: * @exception DOMException
105: * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
106: * negative or greater than the number of 16-bit units in
107: * <code>data</code>, or if the specified <code>count</code> is
108: * negative.
109: * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
110: */
111: public void deleteData(int offset, int count) throws DOMException;
112:
113: /**
114: * Replace the characters starting at the specified 16-bit unit offset
115: * with the specified string.
116: * @param offsetThe offset from which to start replacing.
117: * @param countThe number of 16-bit units to replace. If the sum of
118: * <code>offset</code> and <code>count</code> exceeds
119: * <code>length</code>, then all 16-bit units to the end of the data
120: * are replaced; (i.e., the effect is the same as a <code>remove</code>
121: * method call with the same range, followed by an <code>append</code>
122: * method invocation).
123: * @param argThe <code>DOMString</code> with which the range must be
124: * replaced.
125: * @exception DOMException
126: * INDEX_SIZE_ERR: Raised if the specified <code>offset</code> is
127: * negative or greater than the number of 16-bit units in
128: * <code>data</code>, or if the specified <code>count</code> is
129: * negative.
130: * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
131: */
132: public void replaceData(int offset, int count, String arg)
133: throws DOMException;
134:
135: }
|