org.locomotive.util
Class ExpressionSearch

java.lang.Object
  |
  +--org.locomotive.util.ExpressionSearch

public class ExpressionSearch
extends java.lang.Object

A class for matching string A against string B, where one of the strings may have one or more wildcard characters (which are dots, '.') which can match any single character. For example, both 'banana' and 'mo.key' will match "the monkey ate the banana". You would say:

     keywords = { "banana", "monkey" }; 
     ExpressionSearch expr = new ExpressionSearch(keywords);
     boolean matched = expr.matches("the monkey ate the banana");
 
Perhaps later we'll add a larger subset of regular expressions. This class is implemented using a Trie, to optimize access speed. For example, if keywords = { "monkey", "moniker" }, then the Trie would look like:
             __ K  E  Y
  M  O  N __/
            \__ I  K  E  R
 


Constructor Summary
ExpressionSearch(java.lang.String s)
          Create a new expression search object that will search for the input String
ExpressionSearch(java.lang.String[] expression_list)
          Creates a new expression search object.
 
Method Summary
 boolean matches(java.lang.String s)
          returns true if the input string contains the expression
 void setWildcardMode(boolean wm)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpressionSearch

public ExpressionSearch(java.lang.String s)
Create a new expression search object that will search for the input String

ExpressionSearch

public ExpressionSearch(java.lang.String[] expression_list)
Creates a new expression search object. This method will cause an internal 'compiled' search tree to be generated from the list of input expressions.
Method Detail

setWildcardMode

public void setWildcardMode(boolean wm)

matches

public boolean matches(java.lang.String s)
returns true if the input string contains the expression