|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2009 the original author or authors. |
| 2 | + * Copyright 2002-2012 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -41,16 +41,11 @@ class AntPathStringMatcher {
|
41 | 41 |
|
42 | 42 | private final Pattern pattern;
|
43 | 43 |
|
44 |
| - private String str; |
45 |
| - |
46 | 44 | private final List<String> variableNames = new LinkedList<String>();
|
47 | 45 |
|
48 |
| - private final Map<String, String> uriTemplateVariables; |
49 | 46 |
|
50 | 47 | /** Construct a new instance of the <code>AntPatchStringMatcher</code>. */
|
51 |
| - AntPathStringMatcher(String pattern, String str, Map<String, String> uriTemplateVariables) { |
52 |
| - this.str = str; |
53 |
| - this.uriTemplateVariables = uriTemplateVariables; |
| 48 | + AntPathStringMatcher(String pattern) { |
54 | 49 | this.pattern = createPattern(pattern);
|
55 | 50 | }
|
56 | 51 |
|
@@ -100,14 +95,14 @@ private String quote(String s, int start, int end) {
|
100 | 95 | *
|
101 | 96 | * @return <code>true</code> if the string matches against the pattern, or <code>false</code> otherwise.
|
102 | 97 | */
|
103 |
| - public boolean matchStrings() { |
| 98 | + public boolean matchStrings(String str, Map<String, String> uriTemplateVariables) { |
104 | 99 | Matcher matcher = pattern.matcher(str);
|
105 | 100 | if (matcher.matches()) {
|
106 | 101 | if (uriTemplateVariables != null) {
|
107 | 102 | // SPR-8455
|
108 |
| - Assert.isTrue(variableNames.size() == matcher.groupCount(), |
109 |
| - "The number of capturing groups in the pattern segment " + pattern + |
110 |
| - " does not match the number of URI template variables it defines, which can occur if " + |
| 103 | + Assert.isTrue(variableNames.size() == matcher.groupCount(), |
| 104 | + "The number of capturing groups in the pattern segment " + pattern + |
| 105 | + " does not match the number of URI template variables it defines, which can occur if " + |
111 | 106 | " capturing groups are used in a URI template regex. Use non-capturing groups instead.");
|
112 | 107 | for (int i = 1; i <= matcher.groupCount(); i++) {
|
113 | 108 | String name = this.variableNames.get(i - 1);
|
|
0 commit comments