public interface PathMatcher
Matched URI path is always decoded, normalized and
with removed single ended slash (if any).
create(String) factory method. The method accepts Web Server Path Pattern format.
| Construct Example | Description |
|---|---|
/foo/bar/b,a+z |
Exact canonical path match. (Including decoded characters.) |
/foo/{var} |
Named regular expression segment.
Name is var and regexp segment is ([^/]+). Use PathMatcher.Result.param(String) method to get value
of the segment. |
/foo/{} |
Nameless regular expression segment. Regexp segment is ([^/]+) |
/foo/{var:\d+} |
Named regular expression segment with specified expression. |
/foo/{:\d+} |
Nameless regular expression segment with specified expression. |
/foo/{+var} |
A convenience shortcut for /foo/{var:.+}. |
/foo/{+} |
A convenience shortcut for /foo/{:.+}. |
/foo[/bar] |
A optional section. Translated to regexp: /foo(/bar)? |
| Modifier and Type | Interface and Description |
|---|---|
static interface |
PathMatcher.PrefixResult
The result of prefix matching a
PathMatcher to a given URI path. |
static interface |
PathMatcher.Result
The result of matching a
PathMatcher to a given URI path. |
| Modifier and Type | Method and Description |
|---|---|
static PathMatcher |
create(String pathPattern)
Creates new instance from provided Web Server path pattern.
|
PathMatcher.Result |
match(CharSequence path)
Matches this matcher against a URI path.
|
PathMatcher.PrefixResult |
prefixMatch(CharSequence path)
Matches this matcher against a left part (prefix) of URI path with granularity on the path segment.
|
static PathMatcher create(String pathPattern) throws NullPointerException, IllegalPathPatternException
pathPattern - Web Server path pattern.NullPointerException - if parameter pathPattern is null.IllegalPathPatternException - if provided pattern is not valid Web Server path pattern.PathMatcher.Result match(CharSequence path)
path - resolved and normalized URI path to test against.PathMatcher.Result of the test.NullPointerException - in case that path parameter is null.PathMatcher.PrefixResult prefixMatch(CharSequence path)
path - resolved and normalized URI path to test against.PathMatcher.Result of the test.NullPointerException - in case that path parameter is null.Copyright © 2018–2019 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms.