Class PathMatcher
java.lang.Object
software.xdev.testcontainers.imagebuilder.jgit.ignore.internal.AbstractMatcher
software.xdev.testcontainers.imagebuilder.jgit.ignore.internal.PathMatcher
- All Implemented Interfaces:
IMatcher
Matcher built by patterns consists of multiple path segments.
This class is immutable and thread safe.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final booleanprotected final charprotected static final WildMatcherprotected static final WildMatcherFields inherited from class software.xdev.testcontainers.imagebuilder.jgit.ignore.internal.AbstractMatcher
dirOnly, pattern -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPathMatcher(String pattern, Character pathSeparator, boolean dirOnly) -
Method Summary
Modifier and TypeMethodDescriptioncreateMatchers(List<String> segments, Character pathSeparator, boolean dirOnly) protected static IMatchercreateNameMatcher0(String segment, Character pathSeparator, boolean dirOnly, boolean lastSegment) static IMatchercreatePathMatcher(String pattern, Character pathSeparator, boolean dirOnly) Create path matcherprotected booleanprotected static booleanprotected booleanprotected booleanmatches(int matcherIdx, String path, int startIncl, int endExcl, boolean assumeDirectory, boolean pathMatch) booleanMatches entire given stringbooleanMatches only part of given stringprotected booleansimpleMatch(String path, boolean assumeDirectory, boolean pathMatch) protected static StringTrim trailing spaces, unless they are escaped with backslash, see https://www.kernel.org/pub/software/scm/git/docs/gitignore.htmlMethods inherited from class software.xdev.testcontainers.imagebuilder.jgit.ignore.internal.AbstractMatcher
equals, hashCode, toString
-
Field Details
-
WILD_NO_DIRECTORY
-
WILD_ONLY_DIRECTORY
-
matchers
-
slash
protected final char slash -
beginning
protected final boolean beginning
-
-
Constructor Details
-
PathMatcher
protected PathMatcher(String pattern, Character pathSeparator, boolean dirOnly) throws InvalidPatternException - Throws:
InvalidPatternException
-
-
Method Details
-
isSimplePathWithSegments
-
createMatchers
protected static List<IMatcher> createMatchers(List<String> segments, Character pathSeparator, boolean dirOnly) throws InvalidPatternException - Throws:
InvalidPatternException
-
createPathMatcher
public static IMatcher createPathMatcher(String pattern, Character pathSeparator, boolean dirOnly) throws InvalidPatternException Create path matcher- Parameters:
pattern- a patternpathSeparator- if this parameter isn't null then this character will not match at wildcards(* and ? are wildcards).dirOnly- a boolean.- Returns:
- never null
- Throws:
InvalidPatternException- if pattern is invalid
-
trim
Trim trailing spaces, unless they are escaped with backslash, see https://www.kernel.org/pub/software/scm/git/docs/gitignore.html- Parameters:
pattern- non null- Returns:
- trimmed pattern
-
createNameMatcher0
protected static IMatcher createNameMatcher0(String segment, Character pathSeparator, boolean dirOnly, boolean lastSegment) throws InvalidPatternException - Throws:
InvalidPatternException
-
matches
Description copied from interface:IMatcherMatches entire given string- Parameters:
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-trueif the match is for the full path: prefix-only matches are not allowed- Returns:
- true if this matcher pattern matches given string
-
simpleMatch
-
matches
Description copied from interface:IMatcherMatches only part of given string- Parameters:
segment- string which is not null, but might be emptystartIncl- start index, inclusiveendExcl- end index, exclusive- Returns:
- true if this matcher pattern matches given string
-
iterate
protected boolean iterate(String path, int startIncl, int endExcl, boolean assumeDirectory, boolean pathMatch) -
matches
protected boolean matches(int matcherIdx, String path, int startIncl, int endExcl, boolean assumeDirectory, boolean pathMatch) -
isWild
-