Class AbstractFileSetCheck
java.lang.Object
com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck
- All Implemented Interfaces:
- Configurable,- Contextualizable,- FileSetCheck
- Direct Known Subclasses:
- AbstractHeaderCheck,- FileLengthCheck,- FileTabCharacterCheck,- JavadocPackageCheck,- LineLengthCheck,- MultiFileRegexpHeaderCheck,- NewlineAtEndOfFileCheck,- OrderedPropertiesCheck,- RegexpMultilineCheck,- RegexpOnFilenameCheck,- RegexpSinglelineCheck,- TranslationCheck,- TreeWalker,- UniquePropertiesCheck
public abstract class AbstractFileSetCheck
extends AbstractViolationReporter
implements FileSetCheck
Provides common functionality for many FileSetChecks.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprivate static final classThe actual context holder.Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBeanAbstractAutomaticBean.OutputStreamOptions
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprivate final ThreadLocal<AbstractFileSetCheck.FileContext>The check context.private static final StringThe extension separator.private String[]Specify the file extensions of the files to process.private MessageDispatcherThe dispatcher errors are fired to.private intThe tab width for column reporting.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidaddViolations(SortedSet<Violation> violations) Adds the sorted set ofViolationto the message collector.voidbeginProcessing(String charset) Called when about to be called to process a set of files.voiddestroy()Cleans up the object.voidCalled when all the files have been processed.protected final voidfireErrors(String fileName) Notify all listeners about the errors in a file.protected final FileContentsReturns the file contents associated with the file.String[]Makes copy of file extensions and returns them.protected final MessageDispatcherA message dispatcher is used to fire violations to interested audit listeners.protected final intGet tab width to report audit events with.Returns the sorted set ofViolation.voidinit()Initialise the instance.final voidLog a message that has column information.final voidLog a message that has no column information.Request to process a file.protected abstract voidprocessFiltered(File file, FileText fileText) Called to process a file that matches the specified file extensions.final voidsetFileContents(FileContents contents) Set the file contents associated with the tree.voidsetFileExtensions(String... extensions) Setter to specify the file extensions of the files to process.final voidsetMessageDispatcher(MessageDispatcher messageDispatcher) Sets the MessageDispatcher that is used to dispatch audit events to AuditListeners during processing.final voidsetTabWidth(int tabWidth) Set the tab width to report audit events with.Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporterfinishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverityMethods inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBeanconfigure, contextualize, getConfiguration, setupChildMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.puppycrawl.tools.checkstyle.api.ConfigurableconfigureMethods inherited from interface com.puppycrawl.tools.checkstyle.api.Contextualizablecontextualize
- 
Field Details- 
EXTENSION_SEPARATORThe extension separator.- See Also:
 
- 
contextThe check context.
- 
messageDispatcherThe dispatcher errors are fired to.
- 
fileExtensionsSpecify the file extensions of the files to process. Default is uninitialized as the value is inherited from the parent module.
- 
tabWidthThe tab width for column reporting. Default is uninitialized as the value is inherited from the parent module.
 
- 
- 
Constructor Details- 
AbstractFileSetCheckpublic AbstractFileSetCheck()
 
- 
- 
Method Details- 
processFilteredCalled to process a file that matches the specified file extensions.- Parameters:
- file- the file to be processed
- fileText- the contents of the file.
- Throws:
- CheckstyleException- if error condition within Checkstyle occurs.
 
- 
initDescription copied from interface:FileSetCheckInitialise the instance. This is the time to verify that everything required to perform its job.- Specified by:
- initin interface- FileSetCheck
 
- 
destroyDescription copied from interface:FileSetCheckCleans up the object.- Specified by:
- destroyin interface- FileSetCheck
 
- 
beginProcessingDescription copied from interface:FileSetCheckCalled when about to be called to process a set of files.- Specified by:
- beginProcessingin interface- FileSetCheck
- Parameters:
- charset- the character set used to read the files.
 
- 
processDescription copied from interface:FileSetCheckRequest to process a file. The implementation should use the supplied contents and not read the contents again. This reduces the amount of file I/O.The 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. - Specified by:
- processin interface- FileSetCheck
- Parameters:
- file- the file to be processed
- fileText- the contents of the file.
- Returns:
- the sorted set of violations to be logged.
- Throws:
- CheckstyleException- if error condition within Checkstyle occurs
 
- 
finishProcessingDescription copied from interface:FileSetCheckCalled when all the files have been processed. This is the time to perform any checks that need to be done across a set of files. In this method, the implementation is responsible for the logging of violations.- Specified by:
- finishProcessingin interface- FileSetCheck
 
- 
setMessageDispatcherDescription copied from interface:FileSetCheckSets the MessageDispatcher that is used to dispatch audit events to AuditListeners during processing.- Specified by:
- setMessageDispatcherin interface- FileSetCheck
- Parameters:
- messageDispatcher- the dispatcher
 
- 
getMessageDispatcherA message dispatcher is used to fire violations to interested audit listeners.- Returns:
- the current MessageDispatcher.
 
- 
getViolationsReturns the sorted set ofViolation.- Returns:
- the sorted set of Violation.
 
- 
setFileContentsSet the file contents associated with the tree.- Parameters:
- contents- the manager
 
- 
getFileContentsReturns the file contents associated with the file.- Returns:
- the file contents
 
- 
getFileExtensionsMakes copy of file extensions and returns them.- Returns:
- file extensions that identify the files that pass the filter of this FileSetCheck.
 
- 
setFileExtensionsSetter to specify the file extensions of the files to process.- Parameters:
- extensions- the set of file extensions. A missing initial '.' character of an extension is automatically added.
- Throws:
- IllegalArgumentException- is argument is null
 
- 
getTabWidthGet tab width to report audit events with.- Returns:
- the tab width to report audit events with
 
- 
setTabWidthSet the tab width to report audit events with.- Parameters:
- tabWidth- an- intvalue
 
- 
addViolationsAdds the sorted set ofViolationto the message collector.- Parameters:
- violations- the sorted set of- Violation.
 
- 
logDescription copied from class:AbstractViolationReporterLog a message that has no column information.- Specified by:
- login class- AbstractViolationReporter
- Parameters:
- line- the line number where the audit event was found
- key- the message that describes the audit event
- args- the details of the message
- See Also:
 
- 
logDescription copied from class:AbstractViolationReporterLog a message that has column information.- Specified by:
- login class- AbstractViolationReporter
- Parameters:
- lineNo- the line number where the audit event was found
- colNo- the column number where the audit event was found
- key- the message that describes the audit event
- args- the details of the message
- See Also:
 
- 
fireErrorsNotify all listeners about the errors in a file. CallsMessageDispatcher.fireErrors()with all logged errors and then clears errors' list.- Parameters:
- fileName- the audited file
 
 
-