public class RegexpHeaderCheck extends AbstractHeaderCheck
regular expression
for each line of the source header. In default configuration,
if header is not specified, the default value of header is set to null
and the check does not rise any violations.Modifier and Type | Field and Description |
---|---|
private static int[] |
EMPTY_INT_ARRAY
Empty array to avoid instantiations.
|
private java.util.List<java.util.regex.Pattern> |
headerRegexps
The compiled regular expressions.
|
static java.lang.String |
MSG_HEADER_MISMATCH
A key is pointing to the warning message text in "messages.properties"
file.
|
static java.lang.String |
MSG_HEADER_MISSING
A key is pointing to the warning message text in "messages.properties"
file.
|
private int[] |
multiLines
The header lines to repeat (0 or more) in the check, sorted.
|
Constructor and Description |
---|
RegexpHeaderCheck() |
Modifier and Type | Method and Description |
---|---|
private boolean |
isMatch(java.lang.String line,
int headerLineNo)
Checks if a code line matches the required header line.
|
private boolean |
isMultiLine(int lineNo)
Returns true if line is multiline header lines or false.
|
private void |
logFirstSinglelineLine(int startHeaderLine,
int headerSize)
Logs warning if any non-multiline lines left in header regexp.
|
protected void |
postProcessHeaderLines()
Hook method for post processing header lines.
|
protected void |
processFiltered(java.io.File file,
java.util.List<java.lang.String> lines)
Called to process a file that matches the specified file extensions.
|
void |
setHeader(java.lang.String header)
Validates the
header by compiling it with
Pattern.compile(String) and throws
IllegalArgumentException if header isn't a valid pattern. |
void |
setMultiLines(int... list)
Set the lines numbers to repeat in the header check.
|
finishLocalSetup, getExternalResourceLocations, getHeaderLines, setCharset, setHeaderFile
beginProcessing, destroy, finishProcessing, fireErrors, getFileExtensions, getMessageCollector, getMessageDispatcher, init, log, log, process, 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
public static final java.lang.String MSG_HEADER_MISSING
public static final java.lang.String MSG_HEADER_MISMATCH
private static final int[] EMPTY_INT_ARRAY
private final java.util.List<java.util.regex.Pattern> headerRegexps
private int[] multiLines
public void setMultiLines(int... list)
list
- comma separated list of line numbers to repeat in header.protected void processFiltered(java.io.File file, java.util.List<java.lang.String> lines)
AbstractFileSetCheck
processFiltered
in class AbstractFileSetCheck
file
- the file to be processedlines
- an immutable list of the contents of the file.private void logFirstSinglelineLine(int startHeaderLine, int headerSize)
startHeaderLine
- header line number to start fromheaderSize
- whole header sizeprivate boolean isMatch(java.lang.String line, int headerLineNo)
line
- the code lineheaderLineNo
- the header line number.private boolean isMultiLine(int lineNo)
lineNo
- a line numberlineNo
is one of the repeat header lines.protected void postProcessHeaderLines()
AbstractHeaderCheck
postProcessHeaderLines
in class AbstractHeaderCheck
public void setHeader(java.lang.String header)
header
by compiling it with
Pattern.compile(String)
and throws
IllegalArgumentException
if header
isn't a valid pattern.setHeader
in class AbstractHeaderCheck
header
- the header value to validate and set (in that order)