Class 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 extensions of the files to process. Type is java.lang.String[]. Default value is "".
    • Property format - Specify the format of the regular expression to match. Type is java.util.regex.Pattern. Default value is "$.".
    • Property ignoreCase - Control whether to ignore case when searching. Type is boolean. Default value is false.
    • Property matchAcrossLines - Control whether to match expressions across multiple lines. Type is boolean. Default value is false.
    • Property maximum - Specify the maximum number of matches required in each file. Type is int. Default value is 0.
    • Property message - Specify the message which is used to notify about violations, if empty then default (hard-coded) message is used. Type is java.lang.String. Default value is null.
    • Property minimum - Specify the minimum number of matches required in each file. Type is int. Default value is 0.

    Parent is com.puppycrawl.tools.checkstyle.Checker

    Violation Message Keys:

    • regexp.StackOverflowError
    • regexp.empty
    • regexp.exceeded
    • regexp.minimum
    Since:
    5.0
    • Field Detail

      • format

        private String format
        Specify the format of the regular expression to match.
      • message

        private 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.
    • Method Detail

      • getRegexCompileFlags

        private int getRegexCompileFlags()
        Retrieves the compile-flags for the regular expression being built based on matchAcrossLines.
        Returns:
        The compile-flags.
      • setFormat

        public void setFormat​(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​(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