org.ceryle.wiki.plugin.query
Class ExpressionParser

java.lang.Object
  extended by org.ceryle.wiki.plugin.query.ExpressionParser
All Implemented Interfaces:
PluginConstants
Direct Known Subclasses:
AssertionProcessor

public class ExpressionParser
extends Object
implements PluginConstants

This is the first line of defense against bad query strings. Parses from the original string form into Terms, Operators and if the user explicitly had parenthesis, sub-Expressions.

Author:
John Volkar (john.volkar at gmail.com), Murray Altheim

Field Summary
 
Fields inherited from interface org.ceryle.wiki.plugin.util.PluginConstants
ACL, AOP, APOS_ENT, ASTERISK, BCL, BOP, BR, CAPCL, CAPOP, CLATT, COLON, COMMA, DIV_class, DIV_style, DIVCL, DOT, EQ, EQQUO, EQSQUO, FALSE, FORMCL, FORMOP, GET, ICL, INPUTOP, IOP, LABELCL, LABELFOR, LABELOP, LCURL, LICL, LIOP, LPAR, LSBR, MT, NBSP, NL, OLCL, OLOP, P_class, PCL, PLUGCL, PLUGO, POP, POST, QUO, QUOCL, QUOETCL, RCURL, RPAR, RSBR, SEMI, SP, SPAN_class, SPANCL, SPANOP, SQUO, TABLECL, TABLEOP, TDCL, TDOP, THCL, THOP, TRCL, TROP, TRUE, TTCL, TTOP, ULCL, ULOP, UNDER
 
Constructor Summary
ExpressionParser()
           
 
Method Summary
protected  List collapseBracketedTerms(List list)
          Join back together the bracketed page names.
protected  List explicitExpressions(List list)
          Create expressions based on use of explicit parentheses in the expression.
protected  int findLastOpen(List list)
           
protected  int findNextClose(List list, int startIndex)
           
 Expression parse(String queryString)
          Parse the string and return one top-level expression which if toString()'d would show the canonical form that the user should have given if his syntax was perfect.
protected  List replaceOperators(List list)
          Replace string names of operators with Operator instances.
protected  void syntaxCheckBrackets(CharacterIterator iter)
          Square brackets must exist balance and NOT nest...
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpressionParser

public ExpressionParser()
Method Detail

parse

public Expression parse(String queryString)
                 throws QueryException
Parse the string and return one top-level expression which if toString()'d would show the canonical form that the user should have given if his syntax was perfect.

Parameters:
queryString -
Returns:
the generated Expression
Throws:
QueryException

collapseBracketedTerms

protected List collapseBracketedTerms(List list)
Join back together the bracketed page names.

Parameters:
list -
Returns:
the processed List

replaceOperators

protected List replaceOperators(List list)
                         throws QueryException
Replace string names of operators with Operator instances. If there is unrecognizable text throw a QueryException. Returned list will only have "(", ")", Term and Operator instances in it. The String comparisons are made on intern()'d Strings, so this is relatively fast.

Parameters:
list - the input List
Returns:
the modified List
Throws:
QueryException

explicitExpressions

protected List explicitExpressions(List list)
                            throws QueryException
Create expressions based on use of explicit parentheses in the expression.

Parameters:
list - the input List
Returns:
the modified List
Throws:
QueryException

findLastOpen

protected int findLastOpen(List list)

findNextClose

protected int findNextClose(List list,
                            int startIndex)

syntaxCheckBrackets

protected void syntaxCheckBrackets(CharacterIterator iter)
                            throws QueryException
Square brackets must exist balance and NOT nest...

Parameters:
chars -
Throws:
QueryException


The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.