/** * Return the path parameters for each bound variable. */ public Map<String, MultiValueMap<String, String>> getMatrixVariables() { return this.pathMatchInfo.getMatrixVariables(); } }
/** * Construct a new {@code UrlBasedCorsConfigurationSource} instance with default * {@code PathPatternParser}. * @since 5.0.6 */ public UrlBasedCorsConfigurationSource() { this(new PathPatternParser()); }
PatternParseException(int pos, char[] pattern, PatternMessage messageType, Object... inserts) { super(messageType.formatMessage(inserts)); this.position = pos; this.pattern = pattern; this.messageType = messageType; this.inserts = inserts; }
private void checkMatches(String uriTemplate, String path) { PathPatternParser parser = new PathPatternParser(); parser.setMatchOptionalTrailingSeparator(true); PathPattern p = parser.parse(uriTemplate); PathContainer pc = toPathContainer(path); assertTrue(p.matches(pc)); }
private PathPattern parse(String path) { PathPatternParser pp = new PathPatternParser(); pp.setMatchOptionalTrailingSeparator(true); return pp.parse(path); }
public String combine(String string1, String string2) { PathPattern pattern1 = pp.parse(string1); PathPattern pattern2 = pp.parse(string2); return pattern1.combine(pattern2).getPatternString(); }
@Test // SPR-13286 public void caseInsensitive() { PathPatternParser pp = new PathPatternParser(); pp.setCaseSensitive(false); PathPattern p = pp.parse("/group/{groupName}/members"); assertMatches(p,"/group/sales/members"); assertMatches(p,"/Group/Sales/Members"); assertMatches(p,"/group/Sales/members"); }
/** * Return variables that were bound in the part of the path that was * successfully matched or an empty map. */ public Map<String, String> getUriVariables() { return this.pathMatchInfo.getUriVariables(); }
private PathPattern.PathMatchInfo matchAndExtract(String pattern, String path) { return parse(pattern).matchAndExtract(PathPatternTests.toPathContainer(path)); }
private PathPattern.PathMatchInfo matchAndExtract(PathPattern pp, String path) { return pp.matchAndExtract(PathPatternTests.toPathContainer(path)); }
/** * Shortcut method for setting the same property on the underlying pattern * parser in use. For more details see: * <ul> * <li>{@link #getPathPatternParser()} -- the underlying pattern parser * <li>{@link PathPatternParser#setMatchOptionalTrailingSeparator(boolean)} -- * the trailing slash option, including its default value. * </ul> */ public void setUseTrailingSlashMatch(boolean trailingSlashMatch) { this.patternParser.setMatchOptionalTrailingSeparator(trailingSlashMatch); }
private PathRemainingMatchInfo getPathRemaining(String pattern, String path) { return parse(pattern).matchStartOfPath(toPathContainer(path)); }
@Override public boolean matches(int pathIndex, PathPattern.MatchingContext matchingContext) { // If there is more data, it must start with the separator if (pathIndex < matchingContext.pathLength && !matchingContext.isSeparator(pathIndex)) { return false; } if (matchingContext.determineRemainingPath) { matchingContext.remainingPathIndex = matchingContext.pathLength; } return true; }
public PathMatchInfo getPathMatchResult() { if (this.extractedUriVariables == null) { return PathMatchInfo.EMPTY; } else { return new PathMatchInfo(this.extractedUriVariables, this.extractedMatrixVariables); } }
RegexPathElement(int pos, char[] regex, boolean caseSensitive, char[] completePattern, char separator) { super(pos, separator); this.regex = regex; this.caseSensitive = caseSensitive; this.pattern = buildPattern(regex, completePattern); }
private PathRemainingMatchInfo getPathRemaining(PathPattern pattern, String path) { return pattern.matchStartOfPath(toPathContainer(path)); }
/** * Verify the pattern string computed for a parsed pattern matches the original pattern text */ private PathPattern checkStructure(String pattern) { PathPattern pp = parse(pattern); assertEquals(pattern, pp.computePatternString()); return pp; }
private void checkNoMatch(String uriTemplate, String path) { PathPatternParser p = new PathPatternParser(); PathPattern pattern = p.parse(uriTemplate); PathContainer PathContainer = toPathContainer(path); assertFalse(pattern.matches(PathContainer)); }
private PathPattern.PathMatchInfo matchAndExtract(PathPattern p, String path) { return p.matchAndExtract(toPathContainer(path)); }
/** * Return a formatted message with inserts applied. */ @Override public String getMessage() { return this.messageType.formatMessage(this.inserts); }