org.ceryle.wiki.plugin.assertion
Class AssertionProcessor

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

public class AssertionProcessor
extends ExpressionParser
implements PluginConstants

This takes over after the Assertion syntax has been parsed, receiving its input as a List. But apart from its input, this class performs roughly the same post-processing as ExpressionParser, returning either an Expression or an Assertion (a subclass of Expression).

Author:
Murray Altheim

Field Summary
static String ANYPAGE
          The string value indicating a reference to any page.
static boolean requirePageOnOutput
          When true, pages must exist for each term in the expression or an exception is thrown.
static String THISPAGE
          The string value indicating the page the assertion occurs on.
 
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
AssertionProcessor(WikiEngine engine)
          Constructor with the WikiEngine engine.
 
Method Summary
 void convertTerms(List list, String pagename)
          Converts any square-bracketed Strings in the List list with Terms.
protected  List makeExpressionsExplicit(WikiContext context, List list, boolean isTemplate)
          Create expressions based on use of explicit parentheses in the expression.
 void pageCheck(WikiEngine engine, Term subject)
          Throws an AssertionException if the referenced subject page doesn't exist.
 void pageCheck(WikiEngine engine, Term subject, Predicate predicate, Term object)
          Throws an AssertionException if any of the referenced pages don't exist.
 Expression parse(String queryString)
          Not used in this class, since it is meant to receive pre-parsed content.
 Expression process(WikiContext context, List statement, boolean isTemplate)
          This holds roughly the same place as parse(String) in ExpressionParser, except that the preliminaries are already handled, so this takes a List.
protected  List replaceOperators(List list)
          Replace string names of operators with Operator instances.
 
Methods inherited from class org.ceryle.wiki.plugin.query.ExpressionParser
collapseBracketedTerms, explicitExpressions, findLastOpen, findNextClose, syntaxCheckBrackets
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

requirePageOnOutput

public static boolean requirePageOnOutput
When true, pages must exist for each term in the expression or an exception is thrown.


THISPAGE

public static final String THISPAGE
The string value indicating the page the assertion occurs on. The value is "[.]".

See Also:
Constant Field Values

ANYPAGE

public static final String ANYPAGE
The string value indicating a reference to any page. The value is "[*]". This is a synonym for the more correct regex, "[.*]".

See Also:
Constant Field Values
Constructor Detail

AssertionProcessor

public AssertionProcessor(WikiEngine engine)
Constructor with the WikiEngine engine.

Method Detail

parse

public Expression parse(String queryString)
Not used in this class, since it is meant to receive pre-parsed content. Use process(WikiContext,List,boolean) instead.

Overrides:
parse in class ExpressionParser
Returns:
the generated Expression
Throws:
UnsupportedOperationException - if called

process

public Expression process(WikiContext context,
                          List statement,
                          boolean isTemplate)
                   throws QueryException
This holds roughly the same place as parse(String) in ExpressionParser, except that the preliminaries are already handled, so this takes a List.

Parameters:
context - the WikiContext providing the wiki page declaring the Assertion
statement - the List of tokens to process into an Expression or Assertion
isTemplate - if true, the resulting Assertion is considered an assertion template.
Returns:
either an Assertion or its superclass, Expression
Throws:
AssertionException - if any component of the Expression is invalid.
QueryException

pageCheck

public void pageCheck(WikiEngine engine,
                      Term subject)
               throws AssertionException
Throws an AssertionException if the referenced subject page doesn't exist.

Throws:
AssertionException

pageCheck

public void pageCheck(WikiEngine engine,
                      Term subject,
                      Predicate predicate,
                      Term object)
               throws AssertionException
Throws an AssertionException if any of the referenced pages don't exist. Any error message will describe specifically the missing page(s).

Throws:
AssertionException

convertTerms

public void convertTerms(List list,
                         String pagename)
Converts any square-bracketed Strings in the List list with Terms. If the pagename parameter is non-null, any instances of "[.]" will be replaced by "[pagename]".


replaceOperators

protected List replaceOperators(List list)
Replace string names of operators with Operator instances. If there is unrecognizable text throw, returned stack will only have "(", ")", Term and Operator instances in it. This overrides ExpressionParser.replaceOperators(List), but rather than throw an RuntimeException on encountering unknown text, permits the creation of custom, user-defined Predicates. The Predicate creation will itself fail if not backed by a properly-established wiki page asserted as a WikiVerb instance.

Overrides:
replaceOperators in class ExpressionParser
Parameters:
list -
Returns:
the modified List

makeExpressionsExplicit

protected List makeExpressionsExplicit(WikiContext context,
                                       List list,
                                       boolean isTemplate)
                                throws QueryException
Create expressions based on use of explicit parentheses in the expression. Basically overrides ExpressionParser.explicitExpressions(List), except it has been renamed because this method can throw an AssertionException.

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


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