Top Description Fields Constructors Methods
com.sun.org.apache.xerces.internal.dom

public Class TextImpl

extends CharacterDataImpl
implements CharacterData, Text
Class Inheritance
All Implemented Interfaces
org.w3c.dom.Text, org.w3c.dom.CharacterData, org.w3c.dom.Node
Known Direct Subclasses
com.sun.org.apache.xerces.internal.dom.CDATASectionImpl, com.sun.org.apache.xerces.internal.dom.DeferredTextImpl
Imports
org.w3c.dom.CharacterData, .DOMException, .Node, .Text

Text nodes hold the non-markup, non-Entity content of an Element or Attribute.

When a document is first made available to the DOM, there is only one Text object for each block of adjacent plain-text. Users (ie, applications) may create multiple adjacent Texts during editing -- see org.w3c.dom.Element#normalize for discussion.

Note that CDATASection is a subclass of Text. This is conceptually valid, since they're really just two different ways of quoting characters when they're written out as part of an XML stream.

Since
PR-DOM-Level-1-19980818.

Field Summary

Modifier and TypeField and Description
pack-priv static final long
Inherited from com.sun.org.apache.xerces.internal.dom.CharacterDataImpl:
data

Constructor Summary

AccessConstructor and Description
public
TextImpl()

Default constructor

public
TextImpl(CoreDocumentImpl ownerDoc, String data)

Factory constructor.

Method Summary

Modifier and TypeMethod and Description
private boolean

Returns:

true - can replace text false - can't replace exception must be raised
canModifyNext
(Node node)

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.

private boolean

Returns:

true - can replace text false - can't replace exception must be raised
canModifyPrev
(Node node)

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.

public String
public short
getNodeType()

Implements abstract com.sun.org.apache.xerces.internal.dom.NodeImpl.getNodeType.

Implements org.w3c.dom.Node.getNodeType.

A short integer indicating what type of node this is.

public String
getWholeText()

Implements org.w3c.dom.Text.getWholeText.

DOM Level 3 WD - Experimental.

private boolean

Returns:

true - if execution was stopped because the type of node other than EntityRef, Text, CDATA is encountered, otherwise return false
getWholeTextBackward
(Node node, StringBuilder buffer, Node parent)

Concatenates the text of all logically-adjacent text nodes to the left of the node

private boolean

Returns:

true - if execution was stopped because the type of node other than EntityRef, Text, CDATA is encountered, otherwise return false
getWholeTextForward
(Node node, StringBuilder buffer, Node parent)

Concatenates the text of all logically-adjacent text nodes to the right of this node

private boolean

Returns:

true - Contains text only children
hasTextOnlyChildren
(Node node)

Check if an EntityReference node has Text Only child nodes

protected void
insertTextContent(StringBuilder buf)

internal method taking a StringBuilder in parameter and inserts the text content at the start of the buffer

public boolean
isElementContentWhitespace()

Implements org.w3c.dom.Text.isElementContentWhitespace.

DOM L3 Core CR - Experimental Returns whether this text node contains element content whitespace, often abusively called "ignorable whitespace".

public boolean
isIgnorableWhitespace()

NON-DOM: Returns whether this Text is ignorable whitespace.

public String
removeData()

