Class Violation
java.lang.Object
com.puppycrawl.tools.checkstyle.api.Violation
- All Implemented Interfaces:
Comparable<Violation>
Represents a violation that can be localised. The translations come from
message.properties files. The underlying implementation uses
java.text.MessageFormat.
-
Field Summary
Modifier and TypeFieldDescriptionprivate final Object[]
Arguments for MessageFormat.private final String
Name of the resource bundle to get violations from.private final int
The column char index.private final int
The column number.private final String
A custom violation overriding the default violation from the bundle.private static final SeverityLevel
The default severity level if one is not specified.private final String
Key for the violation format.private final int
The line number.private final String
The id of the module generating the violation.private final SeverityLevel
The severity level.private final Class<?>
Class of the source for this Violation.private final int
The token type constant. -
Constructor Summary
ConstructorDescriptionViolation
(int lineNo, int columnNo, int columnCharIndex, int tokenType, String bundle, String key, Object[] args, SeverityLevel severityLevel, String moduleId, Class<?> sourceClass, String customMessage) Creates a newViolation
instance.Violation
(int lineNo, int columnNo, int tokenType, String bundle, String key, Object[] args, SeverityLevel severityLevel, String moduleId, Class<?> sourceClass, String customMessage) Creates a newViolation
instance.Violation
(int lineNo, int columnNo, String bundle, String key, Object[] args, SeverityLevel severityLevel, String moduleId, Class<?> sourceClass, String customMessage) Creates a newViolation
instance.Violation
(int lineNo, int columnNo, String bundle, String key, Object[] args, String moduleId, Class<?> sourceClass, String customMessage) Creates a newViolation
instance.Violation
(int lineNo, String bundle, String key, Object[] args, SeverityLevel severityLevel, String moduleId, Class<?> sourceClass, String customMessage) Creates a newViolation
instance.Violation
(int lineNo, String bundle, String key, Object[] args, String moduleId, Class<?> sourceClass, String customMessage) Creates a newViolation
instance. -
Method Summary
Modifier and TypeMethodDescriptionint
boolean
Indicates whether some other object is "equal to" this one.int
Gets the column char index.int
Gets the column number.getKey()
Returns the violation key to locate the translation, can also be used in IDE plugins to map audit event violations to corrective actions.int
Gets the line number.Returns id of module.Gets the severity level.Gets the name of the source for this Violation.int
Gets the token type.Gets the translated violation.int
hashCode()
-
Field Details
-
DEFAULT_SEVERITY
The default severity level if one is not specified. -
lineNo
The line number. -
columnNo
The column number. -
columnCharIndex
The column char index. -
tokenType
The token type constant. SeeTokenTypes
. -
severityLevel
The severity level. -
moduleId
The id of the module generating the violation. -
key
Key for the violation format. -
args
Arguments for MessageFormat. -
bundle
Name of the resource bundle to get violations from. -
sourceClass
Class of the source for this Violation. -
customMessage
A custom violation overriding the default violation from the bundle.
-
-
Constructor Details
-
Violation
public Violation(int lineNo, int columnNo, int columnCharIndex, int tokenType, String bundle, String key, Object[] args, SeverityLevel severityLevel, String moduleId, Class<?> sourceClass, String customMessage) Creates a newViolation
instance.- Parameters:
lineNo
- line number associated with the violationcolumnNo
- column number associated with the violationcolumnCharIndex
- column char index associated with the violationtokenType
- token type of the event associated with violation. SeeTokenTypes
bundle
- resource bundle namekey
- the key to locate the translationargs
- arguments for the translationseverityLevel
- severity level for the violationmoduleId
- the id of the module the violation is associated withsourceClass
- the Class that is the source of the violationcustomMessage
- optional custom violation overriding the default
-
Violation
public Violation(int lineNo, int columnNo, int tokenType, String bundle, String key, Object[] args, SeverityLevel severityLevel, String moduleId, Class<?> sourceClass, String customMessage) Creates a newViolation
instance.- Parameters:
lineNo
- line number associated with the violationcolumnNo
- column number associated with the violationtokenType
- token type of the event associated with violation. SeeTokenTypes
bundle
- resource bundle namekey
- the key to locate the translationargs
- arguments for the translationseverityLevel
- severity level for the violationmoduleId
- the id of the module the violation is associated withsourceClass
- the Class that is the source of the violationcustomMessage
- optional custom violation overriding the default
-
Violation
public Violation(int lineNo, int columnNo, String bundle, String key, Object[] args, SeverityLevel severityLevel, String moduleId, Class<?> sourceClass, String customMessage) Creates a newViolation
instance.- Parameters:
lineNo
- line number associated with the violationcolumnNo
- column number associated with the violationbundle
- resource bundle namekey
- the key to locate the translationargs
- arguments for the translationseverityLevel
- severity level for the violationmoduleId
- the id of the module the violation is associated withsourceClass
- the Class that is the source of the violationcustomMessage
- optional custom violation overriding the default
-
Violation
public Violation(int lineNo, int columnNo, String bundle, String key, Object[] args, String moduleId, Class<?> sourceClass, String customMessage) Creates a newViolation
instance.- Parameters:
lineNo
- line number associated with the violationcolumnNo
- column number associated with the violationbundle
- resource bundle namekey
- the key to locate the translationargs
- arguments for the translationmoduleId
- the id of the module the violation is associated withsourceClass
- the Class that is the source of the violationcustomMessage
- optional custom violation overriding the default
-
Violation
public Violation(int lineNo, String bundle, String key, Object[] args, SeverityLevel severityLevel, String moduleId, Class<?> sourceClass, String customMessage) Creates a newViolation
instance.- Parameters:
lineNo
- line number associated with the violationbundle
- resource bundle namekey
- the key to locate the translationargs
- arguments for the translationseverityLevel
- severity level for the violationmoduleId
- the id of the module the violation is associated withsourceClass
- the source class for the violationcustomMessage
- optional custom violation overriding the default
-
Violation
public Violation(int lineNo, String bundle, String key, Object[] args, String moduleId, Class<?> sourceClass, String customMessage) Creates a newViolation
instance. The column number defaults to 0.- Parameters:
lineNo
- line number associated with the violationbundle
- name of a resource bundle that contains audit event violationskey
- the key to locate the translationargs
- arguments for the translationmoduleId
- the id of the module the violation is associated withsourceClass
- the name of the source for the violationcustomMessage
- optional custom violation overriding the default
-
-
Method Details
-
getLineNo
Gets the line number.- Returns:
- the line number
-
getColumnNo
Gets the column number.- Returns:
- the column number
-
getColumnCharIndex
Gets the column char index.- Returns:
- the column char index
-
getTokenType
Gets the token type.- Returns:
- the token type
-
getSeverityLevel
Gets the severity level.- Returns:
- the severity level
-
getModuleId
Returns id of module.- Returns:
- the module identifier.
-
getKey
Returns the violation key to locate the translation, can also be used in IDE plugins to map audit event violations to corrective actions.- Returns:
- the violation key
-
getSourceName
Gets the name of the source for this Violation.- Returns:
- the name of the source for this Violation
-
equals
Indicates whether some other object is "equal to" this one. Suppression on enumeration is needed so code stays consistent. -
hashCode
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Violation>
-
getViolation
Gets the translated violation.- Returns:
- the translated violation
-