Tests paths such as config/dev/app.properties against patterns with
wildcards such as config/**/*.properties, and pulls values out of
them.
The resource pattern resolver and @PropertySource use it to expand
location patterns. AntPathMatcher is the only implementation;
applications rarely need either, but can use one for their own
matching of paths or dotted names.
// Which uploaded files are stylesheets.
final PathMatcher matcher = AntPathMatcher();
matcher.match('/static/**/*.css', '/static/css/app.css'); // true
Spring (Java):
PathMatcher matcher = new AntPathMatcher();
matcher.match("/static/**/*.css", "/static/css/app.css"); // true
- Implementers
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
combine(
String pattern1, String pattern2) → String -
Joins two patterns into one, such as a prefix and a sub-pattern:
/hotels/*and/bookinggive/hotels/booking. -
extractPathWithinPattern(
String pattern, String path) → String -
The part of
pathmatched by the wildcard part ofpattern, such as the file path below a mapped directory. -
extractUriTemplateVariables(
String pattern, String path) → Map< String, String> -
The values of the
{name}variables ofpatterninpath, by name. -
getPatternComparator(
String path) → Comparator< String> -
A comparator that sorts patterns from the most to the least specific
for
path, to pick the best of several matching patterns. A pattern equal topathcomes first and/**last. -
isPattern(
String path) → bool -
Whether
pathcontains pattern syntax (*,?or a{name}variable), so it must be matched rather than compared. -
match(
String pattern, String path) → bool -
Whether the whole of
pathmatchespattern. -
matchStart(
String pattern, String path) → bool -
Whether
pathmatches the beginning ofpattern, so a longer path starting with it could still match. Used to skip directories that cannot contain a match. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited