public abstract class AbstractFileSetCheck extends AbstractViolationReporter implements FileSetCheck
| Modifier and Type | Class and Description |
|---|---|
private static class |
AbstractFileSetCheck.FileContext
The actual context holder.
|
AutomaticBean.OutputStreamOptions| Modifier and Type | Field and Description |
|---|---|
private java.lang.ThreadLocal<AbstractFileSetCheck.FileContext> |
context
The check context.
|
private java.lang.String[] |
fileExtensions
Specify the file type extension of files to process.
|
private MessageDispatcher |
messageDispatcher
The dispatcher errors are fired to.
|
private int |
tabWidth
The tab width for column reporting.
|
| Constructor and Description |
|---|
AbstractFileSetCheck() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addViolations(java.util.SortedSet<Violation> violations)
Adds the sorted set of
Violation to the message collector. |
void |
beginProcessing(java.lang.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(java.lang.String fileName)
Notify all listeners about the errors in a file.
|
protected FileContents |
getFileContents()
Returns the file contents associated with the file.
|
java.lang.String[] |
getFileExtensions()
Makes copy of file extensions and returns them.
|
protected MessageDispatcher |
getMessageDispatcher()
A message dispatcher is used to fire violations to
interested audit listeners.
|
protected int |
getTabWidth()
Get tab width to report audit events with.
|
java.util.SortedSet<Violation> |
getViolations()
Returns the sorted set of
Violation. |
void |
init()
Initialise the instance.
|
void |
log(int lineNo,
int colNo,
java.lang.String key,
java.lang.Object... args)
Log a message that has column information.
|
void |
log(int line,
java.lang.String key,
java.lang.Object... args)
Log a message that has no column information.
|
java.util.SortedSet<Violation> |
process(java.io.File file,
FileText fileText)
Request to process a file.
|
protected abstract void |
processFiltered(java.io.File file,
FileText fileText)
Called to process a file that matches the specified file extensions.
|
void |
setFileContents(FileContents contents)
Set the file contents associated with the tree.
|
void |
setFileExtensions(java.lang.String... extensions)
Setter to specify the file type extension of files to process.
|
void |
setMessageDispatcher(MessageDispatcher messageDispatcher)
Sets the MessageDispatcher that is used to dispatch audit events
to AuditListeners during processing.
|
void |
setTabWidth(int tabWidth)
Set the tab width to report audit events with.
|
finishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverityconfigure, contextualize, getConfiguration, setupChildclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitconfigurecontextualizeprivate final java.lang.ThreadLocal<AbstractFileSetCheck.FileContext> context
private MessageDispatcher messageDispatcher
private java.lang.String[] fileExtensions
private int tabWidth
public AbstractFileSetCheck()
protected abstract void processFiltered(java.io.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()
FileSetCheckinit in interface FileSetCheckpublic void destroy()
FileSetCheckdestroy in interface FileSetCheckpublic void beginProcessing(java.lang.String charset)
FileSetCheckbeginProcessing in interface FileSetCheckcharset - the character set used to read the files.public final java.util.SortedSet<Violation> process(java.io.File file, FileText fileText) throws CheckstyleException
FileSetCheckThe file set to process might contain files that are not interesting to the FileSetCheck. Such files should be ignored, no audit event 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 violations to be logged.
process in interface FileSetCheckfile - the file to be processedfileText - the contents of the file.CheckstyleException - if error condition within Checkstyle occurspublic void finishProcessing()
FileSetCheckfinishProcessing in interface FileSetCheckpublic final void setMessageDispatcher(MessageDispatcher messageDispatcher)
FileSetChecksetMessageDispatcher in interface FileSetCheckmessageDispatcher - the dispatcherprotected final MessageDispatcher getMessageDispatcher()
public java.util.SortedSet<Violation> getViolations()
Violation.Violation.public final void setFileContents(FileContents contents)
contents - the managerprotected final FileContents getFileContents()
public java.lang.String[] getFileExtensions()
public final void setFileExtensions(java.lang.String... extensions)
extensions - the set of file extensions. A missing
initial '.' character of an extension is automatically added.java.lang.IllegalArgumentException - is argument is nullprotected final int getTabWidth()
public final void setTabWidth(int tabWidth)
tabWidth - an int valueprotected void addViolations(java.util.SortedSet<Violation> violations)
Violation to the message collector.violations - the sorted set of Violation.public final void log(int line, java.lang.String key, java.lang.Object... args)
AbstractViolationReporterlog in class AbstractViolationReporterline - the line number where the audit event was foundkey - the message that describes the audit eventargs - the details of the messageMessageFormatpublic final void log(int lineNo, int colNo, java.lang.String key, java.lang.Object... args)
AbstractViolationReporterlog in class AbstractViolationReporterlineNo - the line number where the audit event was foundcolNo - the column number where the audit event was foundkey - the message that describes the audit eventargs - the details of the messageMessageFormatprotected final void fireErrors(java.lang.String fileName)
MessageDispatcher.fireErrors() with
all logged errors and then clears errors' list.fileName - the audited fileCopyright © 2001-2022. All Rights Reserved.