net.sourceforge.rssowl.util.search
Class SearchPatternParser

java.lang.Object
  extended by net.sourceforge.rssowl.util.search.SearchPatternParser

public class SearchPatternParser
extends java.lang.Object

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

Version:
1.2.4
Author:
Benjamin Pasero

Field Summary
static java.lang.String AND
          Search Pattern Boolean AND modifier
static java.lang.String MUST_CONTAIN_KEY
          Hashtable Key for the Must Key-Words
static java.lang.String MUSTNOT_CONTAIN_KEY
          Hashtable Key for the Must-Not Key-Words
static java.lang.String NOT
          Search Pattern Boolean NOT modifier
static java.lang.String OR
          Search Pattern Boolean OR modifier
 
Constructor Summary
private SearchPatternParser()
          This utility class constructor is hidden
 
Method Summary
(package private) static java.util.ArrayList generateRegEx(java.util.ArrayList keys, boolean isWholeWord)
          Generate a RegEx from the AND / OR keywords.
private static int getClosestKeyword(java.lang.String pattern, int notIndex)
          Finds the next index of one of the keywords AND, OR
static java.lang.String getTranslation(java.lang.String key)
          Get the Translation for the given Search Key, which may be Boolean AND, OR and NOT.
private static java.util.ArrayList parseMustAndMayWords(java.lang.String pattern)
          Parse Words that should match the result (AND / OR)
(package private) static java.util.Hashtable parsePattern(java.lang.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

AND

public static final java.lang.String AND
Search Pattern Boolean AND modifier

See Also:
Constant Field Values

MUST_CONTAIN_KEY

public static final java.lang.String MUST_CONTAIN_KEY
Hashtable Key for the Must Key-Words

See Also:
Constant Field Values

MUSTNOT_CONTAIN_KEY

public static final java.lang.String MUSTNOT_CONTAIN_KEY
Hashtable Key for the Must-Not Key-Words

See Also:
Constant Field Values

NOT

public static final java.lang.String NOT
Search Pattern Boolean NOT modifier

See Also:
Constant Field Values

OR

public static final java.lang.String OR
Search Pattern Boolean OR modifier

See Also:
Constant Field Values
Constructor Detail

SearchPatternParser

private SearchPatternParser()
This utility class constructor is hidden

Method Detail

getTranslation

public static java.lang.String getTranslation(java.lang.String key)
Get the Translation for the given Search Key, which may be Boolean AND, OR and NOT.

Parameters:
key - The Key of the Search delimiter.
Returns:
String The Translation of the Search delimiter.

getClosestKeyword

private static int getClosestKeyword(java.lang.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 java.util.ArrayList parseMustAndMayWords(java.lang.String pattern)
Parse Words that should match the result (AND / OR)

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

generateRegEx

static java.util.ArrayList generateRegEx(java.util.ArrayList keys,
                                         boolean isWholeWord)
Generate a RegEx from the AND / OR keywords.

Parameters:
keys - List holding the AND / OR Keywords
isWholeWord - If TRUE, search for the entire word and not part of it.
Returns:
RegEx matching the keywords

parsePattern

static java.util.Hashtable parsePattern(java.lang.String pattern)
Parse the search pattern and return a Hashtable. The Hashtable contains one List for the Keywords that should NOT match the result and one List that should match the result (AND). The List for the AND-Keywords holds one List 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


RSSOwl - RSS / RDF / Atom Newsreader

SourceForge.net Logo