Class MultiFileRegexpHeaderCheck.HeaderFileMetadata

java.lang.Object
com.puppycrawl.tools.checkstyle.checks.header.MultiFileRegexpHeaderCheck.HeaderFileMetadata
Enclosing class:
MultiFileRegexpHeaderCheck

private static final class MultiFileRegexpHeaderCheck.HeaderFileMetadata extends Object
Metadata holder for a header file, storing its URI, compiled patterns, and line contents.
  • Field Details

  • Constructor Details

    • HeaderFileMetadata

      private HeaderFileMetadata(URI headerFileUri, String headerFilePath, List<Pattern> headerPatterns, List<String> lineContents)
      Initializes the metadata holder.
      Parameters:
      headerFileUri - URI of the header file
      headerFilePath - original path string of the header file
      headerPatterns - compiled regex patterns for header lines
      lineContents - raw lines from the header file
  • Method Details

    • createFromFile

      Creates a HeaderFileMetadata instance by reading and processing the specified header file.
      Parameters:
      headerPath - path to the header file
      Returns:
      HeaderFileMetadata instance
      Throws:
      IllegalArgumentException - if the header file is invalid or cannot be read
    • createPatternFromLine

      private static Pattern createPatternFromLine(String line)
      Creates a Pattern object from a line of text.
      Parameters:
      line - the line to create a pattern from
      Returns:
      the compiled Pattern
    • getHeaderFileUri

      Returns the URI of the header file.
      Returns:
      header file URI
    • getHeaderFilePath

      Returns the original path string of the header file.
      Returns:
      header file path string
    • getHeaderPatterns

      Returns an unmodifiable list of compiled header patterns.
      Returns:
      header patterns
    • getLineContents

      Returns an unmodifiable list of raw header line contents.
      Returns:
      header lines
    • validateRegex

      private static String validateRegex(String input)
      Ensures that the given input string is a valid regular expression.

      This method validates that the input is a correctly formatted regex string and will throw a PatternSyntaxException if it's invalid.

      Parameters:
      input - the string to be treated as a regex pattern
      Returns:
      the validated regex pattern string
      Throws:
      IllegalArgumentException - if the pattern is not a valid regex