Class Violation

java.lang.Object
org.apache.maven.plugins.checkstyle.Violation

class Violation extends Object
Holds data about a single violation and represents the violation itself.
  • Field Details

    • NO_COLUMN

      protected static final String NO_COLUMN
      Indicates that a column is not set.
      See Also:
    • source

      private final String source
      The full qualified class name of the checkstyle rule
    • file

      private final String file
      The absolute path of the file containing the violation
    • line

      private final String line
    • column

      private String column
    • severity

      private final String severity
    • message

      private final String message
    • ruleName

      private final String ruleName
    • category

      private final String category
  • Constructor Details

    • Violation

      Violation(String source, String file, String line, String severity, String message, String ruleName, String category)
      Creates a violation instance without a column set.
      Parameters:
      source - the fully qualified class name of the checkstyle rule
      file - the absolute file path in which the violation occurred
      line - the line in the file on which the violation occurred
      severity - the severity of the violation
      message - the message from checkstyle for this violation
      ruleName - the rule name from which this violation was created
      category - the category of the checkstyle violation
  • Method Details

    • getSource

      protected String getSource()
      Returns the fully qualified class name of the checker rule.
      Returns:
      the fully qualified class name of the checker rule
    • getFile

      protected String getFile()
      Returns the absolute file path to the checked file.
      Returns:
      the absolute file path to the checked file
    • getLine

      protected String getLine()
      Returns the line in the checked file on which the violation occurred.
      Returns:
      the line in the checked file on which the violation occurred
    • getColumn

      protected String getColumn()
      Returns the column in which the violation occurred, if available.
      Returns:
      the column in which the violation occurred, if available. Otherwise returns NO_COLUMN.
    • setColumn

      protected void setColumn(String column)
      Sets the column value for this violation to the given string value.
      Parameters:
      column - the column value to set. May be null, which will set it to the NO_COLUMN value.
    • getSeverity

      protected String getSeverity()
      Returns the severity of the current violation.
      Returns:
      the severity of the current violation
    • getMessage

      protected String getMessage()
      Returns the message produced by checkstyle for the current violation.
      Returns:
      the message produced by checkstyle for the current violation
    • getRuleName

      protected String getRuleName()
      Returns the name of the rule which led to the current violation.
      Returns:
      the name of the rule which led to the current violation
    • getCategory

      protected String getCategory()
      Returns the category of the current violation.
      Returns:
      the category of the current violation
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object