Package org.springframework.util
Class SimpleRouteMatcher
java.lang.Object
org.springframework.util.SimpleRouteMatcher
- All Implemented Interfaces:
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.
- Since:
- 5.2
- Author:
- Rossen Stoyanchev
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.util.RouteMatcher
RouteMatcher.Route -
Constructor Summary
ConstructorsConstructorDescriptionSimpleRouteMatcher(PathMatcher pathMatcher) Create a newSimpleRouteMatcherfor the givenPathMatcherdelegate. -
Method Summary
Modifier and TypeMethodDescriptionCombines two patterns into a single pattern.Return the underlyingPathMatcherdelegate.Given a route, return aComparatorsuitable for sorting patterns in order of explicitness for that route, so that more specific patterns come before more generic ones.booleanWhether the givenroutecontains pattern syntax which requires theRouteMatcher.match(String, Route)method, or if it is a regular String that could be compared directly to others.booleanmatch(String pattern, RouteMatcher.Route route) Match the given route against the given pattern.matchAndExtract(String pattern, RouteMatcher.Route route) Match the pattern to the route and extract template variables.parseRoute(String route) Return a parsed representation of the given route.
-
Constructor Details
-
SimpleRouteMatcher
Create a newSimpleRouteMatcherfor the givenPathMatcherdelegate.
-
-
Method Details
-
getPathMatcher
Return the underlyingPathMatcherdelegate. -
parseRoute
Description copied from interface:RouteMatcherReturn a parsed representation of the given route.- Specified by:
parseRoutein interfaceRouteMatcher- Parameters:
route- the route to parse- Returns:
- the parsed representation of the route
-
isPattern
Description copied from interface:RouteMatcherWhether the givenroutecontains pattern syntax which requires theRouteMatcher.match(String, Route)method, or if it is a regular String that could be compared directly to others.- Specified by:
isPatternin interfaceRouteMatcher- Parameters:
route- the route to check- Returns:
trueif the givenrouterepresents a pattern
-
combine
Description copied from interface:RouteMatcherCombines two patterns into a single pattern.- Specified by:
combinein interfaceRouteMatcher- Parameters:
pattern1- the first patternpattern2- the second pattern- Returns:
- the combination of the two patterns
-
match
Description copied from interface:RouteMatcherMatch the given route against the given pattern.- Specified by:
matchin interfaceRouteMatcher- Parameters:
pattern- the pattern to try to matchroute- the route to test against- Returns:
trueif there is a match,falseotherwise
-
matchAndExtract
Description copied from interface:RouteMatcherMatch the pattern to the route and extract template variables.- Specified by:
matchAndExtractin interfaceRouteMatcher- Parameters:
pattern- the pattern, possibly containing templates variablesroute- the route to extract template variables from- Returns:
- a map with template variables and values
-
getPatternComparator
Description copied from interface:RouteMatcherGiven a route, return aComparatorsuitable for sorting patterns in order of explicitness for that route, so that more specific patterns come before more generic ones.- Specified by:
getPatternComparatorin interfaceRouteMatcher- Parameters:
route- the full path to use for comparison- Returns:
- a comparator capable of sorting patterns in order of explicitness
-