Class GlobPathMatcher

java.lang.Object
org.apache.felix.gogo.runtime.GlobPathMatcher

public class GlobPathMatcher extends Object
Freely adapted from Spring's AntPathMatcher. We don't use the file system's glob PathMatcher because it can't detect directories which can't be a start of a match.
  • Field Details

    • DEFAULT_PATH_SEPARATOR

      public static final String DEFAULT_PATH_SEPARATOR
      Default path separator: "/"
      See Also:
    • pattern

      private String pattern
    • pathSeparator

      private String pathSeparator
    • caseSensitive

      private boolean caseSensitive
    • pattDirs

      private String[] pattDirs
    • pattPats

      private Pattern[] pattPats
  • Constructor Details

    • GlobPathMatcher

      public GlobPathMatcher(String pattern)
      Create a new instance with the DEFAULT_PATH_SEPARATOR.
      Parameters:
      pattern - the pattern
    • GlobPathMatcher

      public GlobPathMatcher(String pattern, String pathSeparator, boolean caseSensitive)
      A convenient, alternative constructor to use with a custom path separator.
      Parameters:
      pattern - the pattern
      pathSeparator - the path separator to use, must not be null.
      caseSensitive - is case sensitive
  • Method Details

    • matches

      public boolean matches(String path, boolean fullMatch)
      Actually match the given path against the given pattern.
      Parameters:
      path - the path String to test
      fullMatch - whether a full pattern match is required (else a pattern match as far as the given base path goes is sufficient)
      Returns:
      true if the supplied path matched, false if it didn't
    • tokenizePath

      private String[] tokenizePath(String path)
      Tokenize the given path String into parts, based on this matcher's settings.
      Parameters:
      path - the path to tokenize
      Returns:
      the tokenized path parts
    • matchStrings

      private boolean matchStrings(int pattIdx, String str)
    • createMatcherPattern

      private Pattern createMatcherPattern(String pattern)