Class FastIgnoreRule

java.lang.Object
org.eclipse.jgit.ignore.FastIgnoreRule

public class FastIgnoreRule extends Object
"Fast" (compared with IgnoreRule) git ignore rule implementation supporting also double star ** pattern.

This class is immutable and thread safe.

Since:
3.6
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private boolean
     
    private boolean
     
    private static final org.slf4j.Logger
     
    private IMatcher
     
    static final char
    Character used as default path separator for ignore entries
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    Constructor for FastIgnoreRule
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Whether the pattern should match directories only
    boolean
    boolean
    Whether the pattern is just a file name and not a path
    boolean
    Indicates whether the rule is non-negation or negation.
    boolean
    Indicates whether the rule is non-negation or negation.
    int
    boolean
    Whether the rule never matches
    boolean
    isMatch(String path, boolean directory)
    Returns true if a match was made.
    boolean
    isMatch(String path, boolean directory, boolean pathMatch)
    Returns true if a match was made.
    (package private) void
    parse(String pattern)
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • LOG

      private static final org.slf4j.Logger LOG
    • PATH_SEPARATOR

      public static final char PATH_SEPARATOR
      Character used as default path separator for ignore entries
      See Also:
    • matcher

      private IMatcher matcher
    • inverse

      private boolean inverse
    • dirOnly

      private boolean dirOnly
  • Constructor Details

    • FastIgnoreRule

      public FastIgnoreRule(String pattern)
      Constructor for FastIgnoreRule
      Parameters:
      pattern - ignore pattern as described in git manual. If pattern is invalid or is not a pattern (comment), this rule doesn't match anything.
    • FastIgnoreRule

      FastIgnoreRule()
  • Method Details

    • parse

      void parse(String pattern) throws InvalidPatternException
      Throws:
      InvalidPatternException
    • isMatch

      public boolean isMatch(String path, boolean directory)
      Returns true if a match was made.
      This function does NOT return the actual ignore status of the target! Please consult getResult() for the negation status. The actual ignore status may be true or false depending on whether this rule is an ignore rule or a negation rule.
      Parameters:
      path - Name pattern of the file, relative to the base directory of this rule
      directory - Whether the target file is a directory or not
      Returns:
      True if a match was made. This does not necessarily mean that the target is ignored. Call getResult() for the result.
    • isMatch

      public boolean isMatch(String path, boolean directory, boolean pathMatch)
      Returns true if a match was made.
      This function does NOT return the actual ignore status of the target! Please consult getResult() for the negation status. The actual ignore status may be true or false depending on whether this rule is an ignore rule or a negation rule.
      Parameters:
      path - Name pattern of the file, relative to the base directory of this rule
      directory - Whether the target file is a directory or not
      pathMatch - true if the match is for the full path: see IMatcher.matches(String, int, int)
      Returns:
      True if a match was made. This does not necessarily mean that the target is ignored. Call getResult() for the result.
      Since:
      4.11
    • getNameOnly

      public boolean getNameOnly()
      Whether the pattern is just a file name and not a path
      Returns:
      true if the pattern is just a file name and not a path
    • dirOnly

      public boolean dirOnly()
      Whether the pattern should match directories only
      Returns:
      true if the pattern should match directories only
    • getNegation

      public boolean getNegation()
      Indicates whether the rule is non-negation or negation.
      Returns:
      True if the pattern had a "!" in front of it
    • getResult

      public boolean getResult()
      Indicates whether the rule is non-negation or negation.
      Returns:
      True if the target is to be ignored, false otherwise.
    • isEmpty

      public boolean isEmpty()
      Whether the rule never matches
      Returns:
      true if the rule never matches (comment line or broken pattern)
      Since:
      4.1
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object