Class PathGroupExtractor
The pattern is compiled with the same flags NottableString.matches(String, boolean)
uses for path matching — case-insensitive matching uses DOTALL | CASE_INSENSITIVE | UNICODE_CASE
and the opt-in matchExactCase mode uses DOTALL only — and is run as an anchored full match,
so a request that matched the path also extracts its groups (no case/DOTALL divergence). Both numbered
groups and Java named groups (?<name>...) are captured.
The returned list is 1-based aligned with Matcher group numbering: index 0 is the whole match
and index 1 the first capturing group, so a template author can use the indices they would naturally
expect from the pattern. A group that did not participate in the match yields null in the list
(and is omitted from the named map).
This is best-effort: a literal path with no capturing groups, a path that is not a regex, or a pattern that fails to compile all yield no groups (an empty result), and never throw, so the match decision — made elsewhere — is never affected by group extraction.
- Author:
- jamesdbloom
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classHolds the numbered and named capture groups extracted from a path match. -
Method Summary
Modifier and TypeMethodDescriptionRunspatternValueas an anchored full-match regex againstactualPathand returns its capture groups.
-
Method Details
-
extract
public static PathGroupExtractor.PathGroups extract(String patternValue, String actualPath, boolean caseSensitive) RunspatternValueas an anchored full-match regex againstactualPathand returns its capture groups.caseSensitiveselects the samePatternflags the path matcher used (false — the default — usesDOTALL | CASE_INSENSITIVE | UNICODE_CASE; true — the opt-inmatchExactCasemode — usesDOTALLonly), so extraction succeeds for exactly the requests that matched. Returns aPathGroupExtractor.PathGroupswith no groups when the pattern is null/blank, has no capturing groups, does not match, or fails to compile.
-