Package org.eclipse.jgit.revwalk.filter
Class PatternMatchRevFilter
- java.lang.Object
-
- org.eclipse.jgit.revwalk.filter.RevFilter
-
- org.eclipse.jgit.revwalk.filter.PatternMatchRevFilter
-
public abstract class PatternMatchRevFilter extends RevFilter
Abstract filter that searches text using extended regular expressions.
-
-
Field Summary
-
Fields inherited from class org.eclipse.jgit.revwalk.filter.RevFilter
ALL, MERGE_BASE, NO_MERGES, NONE, ONLY_MERGES
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
PatternMatchRevFilter(String pattern, boolean innerString, boolean rawEncoding, int flags)
Construct a new pattern matching filter.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static String
forceToRaw(String patternText)
Encode a string pattern for faster matching on byte arrays.boolean
include(RevWalk walker, RevCommit cmit)
Determine if the supplied commit should be included in results.String
pattern()
Get the pattern this filter uses.boolean
requiresCommitBody()
Whether the filter needs the commit body to be parsed.protected abstract CharSequence
text(RevCommit cmit)
Obtain the raw text to match against.String
toString()
-
-
-
Constructor Detail
-
PatternMatchRevFilter
protected PatternMatchRevFilter(String pattern, boolean innerString, boolean rawEncoding, int flags)
Construct a new pattern matching filter.- Parameters:
pattern
- text of the pattern. Callers may want to surround their pattern with ".*" on either end to allow matching in the middle of the string.innerString
- should .* be wrapped around the pattern of ^ and $ are missing? Most users will want this set.rawEncoding
- shouldforceToRaw(String)
be applied to the pattern before compiling it?flags
- flags fromPattern
to control how matching performs.
-
-
Method Detail
-
forceToRaw
protected static final String forceToRaw(String patternText)
Encode a string pattern for faster matching on byte arrays.Force the characters to our funny UTF-8 only convention that we use on raw buffers. This avoids needing to perform character set decodes on the individual commit buffers.
- Parameters:
patternText
- original pattern string supplied by the user or the application.- Returns:
- same pattern, but re-encoded to match our funny raw UTF-8
character sequence
RawCharSequence
.
-
pattern
public String pattern()
Get the pattern this filter uses.- Returns:
- the pattern this filter is applying to candidate strings.
-
include
public boolean include(RevWalk walker, RevCommit cmit) throws MissingObjectException, IncorrectObjectTypeException, IOException
Determine if the supplied commit should be included in results.- Specified by:
include
in classRevFilter
- Parameters:
walker
- the active walker this filter is being invoked from within.cmit
- the commit currently being tested. The commit has been parsed and its body is available for inspection only if the filter returns true fromRevFilter.requiresCommitBody()
.- Returns:
- true to include this commit in the results; false to have this commit be omitted entirely from the results.
- Throws:
MissingObjectException
- an object the filter needs to consult to determine its answer does not exist in the Git repository the walker is operating on. Filtering this commit is impossible without the object.IncorrectObjectTypeException
- an object the filter needed to consult was not of the expected object type. This usually indicates a corrupt repository, as an object link is referencing the wrong type.IOException
- a loose object or pack file could not be read to obtain data necessary for the filter to make its decision.
-
requiresCommitBody
public boolean requiresCommitBody()
Whether the filter needs the commit body to be parsed.- Overrides:
requiresCommitBody
in classRevFilter
- Returns:
- true if the filter needs the commit body to be parsed.
-
text
protected abstract CharSequence text(RevCommit cmit)
Obtain the raw text to match against.- Parameters:
cmit
- current commit being evaluated.- Returns:
- sequence for the commit's content that we need to match on.
-
-