Class IgnoreNode

  • Direct Known Subclasses:
    WorkingTreeIterator.PerDirectoryIgnoreNode

    public class IgnoreNode
    extends java.lang.Object
    Represents a bundle of ignore rules inherited from a base directory. This class is not thread safe, it maintains state about the last match.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static org.slf4j.Logger LOG  
      private java.util.List<FastIgnoreRule> rules
      The rules that have been parsed into this node.
    • Constructor Summary

      Constructors 
      Constructor Description
      IgnoreNode()
      Create an empty ignore node with no rules.
      IgnoreNode​(java.util.List<FastIgnoreRule> rules)
      Create an ignore node with given rules.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.io.BufferedReader asReader​(java.io.InputStream in)  
      java.lang.Boolean checkIgnored​(java.lang.String entryPath, boolean isDirectory)
      Determine if an entry path matches an ignore rule.
      java.util.List<FastIgnoreRule> getRules()
      Get list of all ignore rules held by this node
      IgnoreNode.MatchResult isIgnored​(java.lang.String entryPath, boolean isDirectory)
      Determine if an entry path matches an ignore rule.
      void parse​(java.io.InputStream in)
      Parse files according to gitignore standards.
      void parse​(java.lang.String sourceName, java.io.InputStream in)
      Parse files according to gitignore standards.
      java.lang.String toString()
      • Methods inherited from class java.lang.Object

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

      • LOG

        private static final org.slf4j.Logger LOG
      • rules

        private final java.util.List<FastIgnoreRule> rules
        The rules that have been parsed into this node.
    • Constructor Detail

      • IgnoreNode

        public IgnoreNode()
        Create an empty ignore node with no rules.
      • IgnoreNode

        public IgnoreNode​(java.util.List<FastIgnoreRule> rules)
        Create an ignore node with given rules.
        Parameters:
        rules - list of rules.
    • Method Detail

      • parse

        public void parse​(java.io.InputStream in)
                   throws java.io.IOException
        Parse files according to gitignore standards.
        Parameters:
        in - input stream holding the standard ignore format. The caller is responsible for closing the stream.
        Throws:
        java.io.IOException - Error thrown when reading an ignore file.
      • parse

        public void parse​(java.lang.String sourceName,
                          java.io.InputStream in)
                   throws java.io.IOException
        Parse files according to gitignore standards.
        Parameters:
        sourceName - identifying the source of the stream
        in - input stream holding the standard ignore format. The caller is responsible for closing the stream.
        Throws:
        java.io.IOException - Error thrown when reading an ignore file.
        Since:
        5.11
      • asReader

        private static java.io.BufferedReader asReader​(java.io.InputStream in)
      • getRules

        public java.util.List<FastIgnoreRule> getRules()
        Get list of all ignore rules held by this node
        Returns:
        list of all ignore rules held by this node
      • isIgnored

        public IgnoreNode.MatchResult isIgnored​(java.lang.String entryPath,
                                                boolean isDirectory)
        Determine if an entry path matches an ignore rule.
        Parameters:
        entryPath - the path to test. The path must be relative to this ignore node's own repository path, and in repository path format (uses '/' and not '\').
        isDirectory - true if the target item is a directory.
        Returns:
        status of the path.
      • checkIgnored

        @Nullable
        public java.lang.Boolean checkIgnored​(java.lang.String entryPath,
                                              boolean isDirectory)
        Determine if an entry path matches an ignore rule.
        Parameters:
        entryPath - the path to test. The path must be relative to this ignore node's own repository path, and in repository path format (uses '/' and not '\').
        isDirectory - true if the target item is a directory.
        Returns:
        Boolean.TRUE, if the entry is ignored; Boolean.FALSE, if the entry is forced to be not ignored (negated match); or null, if undetermined
        Since:
        4.11
      • toString

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