12005
|
1 |
/*
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
3 |
*
|
|
4 |
* This code is free software; you can redistribute it and/or modify it
|
|
5 |
* under the terms of the GNU General Public License version 2 only, as
|
|
6 |
* published by the Free Software Foundation. Oracle designates this
|
|
7 |
* particular file as subject to the "Classpath" exception as provided
|
|
8 |
* by Oracle in the LICENSE file that accompanied this code.
|
|
9 |
*
|
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
14 |
* accompanied this code).
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License version
|
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
19 |
*
|
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
21 |
* or visit www.oracle.com if you need additional information or have any
|
|
22 |
* questions.
|
|
23 |
*/
|
|
24 |
|
|
25 |
/*
|
|
26 |
* This file is available under and governed by the GNU General Public
|
|
27 |
* License version 2 only, as published by the Free Software Foundation.
|
|
28 |
* However, the following notice accompanied the original version of this
|
|
29 |
* file and, per its terms, should not be removed:
|
|
30 |
*
|
|
31 |
* Copyright (c) 2004 World Wide Web Consortium,
|
|
32 |
*
|
|
33 |
* (Massachusetts Institute of Technology, European Research Consortium for
|
|
34 |
* Informatics and Mathematics, Keio University). All Rights Reserved. This
|
|
35 |
* work is distributed under the W3C(r) Software License [1] in the hope that
|
|
36 |
* it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
37 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
38 |
*
|
|
39 |
* [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
|
|
40 |
*/
|
|
41 |
|
|
42 |
package org.w3c.dom;
|
|
43 |
|
|
44 |
/**
|
|
45 |
* The <code>Text</code> interface inherits from <code>CharacterData</code>
|
|
46 |
* 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
|
|
47 |
* markup inside an element's content, the text is contained in a single
|
|
48 |
* object implementing the <code>Text</code> interface that is the only
|
|
49 |
* child of the element. If there is markup, it is parsed into the
|
|
50 |
* information items (elements, comments, etc.) and <code>Text</code> nodes
|
|
51 |
* that form the list of children of the element.
|
|
52 |
* <p>When a document is first made available via the DOM, there is only one
|
|
53 |
* <code>Text</code> node for each block of text. Users may create adjacent
|
|
54 |
* <code>Text</code> nodes that represent the contents of a given element
|
|
55 |
* without any intervening markup, but should be aware that there is no way
|
|
56 |
* to represent the separations between these nodes in XML or HTML, so they
|
|
57 |
* will not (in general) persist between DOM editing sessions. The
|
|
58 |
* <code>Node.normalize()</code> method merges any such adjacent
|
|
59 |
* <code>Text</code> objects into a single node for each block of text.
|
|
60 |
* <p> No lexical check is done on the content of a <code>Text</code> node
|
|
61 |
* and, depending on its position in the document, some characters must be
|
|
62 |
* escaped during serialization using character references; e.g. the
|
|
63 |
* characters "<&" if the textual content is part of an element or of
|
|
64 |
* an attribute, the character sequence "]]>" when part of an element,
|
|
65 |
* the quotation mark character " or the apostrophe character ' when part of
|
|
66 |
* an attribute.
|
|
67 |
* <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>.
|
|
68 |
*/
|
|
69 |
public interface Text extends CharacterData {
|
|
70 |
/**
|
|
71 |
* Breaks this node into two nodes at the specified <code>offset</code>,
|
|
72 |
* keeping both in the tree as siblings. After being split, this node
|
|
73 |
* will contain all the content up to the <code>offset</code> point. A
|
|
74 |
* new node of the same type, which contains all the content at and
|
|
75 |
* after the <code>offset</code> point, is returned. If the original
|
|
76 |
* node had a parent node, the new node is inserted as the next sibling
|
|
77 |
* of the original node. When the <code>offset</code> is equal to the
|
|
78 |
* length of this node, the new node has no data.
|
|
79 |
* @param offset The 16-bit unit offset at which to split, starting from
|
|
80 |
* <code>0</code>.
|
|
81 |
* @return The new node, of the same type as this node.
|
|
82 |
* @exception DOMException
|
|
83 |
* INDEX_SIZE_ERR: Raised if the specified offset is negative or greater
|
|
84 |
* than the number of 16-bit units in <code>data</code>.
|
|
85 |
* <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
|
|
86 |
*/
|
|
87 |
public Text splitText(int offset)
|
|
88 |
throws DOMException;
|
|
89 |
|
|
90 |
/**
|
|
91 |
* Returns whether this text node contains <a href='http://www.w3.org/TR/2004/REC-xml-infoset-20040204#infoitem.character'>
|
|
92 |
* element content whitespace</a>, often abusively called "ignorable whitespace". The text node is
|
|
93 |
* determined to contain whitespace in element content during the load
|
|
94 |
* of the document or if validation occurs while using
|
|
95 |
* <code>Document.normalizeDocument()</code>.
|
25262
|
96 |
* @since 1.5, DOM Level 3
|
12005
|
97 |
*/
|
|
98 |
public boolean isElementContentWhitespace();
|
|
99 |
|
|
100 |
/**
|
|
101 |
* Returns all text of <code>Text</code> nodes logically-adjacent text
|
|
102 |
* nodes to this node, concatenated in document order.
|
|
103 |
* <br>For instance, in the example below <code>wholeText</code> on the
|
|
104 |
* <code>Text</code> node that contains "bar" returns "barfoo", while on
|
|
105 |
* the <code>Text</code> node that contains "foo" it returns "barfoo".
|
|
106 |
*
|
|
107 |
* <pre>
|
|
108 |
* +-----+
|
|
109 |
* | <p> |
|
|
110 |
* +-----+
|
|
111 |
* /\
|
|
112 |
* / \
|
|
113 |
* /-----\ +-------+
|
|
114 |
* | bar | | &ent; |
|
|
115 |
* \-----/ +-------+
|
|
116 |
* |
|
|
117 |
* |
|
|
118 |
* /-----\
|
|
119 |
* | foo |
|
|
120 |
* \-----/
|
|
121 |
* </pre>
|
|
122 |
* <em>Figure: barTextNode.wholeText value is "barfoo"</em>
|
|
123 |
*
|
25262
|
124 |
* @since 1.5, DOM Level 3
|
12005
|
125 |
*/
|
|
126 |
public String getWholeText();
|
|
127 |
|
|
128 |
/**
|
|
129 |
* Replaces the text of the current node and all logically-adjacent text
|
|
130 |
* nodes with the specified text. All logically-adjacent text nodes are
|
|
131 |
* removed including the current node unless it was the recipient of the
|
|
132 |
* replacement text.
|
|
133 |
* <p>This method returns the node which received the replacement text.
|
|
134 |
* The returned node is:</p>
|
|
135 |
* <ul>
|
|
136 |
* <li><code>null</code>, when the replacement text is
|
|
137 |
* the empty string;
|
|
138 |
* </li>
|
|
139 |
* <li>the current node, except when the current node is
|
|
140 |
* read-only;
|
|
141 |
* </li>
|
|
142 |
* <li> a new <code>Text</code> node of the same type (
|
|
143 |
* <code>Text</code> or <code>CDATASection</code>) as the current node
|
|
144 |
* inserted at the location of the replacement.
|
|
145 |
* </li>
|
|
146 |
* </ul>
|
|
147 |
* <p>For instance, in the above example calling
|
|
148 |
* <code>replaceWholeText</code> on the <code>Text</code> node that
|
|
149 |
* contains "bar" with "yo" in argument results in the following:</p>
|
|
150 |
*
|
|
151 |
* <pre>
|
|
152 |
* +-----+
|
|
153 |
* | <p> |
|
|
154 |
* +-----+
|
|
155 |
* |
|
|
156 |
* |
|
|
157 |
* /-----\
|
|
158 |
* | yo |
|
|
159 |
* \-----/
|
|
160 |
* </pre>
|
|
161 |
* <em>Figure: barTextNode.replaceWholeText("yo") modifies the
|
|
162 |
* textual content of barTextNode with "yo"</em>
|
|
163 |
*
|
|
164 |
* <p>Where the nodes to be removed are read-only descendants of an
|
|
165 |
* <code>EntityReference</code>, the <code>EntityReference</code> must
|
|
166 |
* be removed instead of the read-only nodes. If any
|
|
167 |
* <code>EntityReference</code> to be removed has descendants that are
|
|
168 |
* not <code>EntityReference</code>, <code>Text</code>, or
|
|
169 |
* <code>CDATASection</code> nodes, the <code>replaceWholeText</code>
|
|
170 |
* method must fail before performing any modification of the document,
|
|
171 |
* raising a <code>DOMException</code> with the code
|
|
172 |
* <code>NO_MODIFICATION_ALLOWED_ERR</code>.</p>
|
|
173 |
* <p>For instance, in the example below calling
|
|
174 |
* <code>replaceWholeText</code> on the <code>Text</code> node that
|
|
175 |
* contains "bar" fails, because the <code>EntityReference</code> node
|
|
176 |
* "ent" contains an <code>Element</code> node which cannot be removed.</p>
|
|
177 |
* @param content The content of the replacing <code>Text</code> node.
|
|
178 |
* @return The <code>Text</code> node created with the specified content.
|
|
179 |
* @exception DOMException
|
|
180 |
* NO_MODIFICATION_ALLOWED_ERR: Raised if one of the <code>Text</code>
|
|
181 |
* nodes being replaced is readonly.
|
25262
|
182 |
* @since 1.5, DOM Level 3
|
12005
|
183 |
*/
|
|
184 |
public Text replaceWholeText(String content)
|
|
185 |
throws DOMException;
|
|
186 |
|
|
187 |
}
|