Class Violation

    • Constructor Detail

      • 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 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,
                         String bundle,
                         String key,
                         Object[] args,
                         SeverityLevel severityLevel,
                         String moduleId,
                         Class<?> sourceClass,
                         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,
                         String bundle,
                         String key,
                         Object[] args,
                         SeverityLevel severityLevel,
                         String moduleId,
                         Class<?> sourceClass,
                         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,
                         String bundle,
                         String key,
                         Object[] args,
                         String moduleId,
                         Class<?> sourceClass,
                         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,
                         String bundle,
                         String key,
                         Object[] args,
                         SeverityLevel severityLevel,
                         String moduleId,
                         Class<?> sourceClass,
                         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,
                         String bundle,
                         String key,
                         Object[] args,
                         String moduleId,
                         Class<?> sourceClass,
                         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 String getModuleId()
        Returns id of module.
        Returns:
        the module identifier.
      • getKey

        public 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 String getSourceName()
        Gets the name of the source for this Violation.
        Returns:
        the name of the source for this Violation
      • setLocale

        public static void setLocale​(Locale locale)
        Sets a locale to use for localization.
        Parameters:
        locale - the locale to use for localization
      • clearCache

        public static void clearCache()
        Clears the cache.
      • equals

        public boolean equals​(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 Object
      • getViolation

        public String getViolation()
        Gets the translated violation.
        Returns:
        the translated violation
      • getCustomViolation

        private String getCustomViolation()
        Returns the formatted custom violation if one is configured.
        Returns:
        the formatted custom violation or null if there is no custom violation
      • getBundle

        private ResourceBundle getBundle​(String bundleName)
        Find a ResourceBundle for a given bundle name. Uses the classloader of the class emitting this violation, to be sure to get the correct bundle.
        Parameters:
        bundleName - the bundle name
        Returns:
        a ResourceBundle