public final class PathMatcherSupport extends Object
PathMatcher
s.Modifier and Type | Method and Description |
---|---|
static Pattern |
toGlobPattern(String glob)
Converts the given glob into a
Pattern . |
static Pattern |
toGlobPattern(String glob,
int flags)
Converts the given glob into a
Pattern . |
static Pattern |
toPattern(String syntaxAndPattern)
Creates a
Pattern for the given syntax and pattern combination. |
public static Pattern toPattern(String syntaxAndPattern)
Pattern
for the given syntax and pattern combination. This follows the rules of FileSystem.getPathMatcher(String)
.
This method supports two syntaxes: glob
and regex
. If the syntax is glob
, this method delegates to
toGlobPattern(String)
. Otherwise it will call Pattern.compile(String)
.
syntaxAndPattern
- The syntax and pattern.Pattern
based on the given syntax and pattern.IllegalArgumentException
- If the parameter does not take the form syntax:pattern
.PatternSyntaxException
- If the pattern is invalid.UnsupportedOperationException
- If the pattern syntax is not glob
or regex
.public static Pattern toGlobPattern(String glob)
Pattern
.
Note that this method uses a single forward slash (/
) as path separator.
glob
- The glob to convert.Pattern
built from the given glob.PatternSyntaxException
- If the given glob is invalid.FileSystem.getPathMatcher(String)
public static Pattern toGlobPattern(String glob, int flags)
Pattern
.
Note that this method uses a single forward slash (/
) as path separator.
glob
- The glob to convert.flags
- Match flags
for the Pattern
.Pattern
built from the given glob.PatternSyntaxException
- If the given glob is invalid.IllegalArgumentException
- If the match flags are invalid.FileSystem.getPathMatcher(String)
Copyright © 2016–2023. All rights reserved.