Package org.jdom2
Class Comment
- java.lang.Object
-
- org.jdom2.Content
-
- org.jdom2.Comment
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,NamespaceAware
- Direct Known Subclasses:
LocatedComment
public class Comment extends Content
An XML comment. Methods allow the user to get and set the text of the comment.- Author:
- Brett McLaughlin, Jason Hunter
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.jdom2.Content
Content.CType
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Comment
clone()
Return a deep clone of this instance.Comment
detach()
Detaches this child from its parent or does nothing if the child has no parent.java.lang.String
getText()
This returns the textual data within theComment
.java.lang.String
getValue()
Returns the XPath 1.0 string value of this element, which is the text of this comment.protected Comment
setParent(Parent parent)
Sets the parent of this Content.Comment
setText(java.lang.String text)
This will set the value of theComment
.java.lang.String
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
-
-
-
-
Method Detail
-
getValue
public java.lang.String getValue()
Returns the XPath 1.0 string value of this element, which is the text of this comment.
-
getText
public java.lang.String getText()
This returns the textual data within theComment
.- Returns:
String
- text of comment.
-
setText
public Comment setText(java.lang.String text)
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
public 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
public Comment 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
protected Comment setParent(Parent parent)
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
public java.lang.String toString()
This returns aString
representation of theComment
, suitable for debugging. If the XML representation of theComment
is desired,XMLOutputter.outputString(Comment)
should be used.- Overrides:
toString
in classjava.lang.Object
- Returns:
String
- information about theComment
-
-