NON-DOM (used by DOMParser: Sets data to empty string.

public void
replaceData(String value)

NON-DOM (used by DOMParser): Reset data for the node.

public Text

Returns:

text - The Text node created with the specified content.
replaceWholeText
(String
The content of the replacing Text node.
content
)

Implements org.w3c.dom.Text.replaceWholeText.

Replaces the text of the current node and all logically-adjacent text nodes with the specified text.

public void
setIgnorableWhitespace(boolean ignore)

NON-DOM: Set whether this Text is ignorable whitespace.

public void
setValues(CoreDocumentImpl ownerDoc, String data)

NON-DOM: resets node and sets specified values for the current node

public Text

Returns:

A reference to the new node (containing data after the offset point). The original node will contain data up to that point.
splitText
(int
The offset at which to split. If offset is at the end of the available data, the second node will be empty.
offset
)

Implements org.w3c.dom.Text.splitText.

Break a text node into two sibling nodes.

Inherited from com.sun.org.apache.xerces.internal.dom.CharacterDataImpl:
appendDatadeleteDatagetChildNodesgetDatagetLengthgetNodeValueinsertDatainternalDeleteDatainternalInsertDatareplaceDatasetDatasetNodeValuesetNodeValueInternalsetNodeValueInternalsubstringData

Field Detail

serialVersionUIDback to summary
pack-priv static final long serialVersionUID

Hides com.sun.org.apache.xerces.internal.dom.CharacterDataImpl.serialVersionUID.

Serialization version.

Constructor Detail

TextImplback to summary
public TextImpl()

Default constructor

TextImplback to summary
public TextImpl(CoreDocumentImpl ownerDoc, String data)

Factory constructor.

Method Detail

canModifyNextback to summary
private boolean canModifyNext(Node node)

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. Traverse previous siblings of the node to be replaced. If a previous sibling is an EntityReference node, get it's last child. If the first child was a Text or CDATASection node and its next siblings are neither a replaceable EntityReference or Text or CDATASection nodes, return false. IF the first child was neither Text nor CDATASection nor a replaceable EntityReference Node, then return true. If the first child was a Text or CDATASection node any its next sibling was not or was an EntityReference that did not contain only Text or CDATASection nodes, return false. Check this recursively for EntityReference nodes.

Returns:boolean

true - can replace text false - can't replace exception must be raised

canModifyPrevback to summary
private boolean canModifyPrev(Node node)

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. Traverse previous siblings of the node to be replaced. If a previous sibling is an EntityReference node, get it's last child. If the last child was a Text or CDATASection node and its previous siblings are neither a replaceable EntityReference or Text or CDATASection nodes, return false. IF the last child was neither Text nor CDATASection nor a replaceable EntityReference Node, then return true. If the last child was a Text or CDATASection node any its previous sibling was not or was an EntityReference that did not contain only Text or CDATASection nodes, return false. Check this recursively for EntityReference nodes.

Returns:boolean

true - can replace text false - can't replace exception must be raised

getNodeNameback to summary
public String getNodeName()

Implements abstract com.sun.org.apache.xerces.internal.dom.NodeImpl.getNodeName.

Implements org.w3c.dom.Node.getNodeName.

Returns the node name.

getNodeTypeback to summary
public short getNodeType()

Implements abstract com.sun.org.apache.xerces.internal.dom.NodeImpl.getNodeType.

Implements org.w3c.dom.Node.getNodeType.

A short integer indicating what type of node this is. The named constants for this value are defined in the org.w3c.dom.Node interface.

getWholeTextback to summary
public String getWholeText()

Implements org.w3c.dom.Text.getWholeText.

DOM Level 3 WD - Experimental. Returns all text of Text nodes logically-adjacent text nodes to this node, concatenated in document order.

Since
DOM Level 3
getWholeTextBackwardback to summary
private boolean getWholeTextBackward(Node node, StringBuilder buffer, Node parent)

Concatenates the text of all logically-adjacent text nodes to the left of the node

Returns:boolean

true - if execution was stopped because the type of node other than EntityRef, Text, CDATA is encountered, otherwise return false

getWholeTextForwardback to summary
private boolean getWholeTextForward(Node node, StringBuilder buffer, Node parent)

Concatenates the text of all logically-adjacent text nodes to the right of this node

Returns:boolean

true - if execution was stopped because the type of node other than EntityRef, Text, CDATA is encountered, otherwise return false

hasTextOnlyChildrenback to summary
private boolean hasTextOnlyChildren(Node node)

Check if an EntityReference node has Text Only child nodes

Returns:boolean

true - Contains text only children

insertTextContentback to summary
protected void insertTextContent(StringBuilder buf) throws DOMException

internal method taking a StringBuilder in parameter and inserts the text content at the start of the buffer

isElementContentWhitespaceback to summary
public boolean isElementContentWhitespace()

Implements org.w3c.dom.Text.isElementContentWhitespace.

DOM L3 Core CR - Experimental Returns whether this text node contains element content whitespace, often abusively called "ignorable whitespace". The text node is determined to contain whitespace in element content during the load of the document or if validation occurs while using Document.normalizeDocument().

Since
DOM Level 3
isIgnorableWhitespaceback to summary
public boolean isIgnorableWhitespace()

NON-DOM: Returns whether this Text is ignorable whitespace.

removeDataback to summary
public String removeData()

NON-DOM (used by DOMParser: Sets data to empty string. Returns the value the data was set to.

replaceDataback to summary
public void replaceData(String value)

NON-DOM (used by DOMParser): Reset data for the node.

replaceWholeTextback to summary
public Text replaceWholeText(String content) throws DOMException

Implements org.w3c.dom.Text.replaceWholeText.

Replaces the text of the current node and all logically-adjacent text nodes with the specified text. All logically-adjacent text nodes are removed including the current node unless it was the recipient of the replacement text.

Parameters
content:String

The content of the replacing Text node.

Returns:Text

text - The Text node created with the specified content.

Exceptions
DOMException:

Doc from org.w3c.dom.Text.replaceWholeText.

NO_MODIFICATION_ALLOWED_ERR: Raised if one of the Text nodes being replaced is readonly.

Since
DOM Level 3
setIgnorableWhitespaceback to summary
public void setIgnorableWhitespace(boolean ignore)

NON-DOM: Set whether this Text is ignorable whitespace.

setValuesback to summary
public void setValues(CoreDocumentImpl ownerDoc, String data)

NON-DOM: resets node and sets specified values for the current node

splitTextback to summary
public Text splitText(int offset) throws DOMException

Implements org.w3c.dom.Text.splitText.

Break a text node into two sibling nodes. (Note that if the current node has no parent, they won't wind up as "siblings" -- they'll both be orphans.)

Parameters
offset:int

The offset at which to split. If offset is at the end of the available data, the second node will be empty.

Returns:Text

A reference to the new node (containing data after the offset point). The original node will contain data up to that point.

Exceptions
DOMException:

Doc from org.w3c.dom.Text.splitText.

INDEX_SIZE_ERR: Raised if the specified offset is negative or greater than the number of 16-bit units in data.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.

INDEX_SIZE_ERR:
if offset is <0 or >length.
NO_MODIFICATION_ALLOWED_ERR:
if node is read-only.