Class AbstractFileSetCheck

    • Constructor Detail

      • AbstractFileSetCheck

        public AbstractFileSetCheck()
    • Method Detail

      • processFiltered

        protected abstract void processFiltered​(java.io.File file,
                                                FileText fileText)
                                         throws CheckstyleException
        Called to process a file that matches the specified file extensions.
        Parameters:
        file - the file to be processed
        fileText - the contents of the file.
        Throws:
        CheckstyleException - if error condition within Checkstyle occurs.
      • init

        public void init()
        Description copied from interface: FileSetCheck
        Initialise the instance. This is the time to verify that everything required to perform it job.
        Specified by:
        init in interface FileSetCheck
      • beginProcessing

        public void beginProcessing​(java.lang.String charset)
        Description copied from interface: FileSetCheck
        Called when about to be called to process a set of files.
        Specified by:
        beginProcessing in interface FileSetCheck
        Parameters:
        charset - the character set used to read the files.
      • process

        public final java.util.SortedSet<LocalizedMessage> process​(java.io.File file,
                                                                   FileText fileText)
                                                            throws CheckstyleException
        Description copied from interface: FileSetCheck
        Request to process a file. The implementation should use the supplied contents and not read the contents again. This reduces the amount of file I/O.

        The file set to process might contain files that are not interesting to the FileSetCheck. Such files should be ignored, no audit event should be fired for them. For example a FileSetCheck that checks java files should ignore HTML or properties files.

        The method should return the set of messages to be logged.

        Specified by:
        process in interface FileSetCheck
        Parameters:
        file - the file to be processed
        fileText - the contents of the file.
        Returns:
        the sorted set of messages to be logged.
        Throws:
        CheckstyleException - if error condition within Checkstyle occurs
      • finishProcessing

        public void finishProcessing()
        Description copied from interface: FileSetCheck
        Called when all the files have been processed. This is the time to perform any checks that need to be done across a set of files. In this method, the implementation is responsible for the logging of messages.
        Specified by:
        finishProcessing in interface FileSetCheck
      • setMessageDispatcher

        public final void setMessageDispatcher​(MessageDispatcher messageDispatcher)
        Description copied from interface: FileSetCheck
        Sets the MessageDispatcher that is used to dispatch audit events to AuditListeners during processing.
        Specified by:
        setMessageDispatcher in interface FileSetCheck
        Parameters:
        messageDispatcher - the dispatcher
      • getMessageDispatcher

        protected final MessageDispatcher getMessageDispatcher()
        A message dispatcher is used to fire violation messages to interested audit listeners.
        Returns:
        the current MessageDispatcher.
      • setFileContents

        public final void setFileContents​(FileContents contents)
        Set the file contents associated with the tree.
        Parameters:
        contents - the manager
      • getFileContents

        protected final FileContents getFileContents()
        Returns the file contents associated with the file.
        Returns:
        the file contents
      • getFileExtensions

        public java.lang.String[] getFileExtensions()
        Makes copy of file extensions and returns them.
        Returns:
        file extensions that identify the files that pass the filter of this FileSetCheck.
      • setFileExtensions

        public final void setFileExtensions​(java.lang.String... extensions)
        Setter to specify the file type extension of files to process.
        Parameters:
        extensions - the set of file extensions. A missing initial '.' character of an extension is automatically added.
        Throws:
        java.lang.IllegalArgumentException - is argument is null
      • getTabWidth

        protected final int getTabWidth()
        Get tab width to report audit events with.
        Returns:
        the tab width to report audit events with
      • setTabWidth

        public final void setTabWidth​(int tabWidth)
        Set the tab width to report audit events with.
        Parameters:
        tabWidth - an int value
      • log

        public final void log​(int line,
                              java.lang.String key,
                              java.lang.Object... args)
        Description copied from class: AbstractViolationReporter
        Log a message that has no column information.
        Specified by:
        log in class AbstractViolationReporter
        Parameters:
        line - the line number where the audit event was found
        key - the message that describes the audit event
        args - the details of the message
        See Also:
        MessageFormat
      • log

        public final void log​(int lineNo,
                              int colNo,
                              java.lang.String key,
                              java.lang.Object... args)
        Description copied from class: AbstractViolationReporter
        Log a message that has column information.
        Specified by:
        log in class AbstractViolationReporter
        Parameters:
        lineNo - the line number where the audit event was found
        colNo - the column number where the audit event was found
        key - the message that describes the audit event
        args - the details of the message
        See Also:
        MessageFormat
      • fireErrors

        protected final void fireErrors​(java.lang.String fileName)
        Notify all listeners about the errors in a file. Calls MessageDispatcher.fireErrors() with all logged errors and then clears errors' list.
        Parameters:
        fileName - the audited file