Class GlobMatcher

java.lang.Object
org.apache.tomcat.jakartaee.GlobMatcher

public final class GlobMatcher extends Object

This is a utility class to match file globs. The class has been derived from org.apache.tools.ant.types.selectors.SelectorUtils.

All methods are static.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Construct the matcher.
  • Method Summary

    Modifier and Type
    Method
    Description
    private static boolean
    allStars(char[] chars, int start, int end)
     
    private static boolean
    different(boolean caseSensitive, char ch, char other)
     
    private static boolean
    match(String pattern, char[] strArr, boolean caseSensitive)
    Tests whether or not a string matches against a pattern.
    static boolean
    match(String pattern, String str, boolean caseSensitive)
    Tests whether or not a string matches against a pattern.
    static boolean
    matchName(Set<String> patternSet, String fileName, boolean caseSensitive)
    Tests whether or not a given file name matches any file name pattern in the given set.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GlobMatcher

      public GlobMatcher()
      Construct the matcher.
  • Method Details

    • matchName

      public static boolean matchName(Set<String> patternSet, String fileName, boolean caseSensitive)
      Tests whether or not a given file name matches any file name pattern in the given set. The match is performed case-sensitively.
      Parameters:
      patternSet - The pattern set to match against. Must not be null.
      fileName - The file name to match, as a String. Must not be null. It must be just a file name, without a path.
      caseSensitive - Whether or not matching should be performed case sensitively.
      Returns:
      true if any pattern in the set matches against the file name, or false otherwise.
      See Also:
    • match

      public static boolean match(String pattern, String str, boolean caseSensitive)
      Tests whether or not a string matches against a pattern. The pattern may contain two special characters:
      '*' means zero or more characters
      '?' means one and only one character
      Parameters:
      pattern - The pattern to match against. Must not be null.
      str - The string which must be matched against the pattern. Must not be null.
      caseSensitive - Whether or not matching should be performed case sensitively.
      Returns:
      true if the string matches against the pattern, or false otherwise.
    • match

      private static boolean match(String pattern, char[] strArr, boolean caseSensitive)
      Tests whether or not a string matches against a pattern. The pattern may contain two special characters:
      '*' means zero or more characters
      '?' means one and only one character
      Parameters:
      pattern - The pattern to match against. Must not be null.
      strArr - The character array which must be matched against the pattern. Must not be null.
      caseSensitive - Whether or not matching should be performed case sensitively.
      Returns:
      true if the string matches against the pattern, or false otherwise.
    • allStars

      private static boolean allStars(char[] chars, int start, int end)
    • different

      private static boolean different(boolean caseSensitive, char ch, char other)