Class PathPatternRouteMatcher
java.lang.Object
org.springframework.web.util.pattern.PathPatternRouteMatcher
- All Implemented Interfaces:
RouteMatcher
RouteMatcher
built on PathPatternParser
that uses
PathContainer
and PathPattern
as parsed representations of
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
ConstructorDescriptionDefault constructor withPathPatternParser
customized forMESSAGE_ROUTE
and without matching of trailing separator.Constructor with givenPathPatternParser
. -
Method Summary
Modifier and TypeMethodDescriptionCombines two patterns into a single pattern.Given a route, return aComparator
suitable for sorting patterns in order of explicitness for that route, so that more specific patterns come before more generic ones.boolean
Whether the givenroute
contains pattern syntax which requires theRouteMatcher.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.matchAndExtract
(String pattern, RouteMatcher.Route route) Match the pattern to the route and extract template variables.parseRoute
(String routeValue) Return a parsed representation of the given route.
-
Constructor Details
-
PathPatternRouteMatcher
public PathPatternRouteMatcher()Default constructor withPathPatternParser
customized forMESSAGE_ROUTE
and without matching of trailing separator. -
PathPatternRouteMatcher
Constructor with givenPathPatternParser
.
-
-
Method Details
-
parseRoute
Description copied from interface:RouteMatcher
Return a parsed representation of the given route.- Specified by:
parseRoute
in interfaceRouteMatcher
- Parameters:
routeValue
- the route to parse- Returns:
- the parsed representation of the route
-
isPattern
Description copied from interface:RouteMatcher
Whether the givenroute
contains 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:
isPattern
in interfaceRouteMatcher
- Parameters:
route
- the route to check- Returns:
true
if the givenroute
represents a pattern
-
combine
Description copied from interface:RouteMatcher
Combines two patterns into a single pattern.- Specified by:
combine
in interfaceRouteMatcher
- Parameters:
pattern1
- the first patternpattern2
- the second pattern- Returns:
- the combination of the two patterns
-
match
Description copied from interface:RouteMatcher
Match the given route against the given pattern.- Specified by:
match
in interfaceRouteMatcher
- Parameters:
pattern
- the pattern to try to matchroute
- the route to test against- Returns:
true
if there is a match,false
otherwise
-
matchAndExtract
Description copied from interface:RouteMatcher
Match the pattern to the route and extract template variables.- Specified by:
matchAndExtract
in 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:RouteMatcher
Given a route, return aComparator
suitable for sorting patterns in order of explicitness for that route, so that more specific patterns come before more generic ones.- Specified by:
getPatternComparator
in interfaceRouteMatcher
- Parameters:
route
- the full path to use for comparison- Returns:
- a comparator capable of sorting patterns in order of explicitness
-