public class SimpleRouteMatcher extends Object implements RouteMatcher
RouteMatcher
that delegates to a PathMatcher
.
Note: This implementation is not efficient since
PathMatcher
treats paths and patterns as Strings. For more optimized
performance use the PathPatternRouteMatcher
from spring-web
which enables use of parsed routes and patterns.
RouteMatcher.Route
Constructor and Description |
---|
SimpleRouteMatcher(PathMatcher pathMatcher)
Create a new
SimpleRouteMatcher for the given
PathMatcher delegate. |
Modifier and Type | Method and Description |
---|---|
String |
combine(String pattern1,
String pattern2)
Combines two patterns into a single pattern.
|
PathMatcher |
getPathMatcher()
Return the underlying
PathMatcher delegate. |
Comparator<String> |
getPatternComparator(RouteMatcher.Route route)
Given a route, return a
Comparator suitable for sorting patterns
in order of explicitness for that route, so that more specific patterns
come before more generic ones. |
boolean |
isPattern(String route)
Whether the given
route contains pattern syntax which requires
the RouteMatcher.match(String, Route) method, or if it is a regular String
that could be compared directly to others. |
boolean |
match(String pattern,
RouteMatcher.Route route)
Match the given route against the given pattern.
|
Map<String,String> |
matchAndExtract(String pattern,
RouteMatcher.Route route)
Match the pattern to the route and extract template variables.
|
RouteMatcher.Route |
parseRoute(String route)
Return a parsed representation of the given route.
|
public SimpleRouteMatcher(PathMatcher pathMatcher)
SimpleRouteMatcher
for the given
PathMatcher
delegate.public PathMatcher getPathMatcher()
PathMatcher
delegate.public RouteMatcher.Route parseRoute(String route)
RouteMatcher
parseRoute
in interface RouteMatcher
route
- the route to parsepublic boolean isPattern(String route)
RouteMatcher
route
contains pattern syntax which requires
the RouteMatcher.match(String, Route)
method, or if it is a regular String
that could be compared directly to others.isPattern
in interface RouteMatcher
route
- the route to checktrue
if the given route
represents a patternpublic String combine(String pattern1, String pattern2)
RouteMatcher
combine
in interface RouteMatcher
pattern1
- the first patternpattern2
- the second patternpublic boolean match(String pattern, RouteMatcher.Route route)
RouteMatcher
match
in interface RouteMatcher
pattern
- the pattern to try to matchroute
- the route to test againsttrue
if there is a match, false
otherwise@Nullable public Map<String,String> matchAndExtract(String pattern, RouteMatcher.Route route)
RouteMatcher
matchAndExtract
in interface RouteMatcher
pattern
- the pattern, possibly containing templates variablesroute
- the route to extract template variables frompublic Comparator<String> getPatternComparator(RouteMatcher.Route route)
RouteMatcher
Comparator
suitable for sorting patterns
in order of explicitness for that route, so that more specific patterns
come before more generic ones.getPatternComparator
in interface RouteMatcher
route
- the full path to use for comparison