Class Comment

java.lang.Object
com.puppycrawl.tools.checkstyle.api.Comment
All Implemented Interfaces:
TextBlock

public class Comment extends Object implements TextBlock
Representation of the comment block.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final int
    Number of last column of the comment.
    private final int
    Number of last line of the comment.
    private final int
    Number of first column of the comment.
    private final int
    Number of first line of the comment.
    private final String[]
    Text of the comment.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Comment(String[] text, int firstCol, int lastLine, int lastCol)
    Creates new instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    The column in the input file where the text block ends.
    final int
    The last line of the text block in the input file.
    int
    The column in the input file where the text block starts.
    final int
    The line in the input file where the text block starts.
    final String[]
    The text content of the text block.
    boolean
    intersects(int startLine, int startCol, int endLine, int endCol)
    Checks if this comment intersects with a specified part of the file.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • text

      private final String[] text
      Text of the comment.
    • startLineNo

      private final int startLineNo
      Number of first line of the comment.
    • endLineNo

      private final int endLineNo
      Number of last line of the comment.
    • startColNo

      private final int startColNo
      Number of first column of the comment.
    • endColNo

      private final int endColNo
      Number of last column of the comment.
  • Constructor Details

    • Comment

      public Comment(String[] text, int firstCol, int lastLine, int lastCol)
      Creates new instance.
      Parameters:
      text - the lines that make up the comment.
      firstCol - number of the first column of the comment.
      lastLine - number of the last line of the comment.
      lastCol - number of the last column of the comment.
  • Method Details

    • getText

      public final String[] getText()
      Description copied from interface: TextBlock
      The text content of the text block. Each line is represented by one array entry. The linebreak characters are not part of the text content.
      Specified by:
      getText in interface TextBlock
      Returns:
      the text content of the text block.
    • getStartLineNo

      public final int getStartLineNo()
      Description copied from interface: TextBlock
      The line in the input file where the text block starts. Counting starts from 1.
      Specified by:
      getStartLineNo in interface TextBlock
      Returns:
      first line of the text block
    • getEndLineNo

      public final int getEndLineNo()
      Description copied from interface: TextBlock
      The last line of the text block in the input file. Counting starts from 1.
      Specified by:
      getEndLineNo in interface TextBlock
      Returns:
      last line of the text block
    • getStartColNo

      public int getStartColNo()
      Description copied from interface: TextBlock
      The column in the input file where the text block starts. Counting starts from 0.
      Specified by:
      getStartColNo in interface TextBlock
      Returns:
      first line of the text block
    • getEndColNo

      public int getEndColNo()
      Description copied from interface: TextBlock
      The column in the input file where the text block ends. Counting starts from 0.
      Specified by:
      getEndColNo in interface TextBlock
      Returns:
      last line of the text block
    • intersects

      public boolean intersects(int startLine, int startCol, int endLine, int endCol)
      Description copied from interface: TextBlock
      Checks if this comment intersects with a specified part of the file.
      Specified by:
      intersects in interface TextBlock
      Parameters:
      startLine - the starting line number in the file
      startCol - the starting column number in the file
      endLine - the ending line number in the file
      endCol - the ending column number in the file
      Returns:
      true if the positions intersects with this comment.
    • toString

      public String toString()
      Overrides:
      toString in class Object