public class TextImpl extends CharacterDataImpl implements Text
Some of the fields may have package visibility, so other classes belonging to the DOM implementation can easily access them while maintaining the DOM tree structure.
bufferATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE| Constructor and Description |
|---|
TextImpl(DocumentImpl document,
String data) |
| Modifier and Type | Method and Description |
|---|---|
String |
getNodeName()
The name of this node, depending on its type; see the table above.
|
short |
getNodeType()
A code representing the type of the underlying object, as defined above.
|
String |
getWholeText()
Returns all text of
Text nodes logically-adjacent text
nodes to this node, concatenated in document order. |
boolean |
isElementContentWhitespace()
Returns whether this text node contains
element content whitespace, often abusively called "ignorable whitespace".
|
TextImpl |
minimize()
Tries to remove this node using itself and the previous node as context.
|
Text |
replaceWholeText(String content)
Replaces the text of the current node and all logically-adjacent text
nodes with the specified text.
|
Text |
splitText(int offset)
Breaks this node into two nodes at the specified
offset,
keeping both in the tree as siblings. |
appendData, appendDataTo, deleteData, getData, getLength, getNodeValue, insertData, replaceData, setData, substringDatagetNextSibling, getParentNode, getPreviousSiblingappendChild, cloneNode, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getOwnerDocument, getPrefix, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserDataclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitappendData, deleteData, getData, getLength, insertData, replaceData, setData, substringDataappendChild, cloneNode, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserDatapublic TextImpl(DocumentImpl document, String data)
public String getNodeName()
NodegetNodeName in interface NodegetNodeName in class NodeImplpublic short getNodeType()
NodegetNodeType in interface NodegetNodeType in class NodeImplpublic final Text splitText(int offset) throws DOMException
Textoffset,
keeping both in the tree as siblings. After being split, this node
will contain all the content up to the offset point. A
new node of the same type, which contains all the content at and
after the offset point, is returned. If the original
node had a parent node, the new node is inserted as the next sibling
of the original node. When the offset is equal to the
length of this node, the new node has no data.splitText in interface Textoffset - The 16-bit unit offset at which to split, starting from
0.DOMException - INDEX_SIZE_ERR: Raised if the specified offset is negative or greater
than the number of 16-bit units in data.
public final boolean isElementContentWhitespace()
TextDocument.normalizeDocument().isElementContentWhitespace in interface Textpublic final String getWholeText()
TextText nodes logically-adjacent text
nodes to this node, concatenated in document order.
wholeText on the
Text node that contains "bar" returns "barfoo", while on
the Text node that contains "foo" it returns "barfoo".getWholeText in interface Textpublic final Text replaceWholeText(String content) throws DOMException
Textnull, when the replacement text is
the empty string;
Text node of the same type (
Text or CDATASection) as the current node
inserted at the location of the replacement.
replaceWholeText on the Text node that
contains "bar" with "yo" in argument results in the following:
EntityReference, the EntityReference must
be removed instead of the read-only nodes. If any
EntityReference to be removed has descendants that are
not EntityReference, Text, or
CDATASection nodes, the replaceWholeText
method must fail before performing any modification of the document,
raising a DOMException with the code
NO_MODIFICATION_ALLOWED_ERR.
replaceWholeText on the Text node that
contains "bar" fails, because the EntityReference node
"ent" contains an Element node which cannot be removed.replaceWholeText in interface Textcontent - The content of the replacing Text node.Text node created with the specified content.DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if one of the Text
nodes being replaced is readonly.public final TextImpl minimize()
Although this method alters the structure of the DOM tree, it does not alter the document's semantics.