Class WildcardPattern

java.lang.Object
com.aspectran.utils.wildcard.WildcardPattern

public class WildcardPattern extends Object
The Class WildcardPattern.

The following standard quantifiers are recognized:

*
matches single character
+
matches one or more characters
?
matches zero or more characters
**
matches zero or more string delimited by separators
\
Wildcard characters can be escaped

Examples

/static/*
/static/a.jpg
/static*/**/b/*
matches one or more characters
/static*/**
/static/a/a.jpg
**/static/**
a/b/static/a/b/c/a.jpg
/static-?/a??.jpg
/static-a/abc.jpg
  • Field Details

  • Constructor Details

    • WildcardPattern

      public WildcardPattern(String patternString)
    • WildcardPattern

      public WildcardPattern(String patternString, char separator)
  • Method Details

    • getSeparator

      public char getSeparator()
    • getTokens

      protected char[] getTokens()
    • getTypes

      protected int[] getTypes()
    • getWeight

      public float getWeight()
    • matches

      public boolean matches(String compareString)
      If the pattern matches then returns true.
      Parameters:
      compareString - the compare string
      Returns:
      true, if successful
    • mask

      public String mask(String nakedString)
      Erase the characters that corresponds to the wildcard, and returns collect only the remaining characters. In other words, only it remains for the wildcard character.
      Parameters:
      nakedString - the naked string
      Returns:
      the masked string
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

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

      public String toString()
      Overrides:
      toString in class Object
    • compile

      @NonNull public static WildcardPattern compile(String patternString)
    • compile

      @NonNull public static WildcardPattern compile(String patternString, char separator)
    • hasWildcards

      public static boolean hasWildcards(@NonNull String str)