Package org.jdom2
Class Comment
java.lang.Object
org.jdom2.Content
org.jdom2.Comment
- All Implemented Interfaces:
Serializable
,Cloneable
,NamespaceAware
- Direct Known Subclasses:
LocatedComment
An XML comment. Methods allow the user to get and set the text of the
comment.
- Author:
- Brett McLaughlin, Jason Hunter
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jdom2.Content
Content.CType
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()
Return a deep clone of this instance.detach()
Detaches this child from its parent or does nothing if the child has no parent.getText()
This returns the textual data within theComment
.getValue()
Returns the XPath 1.0 string value of this element, which is the text of this comment.protected Comment
Sets the parent of this Content.This will set the value of theComment
.toString()
This returns aString
representation of theComment
, suitable for debugging.Methods inherited from class org.jdom2.Content
equals, getCType, getDocument, getNamespacesInherited, getNamespacesInScope, getNamespacesIntroduced, getParent, getParentElement, hashCode
-
Field Details
-
text
Text of theComment
-
-
Constructor Details
-
Comment
protected Comment()Default, no-args constructor for implementations to use if needed. -
Comment
This creates the comment with the supplied text.- Parameters:
text
-String
content of comment.
-
-
Method Details
-
getValue
Returns the XPath 1.0 string value of this element, which is the text of this comment. -
getText
This returns the textual data within theComment
.- Returns:
String
- text of comment.
-
setText
This will set the value of theComment
.- Parameters:
text
-String
text for comment.- Returns:
Comment
- this Comment modified.- Throws:
IllegalDataException
- if the given text is illegal for a Comment.
-
clone
Return a deep clone of this instance. Even if this instance has a parent, the returned clone will not.All JDOM core classes are Cloneable, and never throw CloneNotSupportedException. Additionally all Cloneable JDOM classes return the correct type of instance from this method and there is no need to cast the result (co-variant return value).
Subclasses of this should still call super.clone() in their clone method.
-
detach
Description copied from class:Content
Detaches this child from its parent or does nothing if the child has no parent.This method can be overridden by particular Content subclasses to return a specific type of Content (co-variant return type). All overriding subclasses must call
super.detach()
; -
setParent
Description copied from class:Content
Sets the parent of this Content. The caller is responsible for removing any pre-existing parentage.This method can be overridden by particular Content subclasses to return a specific type of Content (co-variant return type). All overriding subclasses must call
super.setParent(Parent)
; -
toString
This returns aString
representation of theComment
, suitable for debugging. If the XML representation of theComment
is desired,XMLOutputter.outputString(Comment)
should be used.
-