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
FieldsModifier and TypeFieldDescriptionprivate final Object[]Arguments for MessageFormat.private final StringName of the resource bundle to get violations from.private final intThe column char index.private final intThe column number.private final StringA custom violation overriding the default violation from the bundle.private static final SeverityLevelThe default severity level if one is not specified.private final StringKey for the violation format.private final intThe line number.private final StringThe id of the module generating the violation.private final SeverityLevelThe severity level.private final Class<?> Class of the source for this Violation.private final intThe token type constant. -
Constructor Summary
ConstructorsConstructorDescriptionViolation(int lineNo, int columnNo, int columnCharIndex, int tokenType, String bundle, String key, Object[] args, SeverityLevel severityLevel, String moduleId, Class<?> sourceClass, String customMessage) Creates a newViolationinstance.Violation(int lineNo, int columnNo, int tokenType, String bundle, String key, Object[] args, SeverityLevel severityLevel, String moduleId, Class<?> sourceClass, String customMessage) Creates a newViolationinstance.Violation(int lineNo, int columnNo, String bundle, String key, Object[] args, SeverityLevel severityLevel, String moduleId, Class<?> sourceClass, String customMessage) Creates a newViolationinstance.Violation(int lineNo, int columnNo, String bundle, String key, Object[] args, String moduleId, Class<?> sourceClass, String customMessage) Creates a newViolationinstance.Violation(int lineNo, String bundle, String key, Object[] args, SeverityLevel severityLevel, String moduleId, Class<?> sourceClass, String customMessage) Creates a newViolationinstance.Violation(int lineNo, String bundle, String key, Object[] args, String moduleId, Class<?> sourceClass, String customMessage) Creates a newViolationinstance. -
Method Summary
Modifier and TypeMethodDescriptionint/////////////////////////////////////////////////////////////////////////booleanIndicates whether some other object is "equal to" this one.intGets the column char index.intGets 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.intGets the line number.Returns id of module.Gets the severity level.Gets the name of the source for this Violation.intGets the token type.Gets the translated violation.inthashCode()
-
Field Details
-
DEFAULT_SEVERITY
The default severity level if one is not specified. -
lineNo
private final int lineNoThe line number. -
columnNo
private final int columnNoThe column number. -
columnCharIndex
private final int columnCharIndexThe column char index. -
tokenType
private final int tokenTypeThe 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, @Nullable String customMessage) Creates a newViolationinstance.- 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. SeeTokenTypesbundle- 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, @Nullable String customMessage) Creates a newViolationinstance.- Parameters:
lineNo- line number associated with the violationcolumnNo- column number associated with the violationtokenType- token type of the event associated with violation. SeeTokenTypesbundle- 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, @Nullable String customMessage) Creates a newViolationinstance.- 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, @Nullable String customMessage) Creates a newViolationinstance.- 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, @Nullable String customMessage) Creates a newViolationinstance.- 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, @Nullable String customMessage) Creates a newViolationinstance. 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
public int getLineNo()Gets the line number.- Returns:
- the line number
-
getColumnNo
public int getColumnNo()Gets the column number.- Returns:
- the column number
-
getColumnCharIndex
public int getColumnCharIndex()Gets the column char index.- Returns:
- the column char index
-
getTokenType
public int getTokenType()Gets the token type.- Returns:
- the token type
-
getSeverityLevel
-
getModuleId
-
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
-
hashCode
-
compareTo
/////////////////////////////////////////////////////////////////////////- Specified by:
compareToin interfaceComparable<Violation>
-
getViolation
-