-
public interface PathMatcherURI Path Matcher. It is primary intended for use in Routing implementation.Matched URI path is always decoded,
normalizedand 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+zExact 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 interfacePathMatcher.PrefixResultThe result of prefix matching aPathMatcherto a given URI path.static interfacePathMatcher.ResultThe result of matching aPathMatcherto a given URI path.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static PathMatchercreate(String pathPattern)Creates new instance from provided Web Server path pattern.PathMatcher.Resultmatch(CharSequence path)Matches this matcher against a URI path.PathMatcher.PrefixResultprefixMatch(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 parameterpathPatternisnull.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.Resultof the test. - Throws:
NullPointerException- in case thatpathparameter 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.Resultof the test. - Throws:
NullPointerException- in case thatpathparameter isnull.
-
-