-
public interface PathMatcher
URI Path Matcher. It is primary intended for use in Routing implementation.Matched URI path is always decoded,
normalized
and with removed single ended slash (if any).Web Server Path Pattern
While user can implement this interface to implement any specific needs the primary construction method iscreate(String)
factory method. The method accepts Web Server Path Pattern format.Web Server path pattern description 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 ([^/]+)
. UsePathMatcher.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)?
/* or /foo*
Wildcard character can be matched with any number of characters.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
PathMatcher.PrefixResult
The result of prefix matching aPathMatcher
to a given URI path.static interface
PathMatcher.Result
The result of matching aPathMatcher
to a given URI path.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method 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.
-
-
-
Method Detail
-
create
static PathMatcher create(String pathPattern) throws NullPointerException, IllegalPathPatternException
Creates new instance from provided Web Server path pattern. See class level javadoc for the path pattern description.- Parameters:
pathPattern
- Web Server path pattern.- Returns:
- new instance.
- Throws:
NullPointerException
- if parameterpathPattern
isnull
.IllegalPathPatternException
- if provided pattern is not valid Web Server path pattern.
-
match
PathMatcher.Result match(CharSequence path)
Matches this matcher against a URI path.- Parameters:
path
- resolved and normalized URI path to test against.- Returns:
- a
PathMatcher.Result
of the test. - Throws:
NullPointerException
- in case thatpath
parameter isnull
.
-
prefixMatch
PathMatcher.PrefixResult prefixMatch(CharSequence path)
Matches this matcher against a left part (prefix) of URI path with granularity on the path segment. It means that accepted 'prefix' cannot break path segment and 'remaining-part' MUST start with slash '/' character.- Parameters:
path
- resolved and normalized URI path to test against.- Returns:
- a
PathMatcher.Result
of the test. - Throws:
NullPointerException
- in case thatpath
parameter isnull
.
-
-