Interface CtComment

All Superinterfaces:
Cloneable, CtCodeElement, CtElement, CtQueryable, CtStatement, CtVisitable, FactoryAccessor, Serializable, SourcePositionHolder
All Known Subinterfaces:
CtJavaDoc
All Known Implementing Classes:
CtCommentImpl, CtJavaDocImpl

public interface CtComment extends CtStatement
This code element defines a comment Example: int x = 0; // a comment
  • Field Details

    • LINE_SEPARATOR

      static final String LINE_SEPARATOR
      This line separator is used in comments returned by getContent(). It is OS independent. It has no influence to pretty printed comments, which uses by default OS dependent line separator
      See Also:
      Constant Field Values
  • Method Details

    • getContent

      String getContent()
      Get the content of the comment
      Returns:
      the content of the comment
    • setContent

      <E extends CtComment> E setContent(String content)
    • getRawContent

      String getRawContent()
      Returns:
      the original raw comment from the source file including comment prefix and suffix, indentation (including TABs) original EOLs, based on the attached position object (the returned value is "derived" from the position). If the file pointed to in the position object does not exist on disk anymore, then the empty string "" is returned Note: the call of setContent(String) doesn't influence the returned value, only the value of the position object.
    • getCommentType

      CtComment.CommentType getCommentType()
      Get the type of the comment
      Returns:
      the comment type
    • setCommentType

      <E extends CtComment> E setCommentType(CtComment.CommentType commentType)
    • clone

      CtComment clone()
      Description copied from interface: CtElement
      Clone the element which calls this method in a new object. Note that that references are kept as is, and thus, so if you clone whole classes or methods, some parts of the cloned element (eg executable references) may still point to the initial element. In this case, consider using methods Refactoring.copyType(CtType) and Refactoring.copyMethod(CtMethod) instead which does additional work beyond cloning.
      Specified by:
      clone in interface CtCodeElement
      Specified by:
      clone in interface CtElement
      Specified by:
      clone in interface CtStatement
    • asJavaDoc

      CtJavaDoc asJavaDoc()
      Utility method to for casting the object, throws an exception if not of the correct type