Class Violation

  • All Implemented Interfaces:
    java.lang.Comparable<Violation>

    public final class Violation
    extends java.lang.Object
    implements java.lang.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

      Fields 
      Modifier and Type Field Description
      private java.lang.Object[] args
      Arguments for MessageFormat.
      private java.lang.String bundle
      Name of the resource bundle to get violations from.
      private int columnCharIndex
      The column char index.
      private int columnNo
      The column number.
      private java.lang.String customMessage
      A custom violation overriding the default violation from the bundle.
      private static SeverityLevel DEFAULT_SEVERITY
      The default severity level if one is not specified.
      private java.lang.String key
      Key for the violation format.
      private int lineNo
      The line number.
      private java.lang.String moduleId
      The id of the module generating the violation.
      private SeverityLevel severityLevel
      The severity level.
      private java.lang.Class<?> sourceClass
      Class of the source for this Violation.
      private int tokenType
      The token type constant.
    • Constructor Summary

      Constructors 
      Constructor Description
      Violation​(int lineNo, int columnNo, int columnCharIndex, int tokenType, java.lang.String bundle, java.lang.String key, java.lang.Object[] args, SeverityLevel severityLevel, java.lang.String moduleId, java.lang.Class<?> sourceClass, java.lang.String customMessage)
      Creates a new Violation instance.
      Violation​(int lineNo, int columnNo, int tokenType, java.lang.String bundle, java.lang.String key, java.lang.Object[] args, SeverityLevel severityLevel, java.lang.String moduleId, java.lang.Class<?> sourceClass, java.lang.String customMessage)
      Creates a new Violation instance.
      Violation​(int lineNo, int columnNo, java.lang.String bundle, java.lang.String key, java.lang.Object[] args, SeverityLevel severityLevel, java.lang.String moduleId, java.lang.Class<?> sourceClass, java.lang.String customMessage)
      Creates a new Violation instance.
      Violation​(int lineNo, int columnNo, java.lang.String bundle, java.lang.String key, java.lang.Object[] args, java.lang.String moduleId, java.lang.Class<?> sourceClass, java.lang.String customMessage)
      Creates a new Violation instance.
      Violation​(int lineNo, java.lang.String bundle, java.lang.String key, java.lang.Object[] args, SeverityLevel severityLevel, java.lang.String moduleId, java.lang.Class<?> sourceClass, java.lang.String customMessage)
      Creates a new Violation instance.
      Violation​(int lineNo, java.lang.String bundle, java.lang.String key, java.lang.Object[] args, java.lang.String moduleId, java.lang.Class<?> sourceClass, java.lang.String customMessage)
      Creates a new Violation instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(Violation other)  
      boolean equals​(java.lang.Object object)
      Indicates whether some other object is "equal to" this one.
      int getColumnCharIndex()
      Gets the column char index.
      int getColumnNo()
      Gets the column number.
      java.lang.String 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 getLineNo()
      Gets the line number.
      java.lang.String getModuleId()
      Returns id of module.
      SeverityLevel getSeverityLevel()
      Gets the severity level.
      java.lang.String getSourceName()
      Gets the name of the source for this Violation.
      int getTokenType()
      Gets the token type.
      java.lang.String getViolation()
      Gets the translated violation.
      int hashCode()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • lineNo

        private final int lineNo
        The line number.
      • columnNo

        private final int columnNo
        The column number.
      • columnCharIndex

        private final int columnCharIndex
        The column char index.
      • moduleId

        private final java.lang.String moduleId
        The id of the module generating the violation.
      • key

        private final java.lang.String key
        Key for the violation format.
      • args

        private final java.lang.Object[] args
        Arguments for MessageFormat.
      • bundle

        private final java.lang.String bundle
        Name of the resource bundle to get violations from.
      • sourceClass

        private final java.lang.Class<?> sourceClass
        Class of the source for this Violation.
      • customMessage

        private final java.lang.String customMessage
        A custom violation overriding the default violation from the bundle.
    • Constructor Detail

      • Violation

        public Violation​(int lineNo,
                         int columnNo,
                         int columnCharIndex,
                         int tokenType,
                         java.lang.String bundle,
                         java.lang.String key,
                         java.lang.Object[] args,
                         SeverityLevel severityLevel,
                         java.lang.String moduleId,
                         java.lang.Class<?> sourceClass,
                         java.lang.String customMessage)
        Creates a new Violation instance.
        Parameters:
        lineNo - line number associated with the violation
        columnNo - column number associated with the violation
        columnCharIndex - column char index associated with the violation
        tokenType - token type of the event associated with violation. See TokenTypes
        bundle - resource bundle name
        key - the key to locate the translation
        args - arguments for the translation
        severityLevel - severity level for the violation
        moduleId - the id of the module the violation is associated with
        sourceClass - the Class that is the source of the violation
        customMessage - optional custom violation overriding the default
      • Violation

        public Violation​(int lineNo,
                         int columnNo,
                         int tokenType,
                         java.lang.String bundle,
                         java.lang.String key,
                         java.lang.Object[] args,
                         SeverityLevel severityLevel,
                         java.lang.String moduleId,
                         java.lang.Class<?> sourceClass,
                         java.lang.String customMessage)
        Creates a new Violation instance.
        Parameters:
        lineNo - line number associated with the violation
        columnNo - column number associated with the violation
        tokenType - token type of the event associated with violation. See TokenTypes
        bundle - resource bundle name
        key - the key to locate the translation
        args - arguments for the translation
        severityLevel - severity level for the violation
        moduleId - the id of the module the violation is associated with
        sourceClass - the Class that is the source of the violation
        customMessage - optional custom violation overriding the default
      • Violation

        public Violation​(int lineNo,
                         int columnNo,
                         java.lang.String bundle,
                         java.lang.String key,
                         java.lang.Object[] args,
                         SeverityLevel severityLevel,
                         java.lang.String moduleId,
                         java.lang.Class<?> sourceClass,
                         java.lang.String customMessage)
        Creates a new Violation instance.
        Parameters:
        lineNo - line number associated with the violation
        columnNo - column number associated with the violation
        bundle - resource bundle name
        key - the key to locate the translation
        args - arguments for the translation
        severityLevel - severity level for the violation
        moduleId - the id of the module the violation is associated with
        sourceClass - the Class that is the source of the violation
        customMessage - optional custom violation overriding the default
      • Violation

        public Violation​(int lineNo,
                         int columnNo,
                         java.lang.String bundle,
                         java.lang.String key,
                         java.lang.Object[] args,
                         java.lang.String moduleId,
                         java.lang.Class<?> sourceClass,
                         java.lang.String customMessage)
        Creates a new Violation instance.
        Parameters:
        lineNo - line number associated with the violation
        columnNo - column number associated with the violation
        bundle - resource bundle name
        key - the key to locate the translation
        args - arguments for the translation
        moduleId - the id of the module the violation is associated with
        sourceClass - the Class that is the source of the violation
        customMessage - optional custom violation overriding the default
      • Violation

        public Violation​(int lineNo,
                         java.lang.String bundle,
                         java.lang.String key,
                         java.lang.Object[] args,
                         SeverityLevel severityLevel,
                         java.lang.String moduleId,
                         java.lang.Class<?> sourceClass,
                         java.lang.String customMessage)
        Creates a new Violation instance.
        Parameters:
        lineNo - line number associated with the violation
        bundle - resource bundle name
        key - the key to locate the translation
        args - arguments for the translation
        severityLevel - severity level for the violation
        moduleId - the id of the module the violation is associated with
        sourceClass - the source class for the violation
        customMessage - optional custom violation overriding the default
      • Violation

        public Violation​(int lineNo,
                         java.lang.String bundle,
                         java.lang.String key,
                         java.lang.Object[] args,
                         java.lang.String moduleId,
                         java.lang.Class<?> sourceClass,
                         java.lang.String customMessage)
        Creates a new Violation instance. The column number defaults to 0.
        Parameters:
        lineNo - line number associated with the violation
        bundle - name of a resource bundle that contains audit event violations
        key - the key to locate the translation
        args - arguments for the translation
        moduleId - the id of the module the violation is associated with
        sourceClass - the name of the source for the violation
        customMessage - optional custom violation overriding the default
    • Method Detail

      • 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
      • getModuleId

        public java.lang.String getModuleId()
        Returns id of module.
        Returns:
        the module identifier.
      • getKey

        public java.lang.String 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

        public java.lang.String getSourceName()
        Gets the name of the source for this Violation.
        Returns:
        the name of the source for this Violation
      • equals

        public boolean equals​(java.lang.Object object)
        Indicates whether some other object is "equal to" this one. Suppression on enumeration is needed so code stays consistent.
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • getViolation

        public java.lang.String getViolation()
        Gets the translated violation.
        Returns:
        the translated violation