Class SearchTools

java.lang.Object
com.webmethods.caf.common.SearchTools

public class SearchTools extends Object
Utility class for searching through a map based on an input that is either regular or regex.
  • Field Details

  • Constructor Details

    • SearchTools

      public SearchTools()
  • Method Details

    • buildRegExForTerms

      public static List<Pattern> buildRegExForTerms(List<String> terms)
      Convert the search term list to a list of regex patterns. Uses * as wildcard
      Parameters:
      terms - list of search terms
      Returns:
      list of regex Pattern objects for the given search terms
    • buildRegExForTerms

      public static List<Pattern> buildRegExForTerms(List<String> terms, int flags)
      Convert the search term list to a list of regex patterns. Uses * as wildcard
      Parameters:
      terms - list of search terms
      flags - flags to use for the pattern object
      Returns:
      list of regex Pattern objects for the given search terms
    • buildRegExForTerm

      public static String buildRegExForTerm(String term)
      Convert the search term to a regex string. Uses * as wildcard
      Parameters:
      term - the search term
      Returns:
      regex for the given search term
    • buildPatternForTerm

      public static Pattern buildPatternForTerm(String term)
      Convert the search term to a regex pattern. Uses * as wildcard
      Parameters:
      term - the search term
      Returns:
      regex pattern for the given search term
    • buildPatternForTerm

      public static Pattern buildPatternForTerm(String term, int flags)
      Convert the search term to a regex pattern. Uses * as wildcard
      Parameters:
      term - the search term
      flags - flags to use for the pattern object
      Returns:
      regex pattern for the given search term
    • matchesAllRegExPatterns

      public static boolean matchesAllRegExPatterns(String value, List<Pattern> patternList)
      Check if the given string matches all the regex patterns in the pattern list
      Parameters:
      value - the string to match against
      patternList - the list of regex patterns to match
      Returns:
      true if the value matches all the patterns, false otherwise