org.ceryle.wiki.plugin.query
Class Expression

java.lang.Object
  extended by org.ceryle.wiki.plugin.query.Expression
All Implemented Interfaces:
Operand
Direct Known Subclasses:
Assertion

public class Expression
extends Object
implements Operand

Expressions can be nested, combined with Operators and contain Terms. An expression when evaluated against a candidate page, returns true if the candidate page and all of its nested parts are acceptable.

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

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.ceryle.wiki.plugin.query.Operand
Operand.NullOperand
 
Field Summary
static Expression EMPTY
          An Empty expression accepts everything.
protected  Operand m_left
           
protected  Operator m_operator
           
protected static ExpressionParser m_parser
          This parser instance is used to do the string handling, it checks the string and builds up a list of logical elements that Expression attempts to disambiguate.
protected  Operand m_right
           
 
Fields inherited from interface org.ceryle.wiki.plugin.query.Operand
NULL
 
Constructor Summary
Expression(List list)
          Constructor taking a List of Terms, Operators and sub-Expressions that make up this expression.
Expression(Operand left, Operator operator, Operand right)
          Constructor where the Operator and two Operands of the Expression are explicit and already known.
 
Method Summary
 boolean accepts(String pageName, ReferenceInfoProvider refInfoProvider)
          Typically this method is only called by the QueryItem itsself to ask if the top-level expression would accept the pageName as being part of the result set.
 boolean evaluateOperand(Modifier modifier, ReferenceInfoProvider refInfoProvider, String pageName)
          Evaluates the operand, returns the truth value.
 Operand getLeftOperand()
           
 Operator getOperator()
           
 Operand getRightOperand()
           
static Expression parse(String queryString)
          Main parsing logic to turn a String into an Expression.
 String toString()
          Returns formal form of this expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY

public static final Expression EMPTY
An Empty expression accepts everything.


m_parser

protected static ExpressionParser m_parser
This parser instance is used to do the string handling, it checks the string and builds up a list of logical elements that Expression attempts to disambiguate.


m_left

protected Operand m_left

m_operator

protected Operator m_operator

m_right

protected Operand m_right
Constructor Detail

Expression

public Expression(Operand left,
                  Operator operator,
                  Operand right)
Constructor where the Operator and two Operands of the Expression are explicit and already known.

Parameters:
left - the left side ("subject") of the expression
operator - the operator ("verb") of the expression
right - the right side ("object") of the expression

Expression

public Expression(List list)
           throws QueryException
Constructor taking a List of Terms, Operators and sub-Expressions that make up this expression. Formalizes them into a proper series of nesting expressions, result is one top-level expression and a structured tree inside of it.

Parameters:
list -
Throws:
QueryException
Method Detail

parse

public static Expression parse(String queryString)
                        throws QueryException
Main parsing logic to turn a String into an Expression. This occurs in ExpressionParser. This might be better done via a parser generator.

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

getLeftOperand

public Operand getLeftOperand()

getOperator

public Operator getOperator()

getRightOperand

public Operand getRightOperand()

toString

public String toString()
Returns formal form of this expression.

Overrides:
toString in class Object

accepts

public boolean accepts(String pageName,
                       ReferenceInfoProvider refInfoProvider)
                throws QueryException
Typically this method is only called by the QueryItem itsself to ask if the top-level expression would accept the pageName as being part of the result set.

Parameters:
pageName -
refInfoProvider -
Returns:
true if pageName should be in the result set.
Throws:
QueryException

evaluateOperand

public boolean evaluateOperand(Modifier modifier,
                               ReferenceInfoProvider refInfoProvider,
                               String pageName)
                        throws QueryException
Description copied from interface: Operand
Evaluates the operand, returns the truth value.

Specified by:
evaluateOperand in interface Operand
Throws:
QueryException
See Also:
Operand


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