1 |
768 |
jeremybenn |
/*
|
2 |
|
|
* Copyright (c) 2004 World Wide Web Consortium,
|
3 |
|
|
*
|
4 |
|
|
* (Massachusetts Institute of Technology, European Research Consortium for
|
5 |
|
|
* Informatics and Mathematics, Keio University). All Rights Reserved. This
|
6 |
|
|
* work is distributed under the W3C(r) Software License [1] in the hope that
|
7 |
|
|
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
8 |
|
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
9 |
|
|
*
|
10 |
|
|
* [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
|
11 |
|
|
*/
|
12 |
|
|
|
13 |
|
|
package org.w3c.dom;
|
14 |
|
|
|
15 |
|
|
/**
|
16 |
|
|
* The <code>Text</code> interface inherits from <code>CharacterData</code>
|
17 |
|
|
* and represents the textual content (termed <a href='http://www.w3.org/TR/2004/REC-xml-20040204#syntax'>character data</a> in XML) of an <code>Element</code> or <code>Attr</code>. If there is no
|
18 |
|
|
* markup inside an element's content, the text is contained in a single
|
19 |
|
|
* object implementing the <code>Text</code> interface that is the only
|
20 |
|
|
* child of the element. If there is markup, it is parsed into the
|
21 |
|
|
* information items (elements, comments, etc.) and <code>Text</code> nodes
|
22 |
|
|
* that form the list of children of the element.
|
23 |
|
|
* <p>When a document is first made available via the DOM, there is only one
|
24 |
|
|
* <code>Text</code> node for each block of text. Users may create adjacent
|
25 |
|
|
* <code>Text</code> nodes that represent the contents of a given element
|
26 |
|
|
* without any intervening markup, but should be aware that there is no way
|
27 |
|
|
* to represent the separations between these nodes in XML or HTML, so they
|
28 |
|
|
* will not (in general) persist between DOM editing sessions. The
|
29 |
|
|
* <code>Node.normalize()</code> method merges any such adjacent
|
30 |
|
|
* <code>Text</code> objects into a single node for each block of text.
|
31 |
|
|
* <p> No lexical check is done on the content of a <code>Text</code> node
|
32 |
|
|
* and, depending on its position in the document, some characters must be
|
33 |
|
|
* escaped during serialization using character references; e.g. the
|
34 |
|
|
* characters "<&" if the textual content is part of an element or of
|
35 |
|
|
* an attribute, the character sequence "]]>" when part of an element,
|
36 |
|
|
* the quotation mark character " or the apostrophe character ' when part of
|
37 |
|
|
* an attribute.
|
38 |
|
|
* <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>.
|
39 |
|
|
*/
|
40 |
|
|
public interface Text extends CharacterData {
|
41 |
|
|
/**
|
42 |
|
|
* Breaks this node into two nodes at the specified <code>offset</code>,
|
43 |
|
|
* keeping both in the tree as siblings. After being split, this node
|
44 |
|
|
* will contain all the content up to the <code>offset</code> point. A
|
45 |
|
|
* new node of the same type, which contains all the content at and
|
46 |
|
|
* after the <code>offset</code> point, is returned. If the original
|
47 |
|
|
* node had a parent node, the new node is inserted as the next sibling
|
48 |
|
|
* of the original node. When the <code>offset</code> is equal to the
|
49 |
|
|
* length of this node, the new node has no data.
|
50 |
|
|
* @param offset The 16-bit unit offset at which to split, starting from
|
51 |
|
|
* <code>0</code>.
|
52 |
|
|
* @return The new node, of the same type as this node.
|
53 |
|
|
* @exception DOMException
|
54 |
|
|
* INDEX_SIZE_ERR: Raised if the specified offset is negative or greater
|
55 |
|
|
* than the number of 16-bit units in <code>data</code>.
|
56 |
|
|
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
|
57 |
|
|
*/
|
58 |
|
|
public Text splitText(int offset)
|
59 |
|
|
throws DOMException;
|
60 |
|
|
|
61 |
|
|
/**
|
62 |
|
|
* Returns whether this text node contains <a href='http://www.w3.org/TR/2004/REC-xml-infoset-20040204#infoitem.character'>
|
63 |
|
|
* element content whitespace</a>, often abusively called "ignorable whitespace". The text node is
|
64 |
|
|
* determined to contain whitespace in element content during the load
|
65 |
|
|
* of the document or if validation occurs while using
|
66 |
|
|
* <code>Document.normalizeDocument()</code>.
|
67 |
|
|
* @since DOM Level 3
|
68 |
|
|
*/
|
69 |
|
|
public boolean isElementContentWhitespace();
|
70 |
|
|
|
71 |
|
|
/**
|
72 |
|
|
* Returns all text of <code>Text</code> nodes logically-adjacent text
|
73 |
|
|
* nodes to this node, concatenated in document order.
|
74 |
|
|
* <br>For instance, in the example below <code>wholeText</code> on the
|
75 |
|
|
* <code>Text</code> node that contains "bar" returns "barfoo", while on
|
76 |
|
|
* the <code>Text</code> node that contains "foo" it returns "barfoo".
|
77 |
|
|
* @since DOM Level 3
|
78 |
|
|
*/
|
79 |
|
|
public String getWholeText();
|
80 |
|
|
|
81 |
|
|
/**
|
82 |
|
|
* Replaces the text of the current node and all logically-adjacent text
|
83 |
|
|
* nodes with the specified text. All logically-adjacent text nodes are
|
84 |
|
|
* removed including the current node unless it was the recipient of the
|
85 |
|
|
* replacement text.
|
86 |
|
|
* <br>This method returns the node which received the replacement text.
|
87 |
|
|
* The returned node is:
|
88 |
|
|
* <ul>
|
89 |
|
|
* <li><code>null</code>, when the replacement text is
|
90 |
|
|
* the empty string;
|
91 |
|
|
* </li>
|
92 |
|
|
* <li>the current node, except when the current node is
|
93 |
|
|
* read-only;
|
94 |
|
|
* </li>
|
95 |
|
|
* <li> a new <code>Text</code> node of the same type (
|
96 |
|
|
* <code>Text</code> or <code>CDATASection</code>) as the current node
|
97 |
|
|
* inserted at the location of the replacement.
|
98 |
|
|
* </li>
|
99 |
|
|
* </ul>
|
100 |
|
|
* <br>For instance, in the above example calling
|
101 |
|
|
* <code>replaceWholeText</code> on the <code>Text</code> node that
|
102 |
|
|
* contains "bar" with "yo" in argument results in the following:
|
103 |
|
|
* <br>Where the nodes to be removed are read-only descendants of an
|
104 |
|
|
* <code>EntityReference</code>, the <code>EntityReference</code> must
|
105 |
|
|
* be removed instead of the read-only nodes. If any
|
106 |
|
|
* <code>EntityReference</code> to be removed has descendants that are
|
107 |
|
|
* not <code>EntityReference</code>, <code>Text</code>, or
|
108 |
|
|
* <code>CDATASection</code> nodes, the <code>replaceWholeText</code>
|
109 |
|
|
* method must fail before performing any modification of the document,
|
110 |
|
|
* raising a <code>DOMException</code> with the code
|
111 |
|
|
* <code>NO_MODIFICATION_ALLOWED_ERR</code>.
|
112 |
|
|
* <br>For instance, in the example below calling
|
113 |
|
|
* <code>replaceWholeText</code> on the <code>Text</code> node that
|
114 |
|
|
* contains "bar" fails, because the <code>EntityReference</code> node
|
115 |
|
|
* "ent" contains an <code>Element</code> node which cannot be removed.
|
116 |
|
|
* @param content The content of the replacing <code>Text</code> node.
|
117 |
|
|
* @return The <code>Text</code> node created with the specified content.
|
118 |
|
|
* @exception DOMException
|
119 |
|
|
* NO_MODIFICATION_ALLOWED_ERR: Raised if one of the <code>Text</code>
|
120 |
|
|
* nodes being replaced is readonly.
|
121 |
|
|
* @since DOM Level 3
|
122 |
|
|
*/
|
123 |
|
|
public Text replaceWholeText(String content)
|
124 |
|
|
throws DOMException;
|
125 |
|
|
|
126 |
|
|
}
|