Class CtCommentImpl

All Implemented Interfaces:
Serializable, Cloneable, FactoryAccessor, CtCodeElement, CtComment, CtStatement, SourcePositionHolder, CtElement, CtQueryable, CtVisitable
Direct Known Subclasses:

public class CtCommentImpl extends CtStatementImpl implements CtComment
See Also:
Serialized Form
  • Field Details

    • content

      protected String content
  • Constructor Details

    • CtCommentImpl

      public CtCommentImpl()
    • CtCommentImpl

      protected CtCommentImpl(CtComment.CommentType type)
  • Method Details

    • getContent

      public String getContent()
      Description copied from interface: CtComment
      Get the content of the comment
      Specified by:
      getContent in interface CtComment
      the content of the comment
    • getRawContent

      public String getRawContent()
      Specified by:
      getRawContent in interface CtComment
      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 CtComment.setContent(String) doesn't influence the returned value, only the value of the position object.
    • setContent

      public <E extends CtComment> E setContent(String content)
      Specified by:
      setContent in interface CtComment
    • _setRawContent

      public <E extends CtComment> E _setRawContent(String content)
      FOR ADVANCED USAGE ONLY Set the comment content, without cleaning the comment, if the cleaning behavior to get a canonical version does not work for you. Does not ensure any AST contract such as calling the change listener You have to cast your comment to CtCommentImpl, it's not beautiful, but it's known :-)
    • getCommentType

      public CtComment.CommentType getCommentType()
      Description copied from interface: CtComment
      Get the type of the comment
      Specified by:
      getCommentType in interface CtComment
      the comment type
    • setCommentType

      public <E extends CtComment> E setCommentType(CtComment.CommentType commentType)
      Specified by:
      setCommentType in interface CtComment
    • accept

      public void accept(CtVisitor visitor)
      Description copied from interface: CtVisitable
      Accepts a visitor
      Specified by:
      accept in interface CtVisitable
    • equals

      public boolean equals(Object o)
      The comments are not printed during the CtElement equality. The method is this overridden for CtComment.
      equals in class CtElementImpl
    • hashCode

      public int hashCode()
      hashCode in class CtElementImpl
    • clone

      public 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 CtComment
      Specified by:
      clone in interface CtElement
      Specified by:
      clone in interface CtStatement
      clone in class CtStatementImpl
    • asJavaDoc

      public CtJavaDoc asJavaDoc()
      Description copied from interface: CtComment
      Utility method to for casting the object, throws an exception if not of the correct type
      Specified by:
      asJavaDoc in interface CtComment