## com.puppycrawl.tools.checkstyle
Class Checker

    java.lang.Object
      com.puppycrawl.tools.checkstyle.api.AutomaticBean
          com.puppycrawl.tools.checkstyle.Checker

All Implemented Interfaces:
  Configurable, Contextualizable, MessageDispatcher

    public class Checker

extends AutomaticBean
implements MessageDispatcher

This class provides the functionality to check a set of files.

Author:
  Oliver Burn, Stephane Bailliez, lkuehne

Constructor Summary
`Checker()` Creates a new `Checker` instance.

Method Summary
`void` `addFileSetCheck(FileSetCheck aFileSetCheck)` Adds a FileSetCheck to the list of FileSetChecks that is executed in process().
`void` `addFilter(Filter aFilter)` Adds a filter to the end of the audit event filter chain.
`void` `addListener(AuditListener aListener)` Add the listener that will be used to receive events from the audit.
`void` `destroy()` Cleans up the object.
`void` `finishLocalSetup()` Provides a hook to finish the part of this component's setup that was not handled by the bean introspection.
`protected void` `fireAuditFinished()` notify all listeners about the audit end
`protected void` `fireAuditStarted()` notify all listeners about the audit start
`void` `fireErrors(String aFileName, TreeSet<LocalizedMessage> aErrors)` notify all listeners about the errors in a file.
`void` `fireFileFinished(String aFileName)` Notify all listeners about the end of a file audit.
`void` `fireFileStarted(String aFileName)` Notify all listeners about the beginning of a file audit.
`String` `getBasedir()`
`String` `normalize(String aPath)` "normalize" the given absolute path.
`int` `process(List<File> aFiles)` Processes a set of files with all FileSetChecks.
`void` `removeFilter(Filter aFilter)` Removes filter.
`void` `removeListener(AuditListener aListener)` Removes a given listener.
`void` `setBasedir(String aBasedir)`
`void` `setCharset(String aCharset)` Sets a named charset.
`void` `setClassloader(ClassLoader aLoader)` Sets the classloader that is used to contextualize filesetchecks.
`void` `setLocaleCountry(String aLocaleCountry)`
`void` `setLocaleLanguage(String aLocaleLanguage)`
`void` `setModuleClassLoader(ClassLoader aModuleClassLoader)` Sets the classloader used to load Checkstyle core and custom module classes when the module tree is being built up.
`void` `setModuleFactory(ModuleFactory aModuleFactory)` Sets the factory for creating submodules.
`void` `setSeverity(String aSeverity)` Sets the severity level.
`protected void` `setupChild(Configuration aChildConf)` Called by configure() for every child of this component's Configuration.

Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
`configure, contextualize, getConfiguration`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Checker

    public Checker()
            throws CheckstyleException

  Creates a new `Checker` instance. The instance needs to be contextualized and configured.

  Throws:
    `CheckstyleException` - if an error occurs

Method Detail

### finishLocalSetup

    public void finishLocalSetup()
                          throws CheckstyleException

  Description copied from class: `AutomaticBean`
  Provides a hook to finish the part of this component's setup that was not handled by the bean introspection.

  The default implementation does nothing.

  Overrides:
    `finishLocalSetup` in class `AutomaticBean`
  Throws:
    `CheckstyleException` - if there is a configuration error.

### setupChild

    protected void setupChild(Configuration aChildConf)
                       throws CheckstyleException

  Description copied from class: `AutomaticBean`
  Called by configure() for every child of this component's Configuration.

  The default implementation does nothing.

  Overrides:
    `setupChild` in class `AutomaticBean`
  Parameters:
    `aChildConf` - a child of this component's Configuration
  Throws:
    `CheckstyleException` - if there is a configuration error.
  See Also:
    `Configuration.getChildren()`

### addFileSetCheck

    public void addFileSetCheck(FileSetCheck aFileSetCheck)

  Adds a FileSetCheck to the list of FileSetChecks that is executed in process().

  Parameters:
    `aFileSetCheck` - the additional FileSetCheck

### addFilter

    public void addFilter(Filter aFilter)

  Adds a filter to the end of the audit event filter chain.

  Parameters:
    `aFilter` - the additional filter

