Class RegexpMultilineCheck
- 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.regexp.RegexpMultilineCheck
-
- All Implemented Interfaces:
Configurable,Contextualizable,FileSetCheck
public class RegexpMultilineCheck extends AbstractFileSetCheck
Checks that a specified pattern matches across multiple lines in any file type.
Rationale: This check can be used to when the regular expression can be span multiple lines.
-
Property
fileExtensions- Specify the file type extension of files to process. Type isjava.lang.String[]. Default value is"". -
Property
format- Specify the format of the regular expression to match. Type isjava.util.regex.Pattern. Default value is"$.". -
Property
ignoreCase- Control whether to ignore case when searching. Type isboolean. Default value isfalse. -
Property
matchAcrossLines- Control whether to match expressions across multiple lines. Type isboolean. Default value isfalse. -
Property
maximum- Specify the maximum number of matches required in each file. Type isint. Default value is0. -
Property
message- Specify the message which is used to notify about violations, if empty then default (hard-coded) message is used. Type isjava.lang.String. Default value isnull. -
Property
minimum- Specify the minimum number of matches required in each file. Type isint. Default value is0.
Parent is
com.puppycrawl.tools.checkstyle.CheckerViolation Message Keys:
-
regexp.StackOverflowError -
regexp.empty -
regexp.exceeded -
regexp.minimum
- Since:
- 5.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
AbstractAutomaticBean.OutputStreamOptions
-
-
Field Summary
Fields Modifier and Type Field Description private MultilineDetectordetectorThe detector to use.private java.lang.StringformatSpecify the format of the regular expression to match.private booleanignoreCaseControl whether to ignore case when searching.private booleanmatchAcrossLinesControl whether to match expressions across multiple lines.private intmaximumSpecify the maximum number of matches required in each file.private java.lang.StringmessageSpecify the message which is used to notify about violations, if empty then default (hard-coded) message is used.private intminimumSpecify the minimum number of matches required in each file.
-
Constructor Summary
Constructors Constructor Description RegexpMultilineCheck()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbeginProcessing(java.lang.String charset)Called when about to be called to process a set of files.private intgetRegexCompileFlags()Retrieves the compile-flags for the regular expression being built based onmatchAcrossLines.protected voidprocessFiltered(java.io.File file, FileText fileText)Called to process a file that matches the specified file extensions.voidsetFormat(java.lang.String format)Setter to specify the format of the regular expression to match.voidsetIgnoreCase(boolean ignoreCase)Setter to control whether to ignore case when searching.voidsetMatchAcrossLines(boolean matchAcrossLines)Setter to control whether to match expressions across multiple lines.voidsetMaximum(int maximum)Setter to specify the maximum number of matches required in each file.voidsetMessage(java.lang.String message)Setter to specify the message which is used to notify about violations, if empty then default (hard-coded) message is used.voidsetMinimum(int minimum)Setter to specify the minimum number of matches required in each file.-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractFileSetCheck
addViolations, destroy, finishProcessing, fireErrors, getFileContents, getFileExtensions, getMessageDispatcher, getTabWidth, getViolations, init, log, log, process, setFileContents, setFileExtensions, setMessageDispatcher, setTabWidth
-
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
finishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverity
-
Methods inherited from class com.puppycrawl.tools.checkstyle.AbstractAutomaticBean
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
-
-
-
-
Field Detail
-
format
private java.lang.String format
Specify the format of the regular expression to match.
-
message
private java.lang.String message
Specify the message which is used to notify about violations, if empty then default (hard-coded) message is used.
-
minimum
private int minimum
Specify the minimum number of matches required in each file.
-
maximum
private int maximum
Specify the maximum number of matches required in each file.
-
ignoreCase
private boolean ignoreCase
Control whether to ignore case when searching.
-
matchAcrossLines
private boolean matchAcrossLines
Control whether to match expressions across multiple lines.
-
detector
private MultilineDetector detector
The detector to use.
-
-
Constructor Detail
-
RegexpMultilineCheck
public RegexpMultilineCheck()
-
-
Method Detail
-
beginProcessing
public void beginProcessing(java.lang.String charset)
Description copied from interface:FileSetCheckCalled when about to be called to process a set of files.- Specified by:
beginProcessingin interfaceFileSetCheck- Overrides:
beginProcessingin classAbstractFileSetCheck- Parameters:
charset- the character set used to read the files.
-
processFiltered
protected void processFiltered(java.io.File file, FileText fileText)
Description copied from class:AbstractFileSetCheckCalled to process a file that matches the specified file extensions.- Specified by:
processFilteredin classAbstractFileSetCheck- Parameters:
file- the file to be processedfileText- the contents of the file.
-
getRegexCompileFlags
private int getRegexCompileFlags()
Retrieves the compile-flags for the regular expression being built based onmatchAcrossLines.- Returns:
- The compile-flags.
-
setFormat
public void setFormat(java.lang.String format)
Setter to specify the format of the regular expression to match.- Parameters:
format- the format of the regular expression to match.- Since:
- 5.0
-
setMessage
public void setMessage(java.lang.String message)
Setter to specify the message which is used to notify about violations, if empty then default (hard-coded) message is used.- Parameters:
message- the message to report for a match.- Since:
- 5.0
-
setMinimum
public void setMinimum(int minimum)
Setter to specify the minimum number of matches required in each file.- Parameters:
minimum- the minimum number of matches required in each file.- Since:
- 5.0
-
setMaximum
public void setMaximum(int maximum)
Setter to specify the maximum number of matches required in each file.- Parameters:
maximum- the maximum number of matches required in each file.- Since:
- 5.0
-
setIgnoreCase
public void setIgnoreCase(boolean ignoreCase)
Setter to control whether to ignore case when searching.- Parameters:
ignoreCase- whether to ignore case when searching.- Since:
- 5.0
-
setMatchAcrossLines
public void setMatchAcrossLines(boolean matchAcrossLines)
Setter to control whether to match expressions across multiple lines.- Parameters:
matchAcrossLines- whether to match expressions across multiple lines.- Since:
- 8.25
-
-