Top Description Fields Constructors Methods
org.eclipse.jgit.ignore.internal

public Class PathMatcher

extends AbstractMatcher
Class Inheritance
Static Imports
org.eclipse.jgit.ignore.internal.Strings.checkWildCards, .Strings.count, .Strings.getPathSeparator, .Strings.isWildCard, .Strings.split

Matcher built by patterns consists of multiple path segments.

This class is immutable and thread safe.

Field Summary

Modifier and TypeField and Description
private final boolean
private final List<IMatcher>
private final char
private static final WildMatcher
private static final WildMatcher
Inherited from org.eclipse.jgit.ignore.internal.AbstractMatcher:
dirOnlypattern

Constructor Summary

AccessConstructor and Description
private
PathMatcher(String pattern, Character pathSeparator, boolean dirOnly)

Method Summary

Modifier and TypeMethod and Description
private static List<IMatcher>
createMatchers(List<String> segments, Character pathSeparator, boolean dirOnly)

private static IMatcher
createNameMatcher0(String segment, Character pathSeparator, boolean dirOnly, boolean lastSegment)

public static IMatcher

Returns:

never null
createPathMatcher
(String
a pattern
pattern
,
Character
if this parameter isn't null then this character will not match at wildcards(* and ? are wildcards).
pathSeparator
,
boolean
a boolean.
dirOnly
)

Create path matcher

private boolean
private static boolean
isWild(IMatcher matcher)

private boolean
iterate(final String path, final int startIncl, final int endExcl, boolean assumeDirectory, boolean pathMatch)

public boolean
matches(String
string which is not null, but might be empty
path
,
boolean
true to assume this path as directory (even if it doesn't end with a slash)
assumeDirectory
,
boolean
true if the match is for the full path: prefix-only matches are not allowed
pathMatch
)

Implements org.eclipse.jgit.ignore.IMatcher.matches.

Matches entire given string

public boolean
matches(String
string which is not null, but might be empty
segment
,
int
start index, inclusive
startIncl
,
int
end index, exclusive
endExcl
)

Implements org.eclipse.jgit.ignore.IMatcher.matches.

Matches only part of given string

private boolean
matches(int matcherIdx, String path, int startIncl, int endExcl, boolean assumeDirectory, boolean pathMatch)

private boolean
simpleMatch(String path, boolean assumeDirectory, boolean pathMatch)

private static String

Returns:

trimmed pattern
trim
(String
non null
pattern
)

Trim trailing spaces, unless they are escaped with backslash, see https://www.kernel.org/pub/software/scm/git/docs/gitignore.html

Inherited from org.eclipse.jgit.ignore.internal.AbstractMatcher:
equalshashCodetoString

Field Detail

beginningback to summary
private final boolean beginning
matchersback to summary
private final List<IMatcher> matchers
slashback to summary
private final char slash
WILD_NO_DIRECTORYback to summary
private static final WildMatcher WILD_NO_DIRECTORY
WILD_ONLY_DIRECTORYback to summary
private static final WildMatcher WILD_ONLY_DIRECTORY

Constructor Detail

PathMatcherback to summary
private PathMatcher(String pattern, Character pathSeparator, boolean dirOnly) throws InvalidPatternException

Method Detail

createMatchersback to summary
private static List<IMatcher> createMatchers(List<String> segments, Character pathSeparator, boolean dirOnly) throws InvalidPatternException
createNameMatcher0back to summary
private static IMatcher createNameMatcher0(String segment, Character pathSeparator, boolean dirOnly, boolean lastSegment) throws InvalidPatternException
createPathMatcherback to summary
public static IMatcher createPathMatcher(String pattern, Character pathSeparator, boolean dirOnly) throws InvalidPatternException

Create path matcher

Parameters
pattern:String

a pattern

pathSeparator:Character

if this parameter isn't null then this character will not match at wildcards(* and ? are wildcards).

dirOnly:boolean

a boolean.

Returns:IMatcher

never null

Exceptions
InvalidPatternException:
if pattern is invalid
isSimplePathWithSegmentsback to summary
private boolean isSimplePathWithSegments(String path)
isWildback to summary
private static boolean isWild(IMatcher matcher)
iterateback to summary
private boolean iterate(final String path, final int startIncl, final int endExcl, boolean assumeDirectory, boolean pathMatch)
matchesback to summary
public boolean matches(String path, boolean assumeDirectory, boolean pathMatch)

Implements org.eclipse.jgit.ignore.IMatcher.matches.

Doc from org.eclipse.jgit.ignore.IMatcher.matches.

Matches entire given string

Parameters
path:String

string which is not null, but might be empty

assumeDirectory:boolean

true to assume this path as directory (even if it doesn't end with a slash)

pathMatch:boolean

true if the match is for the full path: prefix-only matches are not allowed

Returns:boolean

true if this matcher pattern matches given string

Annotations
@Override
matchesback to summary
public boolean matches(String segment, int startIncl, int endExcl)

Implements org.eclipse.jgit.ignore.IMatcher.matches.

Doc from org.eclipse.jgit.ignore.IMatcher.matches.

Matches only part of given string

Parameters
segment:String

string which is not null, but might be empty

startIncl:int

start index, inclusive

endExcl:int

end index, exclusive

Returns:boolean

true if this matcher pattern matches given string

Annotations
@Override
matchesback to summary
private boolean matches(int matcherIdx, String path, int startIncl, int endExcl, boolean assumeDirectory, boolean pathMatch)
simpleMatchback to summary
private boolean simpleMatch(String path, boolean assumeDirectory, boolean pathMatch)
trimback to summary
private static String trim(String pattern)

Trim trailing spaces, unless they are escaped with backslash, see https://www.kernel.org/pub/software/scm/git/docs/gitignore.html

Parameters
pattern:String

non null

Returns:String

trimmed pattern