Class MultiFileRegexpHeaderCheck.HeaderFileMetadata
java.lang.Object
com.puppycrawl.tools.checkstyle.checks.header.MultiFileRegexpHeaderCheck.HeaderFileMetadata
- Enclosing class:
- MultiFileRegexpHeaderCheck
Metadata holder for a header file, storing its URI, compiled patterns, and line contents.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateFromFile
(String headerPath) Creates a HeaderFileMetadata instance by reading and processing the specified header file.private static Pattern
createPatternFromLine
(String line) Creates a Pattern object from a line of text.Returns the original path string of the header file.Returns the URI of the header file.Returns an unmodifiable list of compiled header patterns.Returns an unmodifiable list of raw header line contents.private static String
validateRegex
(String input) Ensures that the given input string is a valid regular expression.
-
Field Details
-
headerFileUri
URI of the header file. -
headerFilePath
Original path string of the header file. -
headerPatterns
Compiled regex patterns for each line of the header. -
lineContents
Raw line contents of the header file.
-
-
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 fileheaderFilePath
- original path string of the header fileheaderPatterns
- compiled regex patterns for header lineslineContents
- 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
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
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
-