public abstract class AbstractHeaderCheck extends AbstractFileSetCheck implements ExternalResourceHolder
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
charset
Name of a charset to use for loading the header from a file.
|
private static java.util.regex.Pattern |
ESCAPED_LINE_FEED_PATTERN
Pattern to detect occurrences of '\n' in text.
|
private java.net.URI |
headerFile
The file that contains the header to check against.
|
private java.util.List<java.lang.String> |
readerLines
The lines of the header file.
|
Constructor and Description |
---|
AbstractHeaderCheck() |
Modifier and Type | Method and Description |
---|---|
private void |
checkHeaderNotInitialized()
Called before initializing the header.
|
protected void |
finishLocalSetup()
Provides a hook to finish the part of this component's setup that
was not handled by the bean introspection.
|
java.util.Set<java.lang.String> |
getExternalResourceLocations()
Returns a set of external configuration resource locations which are used by the module.
|
protected java.util.List<java.lang.String> |
getHeaderLines()
Return the header lines to check against.
|
private void |
loadHeader(java.io.Reader headerReader)
Load header to check against from a Reader into readerLines.
|
private void |
loadHeaderFile()
Load the header from a file.
|
protected abstract void |
postProcessHeaderLines()
Hook method for post processing header lines.
|
void |
setCharset(java.lang.String charset)
Set the charset to use for loading the header from a file.
|
void |
setHeader(java.lang.String header)
Set the header to check against.
|
void |
setHeaderFile(java.net.URI uri)
Set the header file to check against.
|
beginProcessing, destroy, finishProcessing, fireErrors, getFileExtensions, getMessageCollector, getMessageDispatcher, init, log, log, process, processFiltered, setFileExtensions, setMessageDispatcher
getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, log, setId, setSeverity
configure, contextualize, getConfiguration, setupChild
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
configure
contextualize
private static final java.util.regex.Pattern ESCAPED_LINE_FEED_PATTERN
private final java.util.List<java.lang.String> readerLines
private java.net.URI headerFile
private java.lang.String charset
protected abstract void postProcessHeaderLines()
protected java.util.List<java.lang.String> getHeaderLines()
public void setCharset(java.lang.String charset) throws java.io.UnsupportedEncodingException
charset
- the charset to use for loading the header from a filejava.io.UnsupportedEncodingException
- if charset is unsupportedpublic void setHeaderFile(java.net.URI uri) throws CheckstyleException
uri
- the uri of the header to load.CheckstyleException
- if fileName is empty.private void loadHeaderFile() throws CheckstyleException
CheckstyleException
- if the file cannot be loadedprivate void checkHeaderNotInitialized()
java.lang.IllegalArgumentException
- if header has already been setpublic void setHeader(java.lang.String header)
header
- header content to check against.java.lang.IllegalArgumentException
- if the header cannot be interpretedprivate void loadHeader(java.io.Reader headerReader) throws java.io.IOException
headerReader
- delivers the header to check againstjava.io.IOException
- ifprotected final void finishLocalSetup() throws CheckstyleException
AutomaticBean
The default implementation does nothing.
finishLocalSetup
in class AutomaticBean
CheckstyleException
- if there is a configuration error.public java.util.Set<java.lang.String> getExternalResourceLocations()
ExternalResourceHolder
NullPointerException
in Checker
.
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 like TreeWalker
.getExternalResourceLocations
in interface ExternalResourceHolder