Class AttributesRule


  • public class AttributesRule
    extends java.lang.Object
    A single attributes rule corresponding to one line in a .gitattributes file. Inspiration from: FastIgnoreRule
    Since:
    3.7
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.List<Attribute> attributes  
      private static java.lang.String ATTRIBUTES_SPLIT_REGEX
      regular expression for splitting attributes - space, tab and \r (the C implementation oddly enough allows \r between attributes)
      private boolean dirOnly  
      private IMatcher matcher  
      private boolean nameOnly  
      private java.lang.String pattern  
    • Constructor Summary

      Constructors 
      Constructor Description
      AttributesRule​(java.lang.String pattern, java.lang.String attributes)
      Create a new attribute rule with the given pattern.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.List<Attribute> getAttributes()
      Return the attributes.
      java.lang.String getPattern()
      Get the pattern
      boolean isDirOnly()
      Whether to match directories only
      boolean isMatch​(java.lang.String relativeTarget, boolean isDirectory)
      Returns true if a match was made.
      boolean isNameOnly()
      Whether the pattern is only a file name and not a path
      private static java.util.List<Attribute> parseAttributes​(java.lang.String attributesLine)  
      java.lang.String toString()
      • Methods inherited from class java.lang.Object

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

      • ATTRIBUTES_SPLIT_REGEX

        private static final java.lang.String ATTRIBUTES_SPLIT_REGEX
        regular expression for splitting attributes - space, tab and \r (the C implementation oddly enough allows \r between attributes)
        See Also:
        Constant Field Values
      • pattern

        private final java.lang.String pattern
      • attributes

        private final java.util.List<Attribute> attributes
      • nameOnly

        private final boolean nameOnly
      • dirOnly

        private final boolean dirOnly
      • matcher

        private final IMatcher matcher
    • Constructor Detail

      • AttributesRule

        public AttributesRule​(java.lang.String pattern,
                              java.lang.String attributes)
        Create a new attribute rule with the given pattern. Assumes that the pattern is already trimmed.
        Parameters:
        pattern - Base pattern for the attributes rule. This pattern will be parsed to generate rule parameters. It can not be null.
        attributes - the rule attributes. This string will be parsed to read the attributes.
    • Method Detail

      • parseAttributes

        private static java.util.List<Attribute> parseAttributes​(java.lang.String attributesLine)
      • isDirOnly

        public boolean isDirOnly()
        Whether to match directories only
        Returns:
        true if the pattern should match directories only
        Since:
        4.3
      • getAttributes

        public java.util.List<Attribute> getAttributes()
        Return the attributes.
        Returns:
        an unmodifiable list of attributes (never returns null)
      • isNameOnly

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

        public java.lang.String getPattern()
        Get the pattern
        Returns:
        The blob pattern to be used as a matcher (never returns null)
      • isMatch

        public boolean isMatch​(java.lang.String relativeTarget,
                               boolean isDirectory)
        Returns true if a match was made.
        Parameters:
        relativeTarget - Name pattern of the file, relative to the base directory of this rule
        isDirectory - Whether the target file is a directory or not
        Returns:
        True if a match was made.
      • toString

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