|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnu.xom.Node
nu.xom.LeafNode
nu.xom.Comment
This class represents an XML comment such as
<-- This is a comment-->
.
It cannot have any child nodes.
It can be a child of an Element
or a Document
.
It has essentially no internal substructure.
Constructor Summary | |
Comment(Comment comment)
Creates a new comment that's a copy of its argument. |
|
Comment(java.lang.String data)
Creates a new Comment object from string data. |
Method Summary | |
protected void |
checkValue(java.lang.String data)
Subclasses can override this method to perform additional checks. |
Node |
copy()
Returns a deep copy of this Comment object
which contains the same text, but does not have any parent. |
java.lang.String |
getValue()
Returns the value of this comment as defined by XPath 1.0. |
void |
setValue(java.lang.String data)
Sets the content of this Comment object
to the specified string. |
java.lang.String |
toString()
Returns a string form of the comment suitable for debugging and diagnosis. |
java.lang.String |
toXML()
Returns a String containing the actual XML
form of the comment;
for example, <--This is a comment--> . |
Methods inherited from class nu.xom.LeafNode |
getChild, getChildCount, hasChildren |
Methods inherited from class nu.xom.Node |
checkDetach, detach, equals, getBaseURI, getDocument, getParent, hashCode |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Comment(java.lang.String data)
Creates a new Comment
object from string data.
The data is checked for legality according to XML 1.0 rules.
Characters like the form feed and null are not allowed.
Furthermore, the two hyphen string "--" is not allowed
and the last character of the comment may not be a hyphen.
data
- the initial text of the commentpublic Comment(Comment comment)
Creates a new comment that's a copy of its argument. The copy has the same data but no parent node.
comment
- the comment to copyMethod Detail |
public final void setValue(java.lang.String data)
Sets the content of this Comment
object
to the specified string.
This string is checked for legality according to XML 1.0 rules.
Characters that can be serialized such as < and &
are allowed. However, characters like the form feed and
unmatched halves of surrogate pairs are not allowed.
Furthermore, the string may not contain a double hyphen
(--
) and may not end with a hyphen.
data
- the text to install in the objectprotected void checkValue(java.lang.String data)
Subclasses can override this method to perform additional checks. However, this can only be used to add checks, not remove them. All text in comments must be potentially well-formed when serialized.
data
- the text to check
XMLException
- if the data does not satisfy
the local constraintspublic final java.lang.String getValue()
Returns the value of this comment as defined by XPath 1.0.
The XPath string-value of a comment node is the string
content of the node, not including the initial
<--
and closing -->
.
getValue
in class Node
Node.getValue()
public Node copy()
Returns a deep copy of this Comment
object
which contains the same text, but does not have any parent.
Thus, it can be inserted into a different document.
copy
in class Node
Comment
that is not part of a documentpublic final java.lang.String toXML()
Returns a String
containing the actual XML
form of the comment;
for example, <--This is a comment-->
.
toXML
in class Node
String
containing a well-formed
XML commentNode.toXML()
public final java.lang.String toString()
Returns a string form of the comment suitable for debugging and diagnosis. It deliberately does not return an actual XML comment.
toString
in class Node
Comment
as a String
Object.toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |