com.webmethods.caf.common
Class SearchTools

java.lang.Object
  extended by 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 Summary
protected static Map regexPatternCache
           
 
Constructor Summary
SearchTools()
           
 
Method Summary
static Pattern buildPatternForTerm(String term)
          Convert the search term to a regex pattern.
static Pattern buildPatternForTerm(String term, int flags)
          Convert the search term to a regex pattern.
static String buildRegExForTerm(String term)
          Convert the search term to a regex string.
static List buildRegExForTerms(List terms)
          Convert the search term list to a list of regex patterns.
static List buildRegExForTerms(List terms, int flags)
          Convert the search term list to a list of regex patterns.
static boolean matchesAllRegExPatterns(String value, List patternList)
          Check if the given string matches all the regex patterns in the pattern list
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

regexPatternCache

protected static Map regexPatternCache
Constructor Detail

SearchTools

public SearchTools()
Method Detail

buildRegExForTerms

public static List buildRegExForTerms(List 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 buildRegExForTerms(List 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 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