JDOM
0.0.5-BETA

org.jdom2
Class Comment

java.lang.Object
  extended by org.jdom2.Content
      extended by 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
 
Field Summary
protected  java.lang.String text
          Text of the Comment
 
Fields inherited from class org.jdom2.Content
ctype, parent
 
Constructor Summary
protected Comment()
          Default, no-args constructor for implementations to use if needed.
  Comment(java.lang.String text)
          This creates the comment with the supplied text.
 
Method Summary
 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 the Comment.
 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 the Comment.
 java.lang.String toString()
          This returns a String representation of the Comment, suitable for debugging.
 
Methods inherited from class org.jdom2.Content
equals, getCType, getDocument, getNamespacesInherited, getNamespacesInScope, getNamespacesIntroduced, getParent, getParentElement, hashCode
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

text

protected java.lang.String text
Text of the Comment

Constructor Detail

Comment

protected Comment()
Default, no-args constructor for implementations to use if needed.


Comment

public Comment(java.lang.String text)
This creates the comment with the supplied text.

Parameters:
text - String content of comment.
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.

Specified by:
getValue in class Content
Returns:
the text of this comment

getText

public java.lang.String getText()
This returns the textual data within the Comment.

Returns:
String - text of comment.

setText

public Comment setText(java.lang.String text)
This will set the value of the Comment.

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 vaue).

Subclasses of this should still call super.clone() in their clone method.

Overrides:
clone in class Content

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

Overrides:
detach in class Content
Returns:
this child detached

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

Overrides:
setParent in class Content
Parameters:
parent - new parent element
Returns:
the target element

toString

public java.lang.String toString()
This returns a String representation of the Comment, suitable for debugging. If the XML representation of the Comment is desired, XMLOutputter.outputString(Comment) should be used.

Overrides:
toString in class java.lang.Object
Returns:
String - information about the Comment

JDOM
0.0.5-BETA

Copyright � 2012 Jason Hunter, Brett McLaughlin. All Rights Reserved.