Top Description Fields Constructors Methods
org.jdom2

public Class Comment

extends Content
Class Inheritance
Known Direct Subclasses
org.jdom2.located.LocatedComment

An XML comment. Methods allow the user to get and set the text of the comment.
Authors
Brett McLaughlin, Jason Hunter

Field Summary

Modifier and TypeField and Description
private static final long
protected String
text

Text of the Comment

Inherited from org.jdom2.Content:
ctypeparent

Constructor Summary

AccessConstructor and Description
protected
Comment()

Default, no-args constructor for implementations to use if needed.

public
Comment(String
String content of comment.
text
)

This creates the comment with the supplied text.

Method Summary

Modifier and TypeMethod and Description
public Comment
clone()

Overrides org.jdom2.Content.clone.

Return a deep clone of this instance.
public Comment
detach()

Overrides org.jdom2.Content.detach.

Detaches this child from its parent or does nothing if the child has no parent.
public String

Returns:

String - text of comment.
getText
()

This returns the textual data within the Comment.

public String

Returns:

the text of this comment
getValue
()

Implements abstract org.jdom2.Content.getValue.

Returns the XPath 1.0 string value of this element, which is the text of this comment.
protected Comment
setParent(Parent
new parent element
parent
)

Overrides org.jdom2.Content.setParent.

Sets the parent of this Content.
public Comment

Returns:

Comment - this Comment modified.
setText
(String
String text for comment.
text
)

This will set the value of the Comment.

public String

Returns:

String - information about the Comment
toString
()

Overrides java.lang.Object.toString.

This returns a String representation of the Comment, suitable for debugging.
Inherited from org.jdom2.Content:
equalsgetCTypegetDocumentgetNamespacesInheritedgetNamespacesInScopegetNamespacesIntroducedgetParentgetParentElementhashCode

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides org.jdom2.Content.serialVersionUID.

JDOM2 Serialization. In this case, Comment is simple.

textback to summary
protected String text

Text of the Comment

Constructor Detail

Commentback to summary
protected Comment()

Default, no-args constructor for implementations to use if needed.

Commentback to summary
public Comment(String text)

This creates the comment with the supplied text.

Parameters
text:String

String content of comment.

Method Detail

cloneback to summary
public Comment clone()

Overrides org.jdom2.Content.clone.

Doc from org.jdom2.CloneBase.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.

Returns:Comment

Doc from java.lang.Object.clone.

a clone of this instance.

Annotations
@Override
detachback to summary
public Comment detach()

Overrides org.jdom2.Content.detach.

Doc from org.jdom2.Content.detach.

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();

Returns:Comment

this child detached

Annotations
@Override
getTextback to summary
public String getText()

This returns the textual data within the Comment.

Returns:String

String - text of comment.

getValueback to summary
public String getValue()

Implements abstract org.jdom2.Content.getValue.

Returns the XPath 1.0 string value of this element, which is the text of this comment.

Returns:String

the text of this comment

Annotations
@Override
setParentback to summary
protected Comment setParent(Parent parent)

Overrides org.jdom2.Content.setParent.

Doc from org.jdom2.Content.setParent.

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);

Parameters
parent:Parent

new parent element

Returns:Comment

the target element

Annotations
@Override
setTextback to summary
public Comment setText(String text)

This will set the value of the Comment.

Parameters
text:String

String text for comment.

Returns:Comment

Comment - this Comment modified.

Exceptions
IllegalDataException:
if the given text is illegal for a Comment.
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

This returns a String representation of the Comment, suitable for debugging. If the XML representation of the Comment is desired, org.jdom2.output.XMLOutputter#outputString(Comment) should be used.

Returns:String

String - information about the Comment

Annotations
@Override