net.sourceforge.rssowl.util
Class SearchpatternParser

java.lang.Object
  extended bynet.sourceforge.rssowl.util.SearchpatternParser

public class SearchpatternParser
extends Object

Class for parsing the search pattern (Operators: AND, OR, NOT).

Version:
1.1.3
Author:
Benjamin Pasero

Field Summary
static String MUST_KEY
          Hashtable Key for the Must Key-Words
static String MUSTNOT_KEY
          Hashtable Key for the Must-Not Key-Words
 
Constructor Summary
private SearchpatternParser()
          This utility class constructor is hidden
 
Method Summary
static Vector generateRegEx(Vector keys)
          Generate a RegEx from the AND / OR keywords.
private static int getClosestKeyword(String pattern, int notIndex)
          Finds the next index of one of the keywords AND, OR
private static Vector parseMustAndMayWords(String pattern)
          Parse Words that should match the result (AND / OR)
static Hashtable parsePattern(String pattern)
          Parse the search pattern and return a Hashtable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MUST_KEY

public static final String MUST_KEY
Hashtable Key for the Must Key-Words

See Also:
Constant Field Values

MUSTNOT_KEY

public static final String MUSTNOT_KEY
Hashtable Key for the Must-Not Key-Words

See Also:
Constant Field Values
Constructor Detail

SearchpatternParser

private SearchpatternParser()
This utility class constructor is hidden

Method Detail

generateRegEx

public static Vector generateRegEx(Vector keys)
Generate a RegEx from the AND / OR keywords.

Parameters:
keys - Vector holding the AND / OR Keywords
Returns:
RegEx matching the keywords

parsePattern

public static Hashtable parsePattern(String pattern)
Parse the search pattern and return a Hashtable. The Hashtable contains one Vector for the Keywords that should NOT match the result and one Vector that should match the result (AND). The Vector for the AND-Keywords holds one Vector for each OR-Keyword. For example: A pattern "Car AND Audi OR Mercedes" would result in: [[Car], [Audi, Mercedes]] beeing equivalent to "Car && (Audi || Mercedes)"

Parameters:
pattern - The search pattern (e.g. "Car AND Audi NOT Ferrari")
Returns:
parsed pattern holding the Keywords for AND, OR and NOT

getClosestKeyword

private static int getClosestKeyword(String pattern,
                                     int notIndex)
Finds the next index of one of the keywords AND, OR

Parameters:
pattern - The search pattern
notIndex - Current position in search pattern
Returns:
Closest index to next keyword

parseMustAndMayWords

private static Vector parseMustAndMayWords(String pattern)
Parse Words that should match the result (AND / OR)

Parameters:
pattern - The search pattern (NOT words are removed)
Returns:
Vector holding AND plus OR keywords


RSSOwl - RSS / RDF / Atom Newsreader

SourceForge.net Logo