Top Description Fields Constructors Methods
com.sun.org.apache.xerces.internal.impl.xs.opti

public Class DefaultText

extends NodeImpl
implements 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.impl.xs.opti.TextImpl
Imports
org.w3c.dom.Text, .DOMException

The Text interface inherits from CharacterData and represents the textual content (termed character data in XML) of an Element or Attr. If there is no markup inside an element's content, the text is contained in a single object implementing the Text interface that is the only child of the element. If there is markup, it is parsed into the information items (elements, comments, etc.) and Text nodes that form the list of children of the element.

When a document is first made available via the DOM, there is only one Text node for each block of text. Users may create adjacent Text nodes that represent the contents of a given element without any intervening markup, but should be aware that there is no way to represent the separations between these nodes in XML or HTML, so they will not (in general) persist between DOM editing sessions. The normalize() method on Node merges any such adjacent Text objects into a single node for each block of text.

See also the Document Object Model (DOM) Level 2 Core Specification. This is an empty implementation.

Field Summary

Inherited from com.sun.org.apache.xerces.internal.impl.xs.opti.NodeImpl:
hiddenlocalpartnodeTypeprefixrawnameuri

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
appendData(String
The DOMString to append.
arg
)

Implements org.w3c.dom.CharacterData.appendData.

Append the string to the end of the character data of the node.

public void
deleteData(int
The offset from which to start removing.
offset
,
int
The number of 16-bit units to delete. If the sum of offset and count exceeds length then all 16-bit units from offset to the end of the data are deleted.
count
)

Implements org.w3c.dom.CharacterData.deleteData.

Remove a range of 16-bit units from the node.

public String
getData()

Implements org.w3c.dom.CharacterData.getData.

The character data of the node that implements this interface.

public int
getLength()

Implements org.w3c.dom.CharacterData.getLength.

The number of 16-bit units that are available through data and the substringData method below.

public String
getWholeText()

Implements org.w3c.dom.Text.getWholeText.

Returns all text of Text nodes logically-adjacent text nodes to this node, concatenated in document order.

public void
insertData(int
The character offset at which to insert.
offset
,
String
The DOMString to insert.
arg
)

Implements org.w3c.dom.CharacterData.insertData.

Insert a string at the specified 16-bit unit offset.

public boolean
public void
replaceData(int
The offset from which to start replacing.
offset
,
int
The number of 16-bit units to replace. If the sum of offset and count exceeds length, then all 16-bit units to the end of the data are replaced; (i.e., the effect is the same as a remove method call with the same range, followed by an append method invocation).
count
,
String
The DOMString with which the range must be replaced.
arg
)

Implements org.w3c.dom.CharacterData.replaceData.

Replace the characters starting at the specified 16-bit unit offset with the specified string.

public Text
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
setData(String data)

Implements org.w3c.dom.CharacterData.setData.

The character data of the node that implements this interface.

public Text

Returns:

The new node, of the same type as this node.
splitText
(int
The 16-bit unit offset at which to split, starting from 0.
offset
)

Implements org.w3c.dom.Text.splitText.

Breaks this node into two nodes at the specified offset, keeping both in the tree as siblings.

public String

Returns:

The specified substring. If the sum of offset and count exceeds the length, then all 16-bit units to the end of the data are returned.
substringData
(int
Start offset of substring to extract.
offset
,
int
The number of 16-bit units to extract.
count
)

Implements org.w3c.dom.CharacterData.substringData.

Extracts a range of data from the node.

Inherited from com.sun.org.apache.xerces.internal.impl.xs.opti.NodeImpl:
getLocalNamegetNamespaceURIgetNodeNamegetNodeTypegetPrefixgetReadOnlysetReadOnly

Constructor Detail

DefaultTextback to summary
public DefaultText()

Method Detail

appendDataback to summary
public void appendData(String arg) throws DOMException

Implements org.w3c.dom.CharacterData.appendData.

Append the string to the end of the character data of the node. Upon success, data provides access to the concatenation of data and the DOMString specified.

Parameters
arg:String

The DOMString to append.

Exceptions
DOMException:
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
deleteDataback to summary
public void deleteData(int offset, int count) throws DOMException

Implements org.w3c.dom.CharacterData.deleteData.

Remove a range of 16-bit units from the node. Upon success, data and length reflect the change.

Parameters
offset:int

The offset from which to start removing.

count:int

The number of 16-bit units to delete. If the sum of offset and count exceeds length then all 16-bit units from offset to the end of the data are deleted.

Exceptions
DOMException:
INDEX_SIZE_ERR: Raised if the specified offset is negative or greater than the number of 16-bit units in data, or if the specified count is negative.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
getDataback to summary
public String getData() throws DOMException

Implements org.w3c.dom.CharacterData.getData.

The character data of the node that implements this interface. The DOM implementation may not put arbitrary limits on the amount of data that may be stored in a CharacterData node. However, implementation limits may mean that the entirety of a node's data may not fit into a single DOMString. In such cases, the user may call substringData to retrieve the data in appropriately sized pieces.