### removeFilter

    public void removeFilter(Filter aFilter)

  Removes filter.

  Parameters:
    `aFilter` - filter to remove.

### destroy

    public void destroy()

  Cleans up the object.

### addListener

    public final void addListener(AuditListener aListener)

  Add the listener that will be used to receive events from the audit.

  Parameters:
    `aListener` - the nosy thing

### removeListener

    public void removeListener(AuditListener aListener)

  Removes a given listener.

  Parameters:
    `aListener` - a listener to remove

### process

    public int process(List<File> aFiles)

  Processes a set of files with all FileSetChecks. Once this is done, it is highly recommended to call for the destroy method to close and remove the listeners.

  Parameters:
    `aFiles` - the list of files to be audited.
  Returns:
    the total number of errors found
  See Also:
    `destroy()`

### setBasedir

    public void setBasedir(String aBasedir)

  Parameters:
    `aBasedir` - the base directory to strip off in filenames

### normalize

    public String normalize(String aPath)

  "normalize" the given absolute path.

  This includes:

  - Uppercase the drive letter if there is one.
  - Remove redundant slashes after the drive spec.
  - resolve all ./, .\, ../ and ..\ sequences.
  - DOS style paths that start with a drive letter will have \ as the separator.

  Parameters:
    `aPath` - a path for "normalizing"
  Returns:
    "normalized" file name
  Throws:
    `NullPointerException` - if the file path is equal to null.

### getBasedir

    public final String getBasedir()

  Returns:
    the base directory property used in unit-test.

### fireAuditStarted

    protected void fireAuditStarted()

  notify all listeners about the audit start

### fireAuditFinished

    protected void fireAuditFinished()

  notify all listeners about the audit end

### fireFileStarted

    public void fireFileStarted(String aFileName)

  Notify all listeners about the beginning of a file audit.

  Specified by:
    `fireFileStarted` in interface `MessageDispatcher`
  Parameters:
    `aFileName` - the file to be audited

### fireFileFinished

    public void fireFileFinished(String aFileName)

  Notify all listeners about the end of a file audit.

  Specified by:
    `fireFileFinished` in interface `MessageDispatcher`
  Parameters:
    `aFileName` - the audited file

### fireErrors

    public void fireErrors(String aFileName,
                           TreeSet<LocalizedMessage> aErrors)

  notify all listeners about the errors in a file.

  Specified by:
    `fireErrors` in interface `MessageDispatcher`
  Parameters:
    `aFileName` - the audited file
    `aErrors` - the audit errors from the file

### setModuleFactory

    public void setModuleFactory(ModuleFactory aModuleFactory)

  Sets the factory for creating submodules.

  Parameters:
    `aModuleFactory` - the factory for creating FileSetChecks

### setLocaleCountry

    public void setLocaleCountry(String aLocaleCountry)

  Parameters:
    `aLocaleCountry` - the country to report messages

### setLocaleLanguage

    public void setLocaleLanguage(String aLocaleLanguage)

  Parameters:
    `aLocaleLanguage` - the language to report messages

### setSeverity

    public final void setSeverity(String aSeverity)

  Sets the severity level. The string should be one of the names defined in the `SeverityLevel` class.

  Parameters:
    `aSeverity` - The new severity level
  See Also:
    `SeverityLevel`

### setClassloader

    public final void setClassloader(ClassLoader aLoader)

  Sets the classloader that is used to contextualize filesetchecks. Some Check implementations will use that classloader to improve the quality of their reports, e.g. to load a class and then analyze it via reflection.

  Parameters:
    `aLoader` - the new classloader

### setModuleClassLoader

    public final void setModuleClassLoader(ClassLoader aModuleClassLoader)

  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 Checker module then this module classloader must be specified.

  Parameters:
    `aModuleClassLoader` - the classloader used to load module classes

### setCharset

    public void setCharset(String aCharset)
                    throws UnsupportedEncodingException

  Sets a named charset.

  Parameters:
    `aCharset` - the name of a charset
  Throws:
    `UnsupportedEncodingException` - if aCharset is unsupported.

Copyright © 2001-2011. All Rights Reserved.