com.puppycrawl.tools.checkstyle.api

Class AbstractFileSetCheck

Implemented Interfaces:
Configurable, Contextualizable, FileSetCheck
Known Direct Subclasses:
CrossLanguageRegexpHeaderCheck, NewlineAtEndOfFileCheck, PackageHtmlCheck, StrictDuplicateCodeCheck, TranslationCheck, TreeWalker

public abstract class AbstractFileSetCheck
extends AbstractViolationReporter
implements FileSetCheck

Provides common functionality for many FileSetChecks.
Author:
lkuehne

Method Summary

void
destroy()
protected File[]
filter(File[] aFiles)
Determines the set of files this FileSetCheck is interested in.
protected void
fireErrors(String aFileName)
Notify all listeners about the errors in a file.
String
getCharset()
protected LocalizedMessages
getMessageCollector()
Returns the collector for violation messages.
protected MessageDispatcher
getMessageDispatcher()
A message dispatcher is used to fire violation messages to interested audit listeners.
protected void
log(int aLine, String aKey, aArgs[] )
Adds a violation message to the message collector.
protected void
log(int aLineNo, int aColNo, String aKey, Object[] aArgs)
Adds a violation message to the message collector.
void
setCharset(String aCharset)
Sets a named charset.
void
setFileExtensions(String[] aExtensions)
Sets the file extensions that identify the files that pass the filter of this FileSetCheck.
void
setMessageDispatcher(MessageDispatcher aDispatcher)

Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter

getId, getMessageBundle, getSeverity, getSeverityLevel, log, log, log, log, log, log, log, log, log, log, log, setId, setSeverity

Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean

configure, contextualize, finishLocalSetup, getConfiguration, setupChild

Method Details

destroy

public void destroy()
Specified by:
destroy in interface FileSetCheck
See Also:
FileSetCheck

filter

protected final File[] filter(File[] aFiles)
Determines the set of files this FileSetCheck is interested in. Returns the files that have one of the currently active file extensions. If no file extensions are active the argument array is returned.

This method can be used in the implementation of process() to filter it's argument list for interesting files.

Parameters:
aFiles - the candidates for processing
Returns:
the subset of aFiles that this FileSetCheck should process

fireErrors

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

getCharset

public String getCharset()
Returns:
the name of the charset

getMessageCollector

protected final LocalizedMessages getMessageCollector()
Returns the collector for violation messages. Subclasses can use the collector to find out the violation messages to fire via the message dispatcher.
Returns:
the collector for localized messages.

getMessageDispatcher

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

log

protected final void log(int aLine,
                         String aKey,
                         aArgs[] )
Overrides:
log in interface AbstractViolationReporter

log

protected final void log(int aLineNo,
                         int aColNo,
                         String aKey,
                         Object[] aArgs)
Overrides:
log in interface AbstractViolationReporter

setCharset

public void setCharset(String aCharset)
            throws UnsupportedEncodingException
Sets a named charset.
Parameters:
aCharset - the name of a charset

setFileExtensions

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

setMessageDispatcher

public final void setMessageDispatcher(MessageDispatcher aDispatcher)
Specified by:
setMessageDispatcher in interface FileSetCheck