Exceptions
DOMException:
  • NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
  • DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in a DOMString variable on the implementation platform.
getLengthback to summary
public int getLength()

Implements org.w3c.dom.CharacterData.getLength.

The number of 16-bit units that are available through data and the substringData method below. This may have the value zero, i.e., CharacterData nodes may be empty.

getWholeTextback to summary
public String getWholeText()

Implements org.w3c.dom.Text.getWholeText.

Doc from org.w3c.dom.Text.getWholeText.

Returns all text of Text nodes logically-adjacent text nodes to this node, concatenated in document order.
For instance, in the example below wholeText on the Text node that contains "bar" returns "barfoo", while on the Text node that contains "foo" it returns "barfoo".

                    +-----+
                    | <p> |
                    +-----+
                      /\
                     /  \
              /-----\    +-------+
              | bar |    | &ent; |
              \-----/    +-------+
                             |
                             |
                          /-----\
                          | foo |
                          \-----/
Figure: barTextNode.wholeText value is "barfoo"
insertDataback to summary
public void insertData(int offset, String arg) throws DOMException

Implements org.w3c.dom.CharacterData.insertData.

Insert a string at the specified 16-bit unit offset.

Parameters
offset:int

The character offset at which to insert.

arg:String

The DOMString to insert.

Exceptions
DOMException:
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.
isElementContentWhitespaceback to summary
public boolean isElementContentWhitespace()

Implements org.w3c.dom.Text.isElementContentWhitespace.

DOM Level 3 CR

replaceDataback to summary
public void replaceData(int offset, int count, String arg) throws DOMException

Implements org.w3c.dom.CharacterData.replaceData.

Replace the characters starting at the specified 16-bit unit offset with the specified string.

Parameters
offset:int

The offset from which to start replacing.

count:int

The number of 16-bit units to replace. If the sum of offset and count exceeds length, then all 16-bit units to the end of the data are replaced; (i.e., the effect is the same as a remove method call with the same range, followed by an append method invocation).

arg:String

The DOMString with which the range must be replaced.

Exceptions
DOMException:
INDEX_SIZE_ERR: Raised if the specified offset is negative or greater than the number of 16-bit units in data, or if the specified count is negative.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
replaceWholeTextback to summary
public Text replaceWholeText(String content) throws DOMException

Implements org.w3c.dom.Text.replaceWholeText.

Doc from 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.

This method returns the node which received the replacement text. The returned node is:

  • null, when the replacement text is the empty string;
  • the current node, except when the current node is read-only;
  • a new Text node of the same type ( Text or CDATASection) as the current node inserted at the location of the replacement.

For instance, in the above example calling replaceWholeText on the Text node that contains "bar" with "yo" in argument results in the following:

                    +-----+
                    | <p> |
                    +-----+
                       |
                       |
                    /-----\
                    | yo  |
                    \-----/
Figure: barTextNode.replaceWholeText("yo") modifies the textual content of barTextNode with "yo"

Where the nodes to be removed are read-only descendants of an 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.

For instance, in the example below calling replaceWholeText on the Text node that contains "bar" fails, because the EntityReference node "ent" contains an Element node which cannot be removed.

Parameters
content:String

The content of the replacing Text node.

Returns:Text

The Text node created with the specified content.

Exceptions
DOMException:
NO_MODIFICATION_ALLOWED_ERR: Raised if one of the Text nodes being replaced is readonly.
setDataback to summary
public void setData(String data) throws DOMException

Implements org.w3c.dom.CharacterData.setData.

The character data of the node that implements this interface. The DOM implementation may not put arbitrary limits on the amount of data that may be stored in a CharacterData node. However, implementation limits may mean that the entirety of a node's data may not fit into a single DOMString. In such cases, the user may call substringData to retrieve the data in appropriately sized pieces.

Exceptions
DOMException:
  • NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
  • DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in a DOMString variable on the implementation platform.
splitTextback to summary
public Text splitText(int offset) throws DOMException

Implements org.w3c.dom.Text.splitText.

Breaks this node into two nodes at the specified offset, 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.

Parameters
offset:int

The 16-bit unit offset at which to split, starting from 0.

Returns:Text

The new node, of the same type as this node.

Exceptions
DOMException:
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.
substringDataback to summary
public String substringData(int offset, int count) throws DOMException

Implements org.w3c.dom.CharacterData.substringData.

Extracts a range of data from the node.

Parameters
offset:int

Start offset of substring to extract.

count:int

The number of 16-bit units to extract.

Returns:String

The specified substring. If the sum of offset and count exceeds the length, then all 16-bit units to the end of the data are returned.

Exceptions
DOMException:
INDEX_SIZE_ERR: Raised if the specified offset is negative or greater than the number of 16-bit units in data, or if the specified count is negative.
DOMSTRING_SIZE_ERR: Raised if the specified range of text does not fit into a DOMString.