public class Checker extends AutomaticBean implements MessageDispatcher, RootModule
AutomaticBean.OutputStreamOptions
Modifier and Type | Field and Description |
---|---|
static String |
EXCEPTION_MSG
Message to use when an exception occurs and should be printed as a violation.
|
Constructor and Description |
---|
Checker()
Creates a new
Checker instance. |
Modifier and Type | Method and Description |
---|---|
void |
addBeforeExecutionFileFilter(BeforeExecutionFileFilter filter)
Adds a before execution file filter to the end of the event chain.
|
void |
addFileSetCheck(FileSetCheck fileSetCheck)
Adds a FileSetCheck to the list of FileSetChecks
that is executed in process().
|
void |
addFilter(Filter filter)
Adds a filter to the end of the audit event filter chain.
|
void |
addListener(AuditListener listener)
Add the listener that will be used to receive events from the audit.
|
void |
clearCache()
Clears the cache.
|
void |
destroy()
Cleans up the object.
|
protected void |
finishLocalSetup()
Provides a hook to finish the part of this component's setup that
was not handled by the bean introspection.
|
void |
fireErrors(String fileName,
SortedSet<LocalizedMessage> errors)
Notify all listeners about the errors in a file.
|
void |
fireFileFinished(String fileName)
Notify all listeners about the end of a file audit.
|
void |
fireFileStarted(String fileName)
Notify all listeners about the beginning of a file audit.
|
int |
process(List<File> files)
Processes a set of files.
|
void |
removeBeforeExecutionFileFilter(BeforeExecutionFileFilter filter)
Removes before execution file filter.
|
void |
removeFilter(Filter filter)
Removes filter.
|
void |
removeListener(AuditListener listener)
Removes a given listener.
|
void |
setBasedir(String basedir)
Sets base directory.
|
void |
setCacheFile(String fileName)
Sets cache file.
|
void |
setCharset(String charset)
Sets a named charset.
|
void |
setClassLoader(ClassLoader classLoader)
Sets the classloader that is used to contextualize fileset checks.
|
void |
setFileExtensions(String... extensions)
Sets the file extensions that identify the files that pass the
filter of this FileSetCheck.
|
void |
setHaltOnException(boolean haltOnException)
Sets the field haltOnException.
|
void |
setLocaleCountry(String localeCountry)
Sets locale country.
|
void |
setLocaleLanguage(String localeLanguage)
Sets locale language.
|
void |
setModuleClassLoader(ClassLoader moduleClassLoader)
Sets the classloader used to load Checkstyle core and custom module
classes when the module tree is being built up.
|
void |
setModuleFactory(ModuleFactory moduleFactory)
Sets the factory for creating submodules.
|
void |
setSeverity(String severity)
Sets the severity level.
|
protected void |
setupChild(Configuration childConf)
Called by configure() for every child of this component's Configuration.
|
configure, contextualize, getConfiguration
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
configure
public static final String EXCEPTION_MSG
public Checker()
Checker
instance.
The instance needs to be contextualized and configured.public void setCacheFile(String fileName) throws IOException
fileName
- the cache file.IOException
- if there are some problems with file loading.public void removeBeforeExecutionFileFilter(BeforeExecutionFileFilter filter)
filter
- before execution file filter to remove.public void removeFilter(Filter filter)
filter
- filter to remove.public void destroy()
RootModule
destroy
in interface RootModule
public void removeListener(AuditListener listener)
listener
- a listener to removepublic void setBasedir(String basedir)
basedir
- the base directory to strip off in file namespublic int process(List<File> files) throws CheckstyleException
RootModule
process
in interface RootModule
files
- the list of files to be audited.CheckstyleException
- if error condition within Checkstyle occursRootModule.destroy()
public void fireFileStarted(String fileName)
fireFileStarted
in interface MessageDispatcher
fileName
- the file to be auditedpublic void fireErrors(String fileName, SortedSet<LocalizedMessage> errors)
fireErrors
in interface MessageDispatcher
fileName
- the audited fileerrors
- the audit errors from the filepublic void fireFileFinished(String fileName)
fireFileFinished
in interface MessageDispatcher
fileName
- the audited fileprotected void finishLocalSetup() throws CheckstyleException
AutomaticBean
The default implementation does nothing.
finishLocalSetup
in class AutomaticBean
CheckstyleException
- if there is a configuration error.protected void setupChild(Configuration childConf) throws CheckstyleException
The default implementation throws CheckstyleException
if
childConf
is null
because it doesn't support children. It
must be overridden to validate and support children that are wanted.
setupChild
in class AutomaticBean
childConf
- a child of this component's ConfigurationCheckstyleException
- if there is a configuration error.Configuration.getChildren()
public void addFileSetCheck(FileSetCheck fileSetCheck)
fileSetCheck
- the additional FileSetCheckpublic void addBeforeExecutionFileFilter(BeforeExecutionFileFilter filter)
filter
- the additional filterpublic void addFilter(Filter filter)
filter
- the additional filterpublic final void addListener(AuditListener listener)
RootModule
addListener
in interface RootModule
listener
- the nosy thingpublic final void setFileExtensions(String... extensions)
extensions
- the set of file extensions. A missing
initial '.' character of an extension is automatically added.public void setModuleFactory(ModuleFactory moduleFactory)
moduleFactory
- the factory for creating FileSetCheckspublic void setLocaleCountry(String localeCountry)
localeCountry
- the country to report messagespublic void setLocaleLanguage(String localeLanguage)
localeLanguage
- the language to report messagespublic final void setSeverity(String severity)
SeverityLevel
class.severity
- The new severity levelSeverityLevel
public final void setClassLoader(ClassLoader classLoader)
classLoader
- the new classloaderpublic final void setModuleClassLoader(ClassLoader moduleClassLoader)
RootModule
setModuleClassLoader
in interface RootModule
moduleClassLoader
- the classloader used to load module classespublic void setCharset(String charset) throws UnsupportedEncodingException
charset
- the name of a charsetUnsupportedEncodingException
- if charset is unsupported.public void setHaltOnException(boolean haltOnException)
haltOnException
- the new value.public void clearCache()
Copyright © 2001–2018. All rights reserved.