org.jdom

Class Comment

Implemented Interfaces:
Cloneable, Serializable

public class Comment
extends Content

An XML comment. Methods allow the user to get and set the text of the comment.
See Also:
Serialized Form

Field Summary

protected String
text
Text of the Comment

Fields inherited from class org.jdom.Content

parent

Constructor Summary

Comment()
Default, no-args constructor for implementations to use if needed.
Comment(String text)
This creates the comment with the supplied text.

Method Summary

String
getText()
This returns the textual data within the Comment.
String
getValue()
Returns the XPath 1.0 string value of this element, which is the text of this comment.
Comment
setText(String text)
This will set the value of the Comment.
String
toString()
This returns a String representation of the Comment, suitable for debugging.

Methods inherited from class org.jdom.Content

clone, detach, equals, getDocument, getParent, getParentElement, getValue, hashCode, setParent

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

text

protected String text
Text of the Comment

Constructor Details

Comment

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

Comment

public Comment(String text)
This creates the comment with the supplied text.
Parameters:
text - String content of comment.
Usages and Demos :

View More Examples of Comment(String text)
   1:         
   2:         Comment comment = new Comment(header);
   3:         doc.getContent().add(0, comment);
   4: 
   5:         Enumeration propertyNames = propertyNames();

View Full Code Here
   1:         if (comment != null) {
   2:             Comment c = new Comment(comment);
   3:             el.addContent(c);
   4:         }

View Full Code Here
   1:         if (comment != null) {
   2:             Comment c = new Comment(comment);
   3:             el.addContent(c);
   4:         }

View Full Code Here
   1:         if (comment != null) {
   2:             Comment c = new Comment(comment);
   3:             el.addContent(c);
   4:         }

View Full Code Here
   1:         if (comment != null) {
   2:             Comment c = new Comment(comment);
   3:             el.addContent(c);
   4:         }

View Full Code Here

Method Details

getText

public String getText()
This returns the textual data within the Comment.
Returns:
String - text of comment.
Usages and Demos :

View More Examples of getText()
   1: import org.apache.xerces.xs.XSElementDeclaration;
   2: import org.jdom.Comment;
   3: import org.jdom.filter.ContentFilter;
   4:         ...
   5:         org.jdom.Document doc= getJDomDocument(filename);
   6:         Filter filter = new ContentFilter(ContentFilter.COMMENT);
   7:                 
   8:         ...
   9:         if((list==null)||list.size()==0) return "";
  10:         Comment ele=(Comment)list.get(0);
  11:             
  12:         ...
  13:         
  14:         String toReturn=ele.getText(); 

View Full Code Here

getValue

public String getValue()
Returns the XPath 1.0 string value of this element, which is the text of this comment.
Overrides:
getValue in interface Content
Returns:
the text of this comment
Usages and Demos :

View More Examples of getValue()
   1: import org.jdom.Attribute;
   2: import org.jdom.Comment;
   3: import org.jdom.DocType;
   4:         ...
   5:         public static boolean equivalent(Text t1, Text t2) {
   6:             String v1 = t1.getValue();
   7:         ...
   8:             String v2 = t2.getValue();
   9:             return v1.equals(v2);
  10:         ...
  11:     
  12:         public static boolean equivalent(Comment c1, Comment c2) {

View Full Code Here

setText

public Comment setText(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.

toString

public 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 interface Object
Returns:
String - information about the Attribute