nu.xom
Class Text
This class represents a run of text.
CDATA sections are not treated differently than
normal text. Text
objects may be adjacent to other
Text
objects.
Text(String data) -
This constructor creates a new
Text object.
|
Text(Text text) -
Creates a copy of the specified
Text object.
|
Node | copy() -
Returns a deep copy of this
Text with no parent,
that can be added to this document or a different one.
|
Node | getChild(int position) -
Throws
IndexOutOfBoundsException because
texts do not have children.
|
int | getChildCount() -
Returns 0 because texts do not have children.
|
String | getValue() -
Returns the XPath 1.0 string-value of this
Text
node.
|
void | setValue(String data) -
Sets the content of the
Text object
to the specified data.
|
String | toString() -
Returns a
String
representation of this Text suitable for
debugging and diagnosis.
|
String | toXML() -
Returns a string containing the XML serialization of this text
node.
|
copy , detach , equals , getBaseURI , getChild , getChildCount , getDocument , getParent , getValue , hashCode , query , query , toXML |
Text
public Text(String data)
This constructor creates a new Text
object.
The data is checked for legality according to XML 1.0 rules.
Characters that can be serialized by escaping them
such as < and & are allowed. However, characters
such as the form feed, null, vertical tab,
unmatched halves of surrogate pairs,
and 0xFFFE and 0xFFFF are not allowed.
data
- the initial text of the object
Text
public Text(Text text)
Creates a copy of the specified Text
object.
text
- the Text
object to copy
copy
public Node copy()
Returns a deep copy of this Text
with no parent,
that can be added to this document or a different one.
- copy in interface Node
- a deep copy of this text node with no parent
getChild
public final Node getChild(int position)
Throws IndexOutOfBoundsException
because
texts do not have children.
- getChild in interface Node
position
- the index of the child node to return
- never returns because texts do not have children;
always throws an exception.
getChildCount
public final int getChildCount()
Returns 0 because texts do not have children.
- getChildCount in interface Node
getValue
public final String getValue()
Returns the XPath 1.0 string-value of this Text
node. The XPath string-value of a text node is the same as
the text of the node.
- getValue in interface Node
setValue
public void setValue(String data)
Sets the content of the Text
object
to the specified data. The data is checked for
legality according to XML 1.0 rules. Characters that
can be serialized such as < and & are allowed.
However, characters such as the form feed, null,
vertical tab, unmatched halves of surrogate pairs,
and 0xFFFE and 0xFFFF are not allowed. Passing null is the same
as passing the empty string.
data
- the text to install in the object
toString
public final String toString()
Returns a String
representation of this Text
suitable for
debugging and diagnosis. This is not
the XML representation of this Text
node.
- a non-XML string representation of this node
toXML
public final String toXML()
Returns a string containing the XML serialization of this text
node. Unlike getValue
, this method escapes
characters such as & and < using entity references such
as &
and <
.
It escapes the carriage return (\r) as 
.
If this text node is a CDATA section, then it may wrap the value
in CDATA section delimiters instead of escaping.
- toXML in interface Node
- the string form of this text node
Copyright 2002-2005 Elliotte Rusty Harold
elharo@metalab.unc.edu