Class AbstractHeaderCheck
java.lang.Object
com.puppycrawl.tools.checkstyle.api.AutomaticBean
com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck
com.puppycrawl.tools.checkstyle.checks.header.AbstractHeaderCheck
- All Implemented Interfaces:
Configurable
,Contextualizable
,ExternalResourceHolder
,FileSetCheck
- Direct Known Subclasses:
HeaderCheck
,RegexpHeaderCheck
public abstract class AbstractHeaderCheck
extends AbstractFileSetCheck
implements ExternalResourceHolder
Abstract super class for header checks.
Provides support for header and headerFile properties.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
AutomaticBean.OutputStreamOptions
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
Provides a hook to finish the part of this component's setup that was not handled by the bean introspection.Returns a set of external configuration resource locations which are used by the module.Return the header lines to check against.protected abstract void
Hook method for post processing header lines.void
setCharset
(String charset) Setter to specify the character encoding to use when reading the headerFile.void
Set the header to check against.void
setHeaderFile
(URI uri) Setter to specify the name of the file containing the required header..Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck
addMessages, beginProcessing, destroy, finishProcessing, fireErrors, getFileContents, getFileExtensions, getMessageDispatcher, getMessages, getTabWidth, init, log, log, process, processFiltered, setFileContents, setFileExtensions, setMessageDispatcher, setTabWidth
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverity
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
configure, contextualize, getConfiguration, setupChild
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.puppycrawl.tools.checkstyle.api.Configurable
configure
Methods inherited from interface com.puppycrawl.tools.checkstyle.api.Contextualizable
contextualize
-
Constructor Details
-
AbstractHeaderCheck
public AbstractHeaderCheck()
-
-
Method Details
-
postProcessHeaderLines
protected abstract void postProcessHeaderLines()Hook method for post processing header lines. This implementation does nothing. -
getHeaderLines
Return the header lines to check against.- Returns:
- the header lines to check against.
-
setCharset
Setter to specify the character encoding to use when reading the headerFile.- Parameters:
charset
- the charset to use for loading the header from a file- Throws:
UnsupportedEncodingException
- if charset is unsupported
-
setHeaderFile
Setter to specify the name of the file containing the required header..- Parameters:
uri
- the uri of the header to load.- Throws:
CheckstyleException
- if fileName is empty.
-
setHeader
Set the header to check against. Individual lines in the header must be separated by '\n' characters.- Parameters:
header
- header content to check against.- Throws:
IllegalArgumentException
- if the header cannot be interpreted
-
finishLocalSetup
Description copied from class:AutomaticBean
Provides a hook to finish the part of this component's setup that was not handled by the bean introspection.The default implementation does nothing.
- Overrides:
finishLocalSetup
in classAbstractViolationReporter
- Throws:
CheckstyleException
- if there is a configuration error.
-
getExternalResourceLocations
Description copied from interface:ExternalResourceHolder
Returns a set of external configuration resource locations which are used by the module. ATTENTION! If 'getExternalResourceLocations()' return null, there will beNullPointerException
inChecker
. Such behaviour will signal that your module (check or filter) is designed incorrectly. It make sense to return an empty set from 'getExternalResourceLocations()' only for composite modules likeTreeWalker
.- Specified by:
getExternalResourceLocations
in interfaceExternalResourceHolder
- Returns:
- a set of external configuration resource locations which are used by the module.
-