public class PathMatcher extends AbstractMatcher
This class is immutable and thread safe.
Modifier and Type | Field and Description |
---|---|
private boolean |
beginning |
private java.util.List<IMatcher> |
matchers |
private char |
slash |
private static WildMatcher |
WILD_NO_DIRECTORY |
private static WildMatcher |
WILD_ONLY_DIRECTORY |
dirOnly, pattern
Modifier | Constructor and Description |
---|---|
private |
PathMatcher(java.lang.String pattern,
java.lang.Character pathSeparator,
boolean dirOnly) |
Modifier and Type | Method and Description |
---|---|
private static java.util.List<IMatcher> |
createMatchers(java.util.List<java.lang.String> segments,
java.lang.Character pathSeparator,
boolean dirOnly) |
private static IMatcher |
createNameMatcher0(java.lang.String segment,
java.lang.Character pathSeparator,
boolean dirOnly,
boolean lastSegment) |
static IMatcher |
createPathMatcher(java.lang.String pattern,
java.lang.Character pathSeparator,
boolean dirOnly)
Create path matcher
|
private boolean |
isSimplePathWithSegments(java.lang.String path) |
private static boolean |
isWild(IMatcher matcher) |
private boolean |
iterate(java.lang.String path,
int startIncl,
int endExcl,
boolean assumeDirectory,
boolean pathMatch) |
private boolean |
matches(int matcherIdx,
java.lang.String path,
int startIncl,
int endExcl,
boolean assumeDirectory,
boolean pathMatch) |
boolean |
matches(java.lang.String path,
boolean assumeDirectory,
boolean pathMatch)
Matches entire given string
|
boolean |
matches(java.lang.String segment,
int startIncl,
int endExcl)
Matches only part of given string
|
private boolean |
simpleMatch(java.lang.String path,
boolean assumeDirectory,
boolean pathMatch) |
private static java.lang.String |
trim(java.lang.String pattern)
Trim trailing spaces, unless they are escaped with backslash, see
https://www.kernel.org/pub/software/scm/git/docs/gitignore.html
|
equals, hashCode, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
createPathMatcher
private static final WildMatcher WILD_NO_DIRECTORY
private static final WildMatcher WILD_ONLY_DIRECTORY
private final java.util.List<IMatcher> matchers
private final char slash
private final boolean beginning
private PathMatcher(java.lang.String pattern, java.lang.Character pathSeparator, boolean dirOnly) throws InvalidPatternException
InvalidPatternException
private boolean isSimplePathWithSegments(java.lang.String path)
private static java.util.List<IMatcher> createMatchers(java.util.List<java.lang.String> segments, java.lang.Character pathSeparator, boolean dirOnly) throws InvalidPatternException
InvalidPatternException
public static IMatcher createPathMatcher(java.lang.String pattern, java.lang.Character pathSeparator, boolean dirOnly) throws InvalidPatternException
pattern
- a patternpathSeparator
- if this parameter isn't null then this character will not
match at wildcards(* and ? are wildcards).dirOnly
- a boolean.InvalidPatternException
private static java.lang.String trim(java.lang.String pattern)
pattern
- non nullprivate static IMatcher createNameMatcher0(java.lang.String segment, java.lang.Character pathSeparator, boolean dirOnly, boolean lastSegment) throws InvalidPatternException
InvalidPatternException
public boolean matches(java.lang.String path, boolean assumeDirectory, boolean pathMatch)
path
- string which is not null, but might be emptyassumeDirectory
- true to assume this path as directory (even if it doesn't end
with a slash)pathMatch
- true
if the match is for the full path: prefix-only
matches are not allowedprivate boolean simpleMatch(java.lang.String path, boolean assumeDirectory, boolean pathMatch)
public boolean matches(java.lang.String segment, int startIncl, int endExcl)
segment
- string which is not null, but might be emptystartIncl
- start index, inclusiveendExcl
- end index, exclusiveprivate boolean iterate(java.lang.String path, int startIncl, int endExcl, boolean assumeDirectory, boolean pathMatch)
private boolean matches(int matcherIdx, java.lang.String path, int startIncl, int endExcl, boolean assumeDirectory, boolean pathMatch)
private static boolean isWild(IMatcher matcher)