Class Checker

    • Constructor Detail

      • Checker

        public Checker()
        Creates a new Checker instance. The instance needs to be contextualized and configured.
    • Method Detail

      • setCacheFile

        public void setCacheFile​(String fileName)
                          throws IOException
        Sets cache file.
        fileName - the cache file.
        IOException - if there are some problems with file loading.
      • removeFilter

        public void removeFilter​(Filter filter)
        Removes filter.
        filter - filter to remove.
      • removeListener

        public void removeListener​(AuditListener listener)
        Removes a given listener.
        listener - a listener to remove
      • setBasedir

        public void setBasedir​(String basedir)
        Sets base directory.
        basedir - the base directory to strip off in file names
      • process

        public int process​(List<File> files)
                    throws CheckstyleException
        Description copied from interface: RootModule
        Processes a set of files. Once this is done, it is highly recommended to call for the destroy method to close and remove the listeners.
        Specified by:
        process in interface RootModule
        files - the list of files to be audited.
        the total number of audit events with error severity found
        CheckstyleException - if error condition within Checkstyle occurs
        See Also:
      • getExternalResourceLocations

        private Set<StringgetExternalResourceLocations()
        Returns a set of external configuration resource locations which are used by all file set checks and filters.
        a set of external configuration resource locations which are used by all file set checks and filters.
      • fireAuditStarted

        private void fireAuditStarted()
        Notify all listeners about the audit start.
      • fireAuditFinished

        private void fireAuditFinished()
        Notify all listeners about the audit end.
      • processFiles

        private void processFiles​(List<File> files)
                           throws CheckstyleException
        Processes a list of files with all FileSetChecks.
        files - a list of files to process.
        CheckstyleException - if error condition within Checkstyle occurs.
        Error - wraps any java.lang.Error happened during execution
      • acceptFileStarted

        private boolean acceptFileStarted​(String fileName)
        Check if all before execution file filters accept starting the file.
        fileName - the file to be audited
        true if the file is accepted.
      • addFileSetCheck

        public void addFileSetCheck​(FileSetCheck fileSetCheck)
        Adds a FileSetCheck to the list of FileSetChecks that is executed in process().
        fileSetCheck - the additional FileSetCheck
      • addFilter

        public void addFilter​(Filter filter)
        Adds a filter to the end of the audit event filter chain.
        filter - the additional filter
      • addListener

        public final void addListener​(AuditListener listener)
        Description copied from interface: RootModule
        Add the listener that will be used to receive events from the audit.
        Specified by:
        addListener in interface RootModule
        listener - the nosy thing
      • setFileExtensions

        public final void setFileExtensions​(String... extensions)
        Sets the file extensions that identify the files that pass the filter of this FileSetCheck.
        extensions - the set of file extensions. A missing initial '.' character of an extension is automatically added.
      • setModuleFactory

        public void setModuleFactory​(ModuleFactory moduleFactory)
        Sets the factory for creating submodules.
        moduleFactory - the factory for creating FileSetChecks
      • setLocaleCountry

        public void setLocaleCountry​(String localeCountry)
        Sets locale country.
        localeCountry - the country to report messages
      • setLocaleLanguage

        public void setLocaleLanguage​(String localeLanguage)
        Sets locale language.
        localeLanguage - the language to report messages
      • setSeverity

        public final void setSeverity​(String severity)
        Sets the severity level. The string should be one of the names defined in the SeverityLevel class.
        severity - The new severity level
        See Also:
      • setModuleClassLoader

        public final void setModuleClassLoader​(ClassLoader moduleClassLoader)
        Description copied from interface: RootModule
        Sets the classloader used to load Checkstyle core and custom module classes when the module tree is being built up. If no custom ModuleFactory is being set for the root module then this module classloader must be specified.
        Specified by:
        setModuleClassLoader in interface RootModule
        moduleClassLoader - the classloader used to load module classes
      • setHaltOnException

        public void setHaltOnException​(boolean haltOnException)
        Sets the field haltOnException.
        haltOnException - the new value.
      • setTabWidth

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

        public void clearCache()
        Clears the cache.
      • getLocalizedMessage

        private String getLocalizedMessage​(String messageKey,
                                           Object... args)
        Extracts localized messages from properties files.
        messageKey - the key pointing to localized message in respective properties file.
        args - the arguments of message in respective properties file.
        a string containing extracted localized message