Class PatternMatchRevFilter


  • public abstract class PatternMatchRevFilter
    extends RevFilter
    Abstract filter that searches text using extended regular expressions.
    • 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 - should forceToRaw(String) be applied to the pattern before compiling it?
        flags - flags from Pattern 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 class RevFilter
        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 from RevFilter.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 class RevFilter
        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.