286N/A/*
286N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
286N/A *
286N/A * This code is free software; you can redistribute it and/or modify it
286N/A * under the terms of the GNU General Public License version 2 only, as
286N/A * published by the Free Software Foundation. Oracle designates this
286N/A * particular file as subject to the "Classpath" exception as provided
286N/A * by Oracle in the LICENSE file that accompanied this code.
286N/A *
286N/A * This code is distributed in the hope that it will be useful, but WITHOUT
286N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
286N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
286N/A * version 2 for more details (a copy is included in the LICENSE file that
286N/A * accompanied this code).
286N/A *
286N/A * You should have received a copy of the GNU General Public License version
286N/A * 2 along with this work; if not, write to the Free Software Foundation,
286N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
286N/A *
286N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
286N/A * or visit www.oracle.com if you need additional information or have any
286N/A * questions.
286N/A */
286N/A
286N/A/*
286N/A * This file is available under and governed by the GNU General Public
286N/A * License version 2 only, as published by the Free Software Foundation.
286N/A * However, the following notice accompanied the original version of this
286N/A * file and, per its terms, should not be removed:
286N/A *
286N/A * Copyright (c) 2004 World Wide Web Consortium,
286N/A *
286N/A * (Massachusetts Institute of Technology, European Research Consortium for
286N/A * Informatics and Mathematics, Keio University). All Rights Reserved. This
286N/A * work is distributed under the W3C(r) Software License [1] in the hope that
286N/A * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
286N/A * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
286N/A *
286N/A * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
286N/A */
286N/A
286N/Apackage org.w3c.dom;
286N/A
286N/A/**
286N/A * The <code>Text</code> interface inherits from <code>CharacterData</code>
286N/A * 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
286N/A * markup inside an element's content, the text is contained in a single
286N/A * object implementing the <code>Text</code> interface that is the only
286N/A * child of the element. If there is markup, it is parsed into the
286N/A * information items (elements, comments, etc.) and <code>Text</code> nodes
286N/A * that form the list of children of the element.
286N/A * <p>When a document is first made available via the DOM, there is only one
286N/A * <code>Text</code> node for each block of text. Users may create adjacent
286N/A * <code>Text</code> nodes that represent the contents of a given element
286N/A * without any intervening markup, but should be aware that there is no way
286N/A * to represent the separations between these nodes in XML or HTML, so they
286N/A * will not (in general) persist between DOM editing sessions. The
286N/A * <code>Node.normalize()</code> method merges any such adjacent
286N/A * <code>Text</code> objects into a single node for each block of text.
286N/A * <p> No lexical check is done on the content of a <code>Text</code> node
286N/A * and, depending on its position in the document, some characters must be
286N/A * escaped during serialization using character references; e.g. the
286N/A * characters "&lt;&amp;" if the textual content is part of an element or of
286N/A * an attribute, the character sequence "]]&gt;" when part of an element,
286N/A * the quotation mark character " or the apostrophe character ' when part of
286N/A * an attribute.
286N/A * <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>.
286N/A */
286N/Apublic interface Text extends CharacterData {
286N/A /**
286N/A * Breaks this node into two nodes at the specified <code>offset</code>,
286N/A * keeping both in the tree as siblings. After being split, this node
286N/A * will contain all the content up to the <code>offset</code> point. A
286N/A * new node of the same type, which contains all the content at and
286N/A * after the <code>offset</code> point, is returned. If the original
286N/A * node had a parent node, the new node is inserted as the next sibling
286N/A * of the original node. When the <code>offset</code> is equal to the
286N/A * length of this node, the new node has no data.
286N/A * @param offset The 16-bit unit offset at which to split, starting from
286N/A * <code>0</code>.
286N/A * @return The new node, of the same type as this node.
286N/A * @exception DOMException
286N/A * INDEX_SIZE_ERR: Raised if the specified offset is negative or greater
286N/A * than the number of 16-bit units in <code>data</code>.
286N/A * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
286N/A */
286N/A public Text splitText(int offset)
286N/A throws DOMException;
286N/A
286N/A /**
286N/A * Returns whether this text node contains <a href='http://www.w3.org/TR/2004/REC-xml-infoset-20040204#infoitem.character'>
286N/A * element content whitespace</a>, often abusively called "ignorable whitespace". The text node is
286N/A * determined to contain whitespace in element content during the load
286N/A * of the document or if validation occurs while using
286N/A * <code>Document.normalizeDocument()</code>.
286N/A * @since DOM Level 3
286N/A */
286N/A public boolean isElementContentWhitespace();
286N/A
286N/A /**
286N/A * Returns all text of <code>Text</code> nodes logically-adjacent text
286N/A * nodes to this node, concatenated in document order.
286N/A * <br>For instance, in the example below <code>wholeText</code> on the
286N/A * <code>Text</code> node that contains "bar" returns "barfoo", while on
286N/A * the <code>Text</code> node that contains "foo" it returns "barfoo".
286N/A *
286N/A * <pre>
286N/A * +-----+
286N/A * | &lt;p&gt; |
286N/A * +-----+
286N/A * /\
286N/A * / \
286N/A * /-----\ +-------+
286N/A * | bar | | &amp;ent; |
286N/A * \-----/ +-------+
286N/A * |
286N/A * |
286N/A * /-----\
286N/A * | foo |
286N/A * \-----/
286N/A * </pre>
286N/A * <em>Figure: barTextNode.wholeText value is "barfoo"</em>
286N/A *
286N/A * @since DOM Level 3
286N/A */
286N/A public String getWholeText();
286N/A
286N/A /**
286N/A * Replaces the text of the current node and all logically-adjacent text
286N/A * nodes with the specified text. All logically-adjacent text nodes are
286N/A * removed including the current node unless it was the recipient of the
286N/A * replacement text.
286N/A * <p>This method returns the node which received the replacement text.
286N/A * The returned node is:</p>
286N/A * <ul>
286N/A * <li><code>null</code>, when the replacement text is
286N/A * the empty string;
286N/A * </li>
286N/A * <li>the current node, except when the current node is
286N/A * read-only;
286N/A * </li>
286N/A * <li> a new <code>Text</code> node of the same type (
286N/A * <code>Text</code> or <code>CDATASection</code>) as the current node
286N/A * inserted at the location of the replacement.
286N/A * </li>
286N/A * </ul>
286N/A * <p>For instance, in the above example calling
286N/A * <code>replaceWholeText</code> on the <code>Text</code> node that
286N/A * contains "bar" with "yo" in argument results in the following:</p>
286N/A *
286N/A * <pre>
286N/A * +-----+
286N/A * | &lt;p&gt; |
286N/A * +-----+
286N/A * |
286N/A * |
286N/A * /-----\
286N/A * | yo |
286N/A * \-----/
286N/A * </pre>
286N/A * <em>Figure: barTextNode.replaceWholeText("yo") modifies the
286N/A * textual content of barTextNode with "yo"</em>
286N/A *
286N/A * <p>Where the nodes to be removed are read-only descendants of an
286N/A * <code>EntityReference</code>, the <code>EntityReference</code> must
286N/A * be removed instead of the read-only nodes. If any
286N/A * <code>EntityReference</code> to be removed has descendants that are
286N/A * not <code>EntityReference</code>, <code>Text</code>, or
286N/A * <code>CDATASection</code> nodes, the <code>replaceWholeText</code>
286N/A * method must fail before performing any modification of the document,
286N/A * raising a <code>DOMException</code> with the code
286N/A * <code>NO_MODIFICATION_ALLOWED_ERR</code>.</p>
286N/A * <p>For instance, in the example below calling
286N/A * <code>replaceWholeText</code> on the <code>Text</code> node that
286N/A * contains "bar" fails, because the <code>EntityReference</code> node
286N/A * "ent" contains an <code>Element</code> node which cannot be removed.</p>
286N/A * @param content The content of the replacing <code>Text</code> node.
286N/A * @return The <code>Text</code> node created with the specified content.
286N/A * @exception DOMException
286N/A * NO_MODIFICATION_ALLOWED_ERR: Raised if one of the <code>Text</code>
286N/A * nodes being replaced is readonly.
286N/A * @since DOM Level 3
286N/A */
286N/A public Text replaceWholeText(String content)
286N/A throws DOMException;
286N/A
286N/A}