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.
Access | Constructor and Description |
---|---|
public |
Modifier and Type | Method and Description |
---|---|
public void | appendData(String
The arg)DOMString to append.Implements org. 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
count)offset and count exceeds
length then all 16-bit units from offset
to the end of the data are deleted.Implements org. Remove a range of 16-bit units from the node. |
public String | getData()
Implements org. The character data of the node that implements this interface. |
public int | getLength()
Implements org. The number of 16-bit units that are available through |
public String | getWholeText()
Implements org. Returns all text of |
public void | insertData(int
The character offset at which to insert. offset, String The arg)DOMString to insert.Implements org. 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
count, String 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).The arg)DOMString with which the range must be
replaced.Implements org. Replace the characters starting at the specified 16-bit unit offset with the specified string. |
public Text | replaceWholeText(String
The content of the replacing content)Text node.Implements org. Replaces the text of the current node and all logically-adjacent text nodes with the specified text. |
public void | setData(String data)
Implements org. The character data of the node that implements this interface. |
public Text | Returns: The new node, of the same type as this node.The 16-bit unit offset at which to split, starting from
offset)0 .Implements org. Breaks this node into two nodes at the specified |
public String | Returns: The specified substring. If the sum ofoffset and
count exceeds the length , then all 16-bit
units to the end of the data are returned.Start offset of substring to extract. offset, int The number of 16-bit units to extract. count)Implements org. Extracts a range of data from the node. |
DefaultText | back to summary |
---|---|
public DefaultText() |
appendData | back to summary |
---|---|
public void appendData(String arg) throws DOMException Implements org. Append the string to the end of the character data of the node. Upon
success,
|
deleteData | back to summary |
---|---|
public void deleteData(int offset, int count) throws DOMException Implements org. Remove a range of 16-bit units from the node. Upon success,
|
getData | back to summary |
---|---|
public String getData() throws DOMException Implements org. 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
|
getLength | back to summary |
---|---|
public int getLength() Implements org. The number of 16-bit units that are available through |
getWholeText | back to summary |
---|---|
public String getWholeText() Implements org. Doc from org. Returns all text of +-----+ | <p> | +-----+ /\ / \ /-----\ +-------+ | bar | | &ent; | \-----/ +-------+ | | /-----\ | foo | \-----/Figure: barTextNode.wholeText value is "barfoo" |
insertData | back to summary |
---|---|
public void insertData(int offset, String arg) throws DOMException Implements org. Insert a string at the specified 16-bit unit offset.
|
isElementContentWhitespace | back to summary |
---|---|
public boolean isElementContentWhitespace() Implements org. DOM Level 3 CR |
replaceData | back to summary |
---|---|
public void replaceData(int offset, int count, String arg) throws DOMException Implements org. Replace the characters starting at the specified 16-bit unit offset with the specified string.
|
replaceWholeText | back to summary |
---|---|
public Text replaceWholeText(String content) throws DOMException Implements org. Doc from org. 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:
For instance, in the above example calling
+-----+ | <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
For instance, in the example below calling
|
setData | back to summary |
---|---|
public void setData(String data) throws DOMException Implements org. 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
|
splitText | back to summary |
---|---|
public Text splitText(int offset) throws DOMException Implements org. Breaks this node into two nodes at the specified
|
substringData | back to summary |
---|---|
public String substringData(int offset, int count) throws DOMException Implements org. Extracts a range of data from the node.
|