Package org.springframework.util
Class SimpleRouteMatcher
- java.lang.Object
- org.springframework.util.SimpleRouteMatcher
- All Implemented Interfaces:
RouteMatcher
public class SimpleRouteMatcher extends Object implements RouteMatcher
RouteMatcherthat delegates to aPathMatcher.Note: This implementation is not efficient since
PathMatchertreats paths and patterns as Strings. For more optimized performance use thePathPatternRouteMatcherfromspring-webwhich 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
Constructors Constructor Description SimpleRouteMatcher(PathMatcher pathMatcher)Create a newSimpleRouteMatcherfor the givenPathMatcherdelegate.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringcombine(String pattern1, String pattern2)Combines two patterns into a single pattern.PathMatchergetPathMatcher()Return the underlyingPathMatcherdelegate.Comparator<String>getPatternComparator(RouteMatcher.Route route)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.booleanisPattern(String route)Whether 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.Map<String,String>matchAndExtract(String pattern, RouteMatcher.Route route)Match the pattern to the route and extract template variables.RouteMatcher.RouteparseRoute(String route)Return a parsed representation of the given route.
Constructor Detail
SimpleRouteMatcher
public SimpleRouteMatcher(PathMatcher pathMatcher)
Create a newSimpleRouteMatcherfor the givenPathMatcherdelegate.
Method Detail
getPathMatcher
public PathMatcher getPathMatcher()
Return the underlyingPathMatcherdelegate.
parseRoute
public RouteMatcher.Route parseRoute(String route)
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
public boolean isPattern(String route)
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
public String combine(String pattern1, String pattern2)
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
public boolean match(String pattern, RouteMatcher.Route route)
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
@Nullable public Map<String,String> matchAndExtract(String pattern, RouteMatcher.Route route)
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
public Comparator<String> getPatternComparator(RouteMatcher.Route route)
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