|
| 1 | +package org.w3c.dom; |
| 2 | + |
| 3 | +/** |
| 4 | + * The <code>CharacterData</code> interface extends Node with a set of |
| 5 | + * attributes and methods for accessing character data in the DOM. For |
| 6 | + * clarity this set is defined here rather than on each object that uses |
| 7 | + * these attributes and methods. No DOM objects correspond directly to |
| 8 | + * <code>CharacterData</code>, though <code>Text</code> and others do inherit |
| 9 | + * the interface from it. All <code>offset</code>s in this interface start |
| 10 | + * from 0. |
| 11 | + */ |
| 12 | +public interface CharacterData extends Node { |
| 13 | + /** |
| 14 | + * The character data of the node that implements this interface. The DOM |
| 15 | + * implementation may not put arbitrary limits on the amount of data that |
| 16 | + * may be stored in a <code>CharacterData</code> node. However, |
| 17 | + * implementation limits may mean that the entirety of a node's data may |
| 18 | + * not fit into a single <code>DOMString</code>. In such cases, the user |
| 19 | + * may call <code>substringData</code> to retrieve the data in |
| 20 | + * appropriately sized pieces. |
| 21 | + * @exception DOMException |
| 22 | + * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. |
| 23 | + * @exception DOMException |
| 24 | + * DOMSTRING_SIZE_ERR: Raised when it would return more characters than |
| 25 | + * fit in a <code>DOMString</code> variable on the implementation |
| 26 | + * platform. |
| 27 | + */ |
| 28 | + public String getData() |
| 29 | + throws DOMException; |
| 30 | + public void setData(String data) |
| 31 | + throws DOMException; |
| 32 | + /** |
| 33 | + * The number of characters that are available through <code>data</code> and |
| 34 | + * the <code>substringData</code> method below. This may have the value |
| 35 | + * zero, i.e., <code>CharacterData</code> nodes may be empty. |
| 36 | + */ |
| 37 | + public int getLength(); |
| 38 | + /** |
| 39 | + * Extracts a range of data from the node. |
| 40 | + * @param offset Start offset of substring to extract. |
| 41 | + * @param count The number of characters to extract. |
| 42 | + * @return The specified substring. If the sum of <code>offset</code> and |
| 43 | + * <code>count</code> exceeds the <code>length</code>, then all |
| 44 | + * characters to the end of the data are returned. |
| 45 | + * @exception DOMException |
| 46 | + * INDEX_SIZE_ERR: Raised if the specified offset is negative or greater |
| 47 | + * than the number of characters in <code>data</code>, or if the |
| 48 | + * specified <code>count</code> is negative. |
| 49 | + * <br>DOMSTRING_SIZE_ERR: Raised if the specified range of text does not |
| 50 | + * fit into a <code>DOMString</code>. |
| 51 | + */ |
| 52 | + public String substringData(int offset, |
| 53 | + int count) |
| 54 | + throws DOMException; |
| 55 | + /** |
| 56 | + * Append the string to the end of the character data of the node. Upon |
| 57 | + * success, <code>data</code> provides access to the concatenation of |
| 58 | + * <code>data</code> and the <code>DOMString</code> specified. |
| 59 | + * @param arg The <code>DOMString</code> to append. |
| 60 | + * @exception DOMException |
| 61 | + * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. |
| 62 | + */ |
| 63 | + public void appendData(String arg) |
| 64 | + throws DOMException; |
| 65 | + /** |
| 66 | + * Insert a string at the specified character offset. |
| 67 | + * @param offset The character offset at which to insert. |
| 68 | + * @param arg The <code>DOMString</code> to insert. |
| 69 | + * @exception DOMException |
| 70 | + * INDEX_SIZE_ERR: Raised if the specified offset is negative or greater |
| 71 | + * than the number of characters in <code>data</code>. |
| 72 | + * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. |
| 73 | + */ |
| 74 | + public void insertData(int offset, |
| 75 | + String arg) |
| 76 | + throws DOMException; |
| 77 | + /** |
| 78 | + * Remove a range of characters from the node. Upon success, |
| 79 | + * <code>data</code> and <code>length</code> reflect the change. |
| 80 | + * @param offset The offset from which to remove characters. |
| 81 | + * @param count The number of characters to delete. If the sum of |
| 82 | + * <code>offset</code> and <code>count</code> exceeds <code>length</code> |
| 83 | + * then all characters from <code>offset</code> to the end of the data |
| 84 | + * are deleted. |
| 85 | + * @exception DOMException |
| 86 | + * INDEX_SIZE_ERR: Raised if the specified offset is negative or greater |
| 87 | + * than the number of characters in <code>data</code>, or if the |
| 88 | + * specified <code>count</code> is negative. |
| 89 | + * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. |
| 90 | + */ |
| 91 | + public void deleteData(int offset, |
| 92 | + int count) |
| 93 | + throws DOMException; |
| 94 | + /** |
| 95 | + * Replace the characters starting at the specified character offset with |
| 96 | + * the specified string. |
| 97 | + * @param offset The offset from which to start replacing. |
| 98 | + * @param count The number of characters to replace. If the sum of |
| 99 | + * <code>offset</code> and <code>count</code> exceeds <code>length</code> |
| 100 | + * , then all characters to the end of the data are replaced (i.e., the |
| 101 | + * effect is the same as a <code>remove</code> method call with the same |
| 102 | + * range, followed by an <code>append</code> method invocation). |
| 103 | + * @param arg The <code>DOMString</code> with which the range must be |
| 104 | + * replaced. |
| 105 | + * @exception DOMException |
| 106 | + * INDEX_SIZE_ERR: Raised if the specified offset is negative or greater |
| 107 | + * than the number of characters in <code>data</code>, or if the |
| 108 | + * specified <code>count</code> is negative. |
| 109 | + * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly. |
| 110 | + */ |
| 111 | + public void replaceData(int offset, |
| 112 | + int count, |
| 113 | + String arg) |
| 114 | + throws DOMException; |
| 115 | +} |
| 116 | + |
0 commit comments