Class PatternMatchRevFilter

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected PatternMatchRevFilter​(java.lang.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 java.lang.String forceToRaw​(java.lang.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.
      java.lang.String pattern()
      Get the pattern this filter uses.
      boolean requiresCommitBody()
      Whether the filter needs the commit body to be parsed.
      protected abstract java.lang.CharSequence text​(RevCommit cmit)
      Obtain the raw text to match against.
      java.lang.String toString()
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • patternText

        private final java.lang.String patternText
      • compiledPattern

        private final java.util.regex.Matcher compiledPattern
    • Constructor Detail

      • PatternMatchRevFilter

        protected PatternMatchRevFilter​(java.lang.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 java.lang.String forceToRaw​(java.lang.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 java.lang.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,
                               java.io.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.
        java.io.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 java.lang.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.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class RevFilter