org.mycore.services.fieldquery
Class MCRQueryParser

java.lang.Object
  extended by org.mycore.parsers.bool.MCRBooleanClauseParser
      extended by org.mycore.services.fieldquery.MCRQueryParser

public class MCRQueryParser
extends MCRBooleanClauseParser

Parses query conditions for use in MCRSearcher.

Author:
Frank Lützenkirchen
See Also:
MCRSearcher

Constructor Summary
MCRQueryParser()
           
 
Method Summary
(package private) static MCRCondition normalizeCondition(MCRCondition cond)
          Normalizes a parsed query condition.
 MCRCondition parse(Element condition)
           
 MCRCondition parse(String s)
           
protected  MCRCondition parseSimpleCondition(Element e)
          Parses XML element containing a simple query condition
protected  MCRCondition parseSimpleCondition(String s)
          Parses a String containing a simple query condition, for example: (title contains "Java") and (creatorID = "122132131")
static boolean validateQueryExpression(String query)
          Used for input validation in editor search form
 
Methods inherited from class org.mycore.parsers.bool.MCRBooleanClauseParser
defaultRule, main
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MCRQueryParser

public MCRQueryParser()
Method Detail

parseSimpleCondition

protected MCRCondition parseSimpleCondition(Element e)
                                     throws MCRParseException
Parses XML element containing a simple query condition

Overrides:
parseSimpleCondition in class MCRBooleanClauseParser
Parameters:
e - the 'condition' element
Returns:
the parsed MCRQueryCondition object
Throws:
MCRParseException

parseSimpleCondition

protected MCRCondition parseSimpleCondition(String s)
                                     throws MCRParseException
Parses a String containing a simple query condition, for example: (title contains "Java") and (creatorID = "122132131")

Overrides:
parseSimpleCondition in class MCRBooleanClauseParser
Parameters:
s - the condition as a String
Returns:
the parsed MCRQueryCondition object
Throws:
MCRParseException

parse

public MCRCondition parse(Element condition)
                   throws MCRParseException
Overrides:
parse in class MCRBooleanClauseParser
Throws:
MCRParseException

parse

public MCRCondition parse(String s)
                   throws MCRParseException
Overrides:
parse in class MCRBooleanClauseParser
Throws:
MCRParseException

normalizeCondition

static MCRCondition normalizeCondition(MCRCondition cond)
Normalizes a parsed query condition. AND/OR conditions that just have one child will be replaced with that child. NOT(NOT(X)) will be normalized to X. (A AND (b AND c)) will be normalized to (A AND B AND C), same for nested ORs. AND/OR/NOT conditions with no child conditions will be removed. Conditions that use the operator "contains" will be splitted into multiple simpler conditions if the condition value contains phrases surrounded by '...' or wildcard search with * or ?.


validateQueryExpression

public static boolean validateQueryExpression(String query)
Used for input validation in editor search form