Package com.github.robtimus.filesystems
Class PathMatcherSupport
- java.lang.Object
-
- com.github.robtimus.filesystems.PathMatcherSupport
-
public final class PathMatcherSupport extends Object
A utility class that can assist in implementingPathMatchers.- Author:
- Rob Spoor
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static PatterntoGlobPattern(String glob)Converts the given glob into aPattern.static PatterntoGlobPattern(String glob, int flags)Converts the given glob into aPattern.static PatterntoPattern(String syntaxAndPattern)Creates aPatternfor the given syntax and pattern combination.
-
-
-
Method Detail
-
toPattern
public static Pattern toPattern(String syntaxAndPattern)
Creates aPatternfor the given syntax and pattern combination. This follows the rules ofFileSystem.getPathMatcher(String).This method supports two syntaxes:
globandregex. If the syntax isglob, this method delegates totoGlobPattern(String). Otherwise it will callPattern.compile(String).- Parameters:
syntaxAndPattern- The syntax and pattern.- Returns:
- A
Patternbased on the given syntax and pattern. - Throws:
IllegalArgumentException- If the parameter does not take the formsyntax:pattern.PatternSyntaxException- If the pattern is invalid.UnsupportedOperationException- If the pattern syntax is notgloborregex.
-
toGlobPattern
public static Pattern toGlobPattern(String glob)
Converts the given glob into aPattern.Note that this method uses a single forward slash (
/) as path separator.- Parameters:
glob- The glob to convert.- Returns:
- A
Patternbuilt from the given glob. - Throws:
PatternSyntaxException- If the given glob is invalid.- See Also:
FileSystem.getPathMatcher(String)
-
toGlobPattern
public static Pattern toGlobPattern(String glob, int flags)
Converts the given glob into aPattern.Note that this method uses a single forward slash (
/) as path separator.- Parameters:
glob- The glob to convert.flags-Match flagsfor thePattern.- Returns:
- A
Patternbuilt from the given glob. - Throws:
PatternSyntaxException- If the given glob is invalid.IllegalArgumentException- If the match flags are invalid.- See Also:
FileSystem.getPathMatcher(String)
-
-