| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Objectnu.xom.Node
nu.xom.Text
This class represents a run of text. CDATA sections are not treated differently than normal text.
Constructor Summary | |
Text(String data)
This constructor creates a new Text object. | |
Text(Text text)
Creates a copy of the specified Text object. |
Method Summary | |
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. |
Methods inherited from class nu.xom.Node |
detach, equals, getBaseURI, getDocument, getParent, hashCode |
Methods inherited from class Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
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
IllegalCharacterDataException
- if data contains any
characters which are illegal in well-formed XML 1.0 such as
null, vertical tab, or unmatched halves of surrogate pairs
public Text(Text text)
Creates a copy of the specified Text
object.
text
- the Text
object to copyMethod Detail |
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.
data
- the text to install in the object
IllegalCharacterDataException
- if data contains any
characters which are illegal in well-formed XML 1.0 such as
null, vertical tab, or unmatched halves of surrogate pairs
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 class Node
public final Node getChild(int position)
Throws IndexOutOfBoundsException
because
texts do not have children.
getChild
in class Node
position
- the index of the child node to return
IndexOutOfBoundsException
- because texts
do not have children
public final int getChildCount()
Returns 0 because texts do not have children.
getChildCount
in class Node
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 class Node
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 
.
toXML
in class Node
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.
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |