com.puppycrawl.tools.checkstyle.api

Class AbstractFileSetCheck

public abstract class AbstractFileSetCheck extends AbstractViolationReporter implements FileSetCheck

Provides common functionality for many FileSetChecks.

Author: lkuehne

Method Summary
voiddestroy()
protected File[]filter(File[] aFiles)
Determines the set of files this FileSetCheck is interested in.
protected voidfireErrors(String aFileName)
Notify all listeners about the errors in a file.
StringgetCharset()
protected LocalizedMessagesgetMessageCollector()
Returns the collector for violation messages.
protected MessageDispatchergetMessageDispatcher()
A message dispatcher is used to fire violation messages to interested audit listeners.
protected voidlog(int aLine, String aKey, Object[] aArgs)
Adds a violation message to the {@link #getMessageCollector message collector}.
protected voidlog(int aLineNo, int aColNo, String aKey, Object[] aArgs)
Adds a violation message to the {@link #getMessageCollector message collector}.
voidsetCharset(String aCharset)
Sets a named charset.
voidsetFileExtensions(String[] aExtensions)
Sets the file extensions that identify the files that pass the filter of this FileSetCheck.
voidsetMessageDispatcher(MessageDispatcher aDispatcher)
{@inheritDoc}

Method Detail

destroy

public void destroy()

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

See Also: FileSetCheck

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, Object[] aArgs)
Adds a violation message to the {@link #getMessageCollector message collector}. {@inheritDoc}

log

protected final void log(int aLineNo, int aColNo, String aKey, Object[] aArgs)
Adds a violation message to the {@link #getMessageCollector message collector}. {@inheritDoc}

setCharset

public void setCharset(String aCharset)
Sets a named charset.

Parameters: aCharset the name of a charset

Throws: UnsupportedEncodingException if aCharset is unsupported.

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)
{@inheritDoc}