Class AbstractHeaderCheck
java.lang.Object
com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
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.AbstractAutomaticBean
AbstractAutomaticBean.OutputStreamOptions -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidCalled before initializing the header.private static CharsetcreateCharset(String name) Creates charset by name.protected final voidProvides 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.private voidloadHeader(Reader headerReader) Load header to check against from a Reader into readerLines.private voidLoad the header from a file.protected abstract voidHook method for post-processing header lines.voidsetCharset(String charset) Setter to specify the character encoding to use when reading the headerFile.voidSpecify the required header specified inline.voidsetHeaderFile(URI uri) Setter to specify the name of the file containing the required header.Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck
addViolations, beginProcessing, destroy, finishProcessing, fireErrors, getFileContents, getFileExtensions, getMessageDispatcher, getTabWidth, getViolations, init, log, log, process, processFiltered, setFileContents, setFileExtensions, setMessageDispatcher, setTabWidthMethods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverityMethods inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
configure, contextualize, getConfiguration, setupChildMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.puppycrawl.tools.checkstyle.api.Configurable
configureMethods inherited from interface com.puppycrawl.tools.checkstyle.api.Contextualizable
contextualize
-
Field Details
-
ESCAPED_LINE_FEED_PATTERN
Pattern to detect occurrences of '\n' in text. -
readerLines
The lines of the header file. -
headerFile
Specify the name of the file containing the required header. -
charset
Specify the character encoding to use when reading the headerFile.
-
-
Constructor Details
-
AbstractHeaderCheck
public AbstractHeaderCheck()
-
-
Method Details
-
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 name to use for loading the header from a file
-
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.
-
loadHeaderFile
Load the header from a file.- Throws:
CheckstyleException- if the file cannot be loaded
-
checkHeaderNotInitialized
Called before initializing the header.- Throws:
IllegalArgumentException- if header has already been set
-
createCharset
Creates charset by name.- Parameters:
name- charset name- Returns:
- created charset
- Throws:
UnsupportedCharsetException- if charset is unsupported
-
setHeader
Specify the required header specified inline. Individual header lines must be separated by the string"\n"(even on platforms with a different line separator).- Parameters:
header- header content to check against.- Throws:
IllegalArgumentException- if the header cannot be interpreted
-
loadHeader
Load header to check against from a Reader into readerLines.- Parameters:
headerReader- delivers the header to check against- Throws:
IOException- if
-
finishLocalSetup
Description copied from class:AbstractAutomaticBeanProvides 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:
finishLocalSetupin classAbstractViolationReporter- Throws:
CheckstyleException- if there is a configuration error.
-
getExternalResourceLocations
Description copied from interface:ExternalResourceHolderReturns a set of external configuration resource locations which are used by the module. ATTENTION! If 'getExternalResourceLocations()' return null, there will beNullPointerExceptioninChecker. Such behaviour will signal that your module (check or filter) is designed incorrectly. It makes sense to return an empty set from 'getExternalResourceLocations()' only for composite modules likeTreeWalker.- Specified by:
getExternalResourceLocationsin interfaceExternalResourceHolder- Returns:
- a set of external configuration resource locations which are used by the module.
-