public abstract class AbstractFileSetCheck extends AbstractViolationReporter implements FileSetCheck
AutomaticBean.OutputStreamOptions
Constructor and Description |
---|
AbstractFileSetCheck() |
Modifier and Type | Method and Description |
---|---|
protected static void |
addMessages(SortedSet<LocalizedMessage> messages)
Adds the sorted set of
LocalizedMessage to the message collector. |
void |
beginProcessing(String charset)
Called when about to be called to process a set of files.
|
void |
destroy()
Cleans up the object.
|
void |
finishProcessing()
Called when all the files have been processed.
|
protected void |
fireErrors(String fileName)
Notify all listeners about the errors in a file.
|
String[] |
getFileExtensions()
Makes copy of file extensions and returns them.
|
protected MessageDispatcher |
getMessageDispatcher()
A message dispatcher is used to fire violation messages to
interested audit listeners.
|
void |
init()
Initialise the instance.
|
void |
log(int lineNo,
int colNo,
String key,
Object... args)
Log a message that has column information.
|
void |
log(int line,
String key,
Object... args)
Log a message that has no column information.
|
SortedSet<LocalizedMessage> |
process(File file,
FileText fileText)
Request to process a file.
|
protected abstract void |
processFiltered(File file,
FileText fileText)
Called to process a file that matches the specified file extensions.
|
void |
setFileExtensions(String... extensions)
Sets the file extensions that identify the files that pass the
filter of this FileSetCheck.
|
void |
setMessageDispatcher(MessageDispatcher messageDispatcher)
Sets the MessageDispatcher that is used to dispatch error
messages to AuditListeners during processing.
|
finishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverity
configure, contextualize, getConfiguration, setupChild
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
configure
contextualize
public AbstractFileSetCheck()
protected abstract void processFiltered(File file, FileText fileText) throws CheckstyleException
file
- the file to be processedfileText
- the contents of the file.CheckstyleException
- if error condition within Checkstyle occurs.public void init()
FileSetCheck
init
in interface FileSetCheck
public void destroy()
FileSetCheck
destroy
in interface FileSetCheck
public void beginProcessing(String charset)
FileSetCheck
beginProcessing
in interface FileSetCheck
charset
- the character set used to read the files.public final SortedSet<LocalizedMessage> process(File file, FileText fileText) throws CheckstyleException
FileSetCheck
The file set to process might contain files that are not interesting to the FileSetCheck. Such files should be ignored, no error message should be fired for them. For example a FileSetCheck that checks java files should ignore HTML or properties files.
The method should return the set of messages to be logged.
process
in interface FileSetCheck
file
- the file to be processedfileText
- the contents of the file.CheckstyleException
- if error condition within Checkstyle occurspublic void finishProcessing()
FileSetCheck
finishProcessing
in interface FileSetCheck
public final void setMessageDispatcher(MessageDispatcher messageDispatcher)
FileSetCheck
setMessageDispatcher
in interface FileSetCheck
messageDispatcher
- the dispatcherprotected final MessageDispatcher getMessageDispatcher()
public String[] getFileExtensions()
public final void setFileExtensions(String... extensions)
extensions
- the set of file extensions. A missing
initial '.' character of an extension is automatically added.IllegalArgumentException
- is argument is nullprotected static void addMessages(SortedSet<LocalizedMessage> messages)
LocalizedMessage
to the message collector.messages
- the sorted set of LocalizedMessage
.public final void log(int line, String key, Object... args)
AbstractViolationReporter
log
in class AbstractViolationReporter
line
- the line number where the error was foundkey
- the message that describes the errorargs
- the details of the messageMessageFormat
public final void log(int lineNo, int colNo, String key, Object... args)
AbstractViolationReporter
log
in class AbstractViolationReporter
lineNo
- the line number where the error was foundcolNo
- the column number where the error was foundkey
- the message that describes the errorargs
- the details of the messageMessageFormat
protected final void fireErrors(String fileName)
MessageDispatcher.fireErrors()
with
all logged errors and than clears errors' list.fileName
- the audited fileCopyright © 2001–2018. All rights reserved.