Class Glob

java.lang.Object
org.ec4j.core.model.Glob

public class Glob extends Object
An EditorConfig glob. Citing from http://editorconfig.org/:

Special characters recognized in section names for wildcard matching:

  • * Matches any string of characters, except path separators (/)
  • ** Matches any string of characters
  • ? Matches any single character
  • [name] Matches any single character in name
  • [!name] Matches any single character not in name
  • {s1,s2,s3} Matches any of the strings given (separated by commas) (Available since EditorConfig Core 0.11.0)
  • {num1..num2} Matches any integer numbers between num1 and num2, where num1 and num2 can be either positive or negative

Methods in this class stating so were copied from EditorConfig by Dennis Ushakov.

  • Field Details

    • error

      private final PatternSyntaxException error
    • ranges

      private final List<int[]> ranges
    • regex

      private final Pattern regex
    • source

      private final String source
    • matchLastSegmentOnly

      private final boolean matchLastSegmentOnly
    • ESCAPED_COMMENT_SIGNS

      static final Pattern ESCAPED_COMMENT_SIGNS
  • Constructor Details

    • Glob

      public Glob(String source)
  • Method Details

    • equals

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

      public PatternSyntaxException getError()
      Returns:
      the PatternSyntaxException that was thrown when parsing the source or null when no PatternSyntaxException was thrown.
    • getSource

      public String getSource()
      Returns:
      the glob string out of which this Glob was constructed
    • hashCode

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

      public boolean isEmpty()
    • isValid

      public boolean isValid()
    • match

      public boolean match(Ec4jPath filePath)
      Matches the given slash (/) separated path against this Glob. The filePath MUST be relative to the directory if the .editorconfig file this Glob was defined in.

      Based on EditorConfig by Dennis Ushakov.

      Parameters:
      filePath - a slash (/) separated file path to match against this Glob
      Returns:
      true if the given filePath matches; false otherwise
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      the glob string out of which this Glob was constructed
    • convertGlobToRegEx

      static void convertGlobToRegEx(String globString, List<int[]> ranges, StringBuilder result)
      Copied from EditorConfig by Dennis Ushakov.
    • matchingBraces

      static boolean matchingBraces(String globString)
      Parameters:
      globString - the glob string to check
      Returns:
      true if the count of opening braces is equal to the count of the closing braces; false otherwise
    • getNumericRange

      static int[] getNumericRange(String choice)
      Copied from EditorConfig by Dennis Ushakov.
    • findChar

      static int findChar(char c, char stopAt, String pattern, int length, int start)
      Copied from EditorConfig by Dennis Ushakov.
    • escapeToRegex

      static void escapeToRegex(char c, StringBuilder result)
      Copied from EditorConfig by Dennis Ushakov.