path against the given pattern.
- *
* @param pattern the pattern to match against
* @param path the path String to test
- * @param fullMatch whether a full pattern match is required (else a pattern match as far as the given base path goes
- * is sufficient)
+ * @param fullMatch whether a full pattern match is required (else a pattern match
+ * as far as the given base path goes is sufficient)
* @return true if the supplied path matched, false if it didn't
*/
- protected boolean doMatch(String pattern,
- String path,
- boolean fullMatch,
+ protected boolean doMatch(String pattern, String path, boolean fullMatch,
Mapnull.
* @param str string which must be matched against the pattern. Must not be null.
* @return true if the string matches against the pattern, or false otherwise.
@@ -271,9 +271,11 @@ public class AntPathMatcher implements PathMatcher {
}
/**
- * Combines two patterns into a new pattern that is returned. This implementation simply concatenates the two - * patterns, unless the first pattern contains a file extension match (such as {@code *.html}. In that case, the second - * pattern should be included in the first, or an {@code IllegalArgumentException} is thrown.
For example:
| Pattern 1 | Pattern 2 | Result |
|---|---|---|
| /hotels | {@code * null} | /hotels |
| {@code null} | /hotels | /hotels |
| /hotels | /bookings | /hotels/bookings |
| /hotels | bookings | /hotels/bookings |
| /hotels/** | {hotel} | /hotels/**/{hotel} |
| /*.html | /hotels.html | /hotels.html |
| /*.html | /hotels | /hotels.html |
| /*.html | /*.txt | IllegalArgumentException |
The returned Comparator will {@linkplain java.util.Collections#sort(java.util.List,
* java.util.Comparator) sort} a list so that more specific patterns (without uri templates or wild cards) come before
* generic patterns. So given a list with the following patterns:
/hotels/new/hotels/{hotel}/hotels/*The full path given as parameter is used to test for exact matches. So when the given path is {@code /hotels/2},
* the pattern {@code /hotels/2} will be sorted before {@code /hotels/1}.
- *
* @param path the full path to use for comparison
* @return a comparator capable of sorting patterns in order of explicitness
*/
@@ -371,6 +369,7 @@ public class AntPathMatcher implements PathMatcher {
return new AntPatternComparator(path);
}
+
private static class AntPatternComparator implements Comparator For example: For pattern "/hotels/{hotel}" and path "/hotels/1", this method will
* return a map containing "hotel"->"1".
- *
* @param pattern the path pattern, possibly containing URI templates
* @param path the full path to extract template variables from
* @return a map, containing variable names as keys; variables values as values
@@ -104,11 +103,12 @@ public interface PathMatcher {
Map The full algorithm used depends on the underlying implementation, but generally, the returned
- * The full algorithm used depends on the underlying implementation, but generally,
+ * the returned The full algorithm used for combining the two pattern depends on the underlying implementation.
- *
* @param pattern1 the first pattern
* @param pattern2 the second pattern
* @return the combination of the two patterns
* @throws IllegalArgumentException when the two patterns cannot be combined
*/
String combine(String pattern1, String pattern2);
+
}
Comparator will {@linkplain java.util.Collections#sort(java.util.List, java.util.Comparator) sort} a
- * list so that more specific patterns (for that come before generic patterns.
- *
+ * Given a full path, returns a {@link Comparator} suitable for sorting patterns
+ * in order of explicitness for that path.
+ * Comparator will
+ * {@linkplain java.util.Collections#sort(java.util.List, java.util.Comparator) sort}
+ * a list so that more specific patterns come before generic patterns.
* @param path the full path to use for comparison
* @return a comparator capable of sorting patterns in order of explicitness
*/
@@ -117,11 +117,11 @@ public interface PathMatcher {
/**
* Combines two patterns into a new pattern that is returned.
*