org.ceryle.wiki.plugin.assertion
Class AssertionPlugin

java.lang.Object
  extended by org.ceryle.wiki.plugin.assertion.AssertionPlugin
All Implemented Interfaces:
InitializablePlugin, WikiPlugin, PluginConstants
Direct Known Subclasses:
Assert, Category

public class AssertionPlugin
extends Object
implements WikiPlugin, PluginConstants, InitializablePlugin

The AssertionPlugin is used to make a wiki assertion. This plugin does its own internal parsing and therefore relies on the availability of the entire plugin command line taken from a parameter named "_expression" (CommandLineParser.PARAM_EXPRESSION).

Parameters

Note: hide overrides debug. Debug sets echo true.

Example

    [{Assert debug='true' [Fido] Isa [Dog] }]
  

Notes

This plugin is not based on QueryPlugin but does have dependencies on both it and some common QueryPlugin-related classes.

The interaction of the parameters and an attempt at helpful error messages means that the output section of this plugin is rather convoluted.

Author:
Murray Altheim

Field Summary
protected static org.apache.log4j.Logger log
           
protected  WikiContext m_context
           
protected  boolean m_debug
           
protected  boolean m_echo
           
protected  String m_emptyText
           
protected  WikiEngine m_engine
           
protected  AssertionHandler m_handler
           
protected  boolean m_hide
           
protected  boolean m_isTemplate
           
protected  int m_outputFormat
           
protected  Map m_params
           
protected  AssertionProcessor m_parser
           
protected static QueryItemManager m_queryManager
           
protected  String NoPagesFound
           
static String PARAM_ECHO
           
static String PARAM_HIDE
           
static String PARAM_OUTPUT
           
static String PARAM_TEMPLATE
           
static String PLUGIN_NAME
           
 
Fields inherited from interface com.ecyrd.jspwiki.plugin.WikiPlugin
CORE_PLUGINS_RESOURCEBUNDLE
 
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
AssertionPlugin()
           
 
Method Summary
protected  boolean appendErrorMessage(StringBuffer out, Exception exception, Expression expr, String body)
          Appends a suitable error message.
protected  void assertionError(WikiContext context, StringBuffer out, Exception exception)
          Process an error by clearing the existing buffer and populating it with an error message.
protected  Stack convertToTerms(Map params, String pagename)
          Converts the terms of the expression.
protected  void error(WikiContext context, StringBuffer out, Exception e)
          Process an error by clearing the existing buffer and populating it with an error message.
 String execute(WikiContext context, Map params)
          Execute the plugin, obtaining the '_cmdline' parameter, processing accordingly, returning XHTML-compatible markup.
 WikiEngine getEngine()
          Returns the WikiEngine supporting the wiki environment of this plugin.
 void initialize(WikiContext context, Map map)
          For compliance with earlier versions of the InitializablePlugin API.
 void initialize(WikiEngine engine)
          The initialization method.
protected  void processExpression(StringBuffer out, String body, Stack terms)
          Parses the parameter Map, processing and converting the terms as necessary.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.log4j.Logger log

PLUGIN_NAME

public static String PLUGIN_NAME

PARAM_ECHO

public static final String PARAM_ECHO
See Also:
Constant Field Values

PARAM_HIDE

public static final String PARAM_HIDE
See Also:
Constant Field Values

PARAM_OUTPUT

public static final String PARAM_OUTPUT
See Also:
Constant Field Values

PARAM_TEMPLATE

public static final String PARAM_TEMPLATE
See Also:
Constant Field Values

NoPagesFound

protected String NoPagesFound

m_emptyText

protected String m_emptyText

m_context

protected WikiContext m_context

m_params

protected Map m_params

m_echo

protected boolean m_echo

m_hide

protected boolean m_hide

m_isTemplate

protected boolean m_isTemplate

m_debug

protected boolean m_debug

m_outputFormat

protected int m_outputFormat

m_queryManager

protected static QueryItemManager m_queryManager

m_handler

protected AssertionHandler m_handler

m_parser

protected AssertionProcessor m_parser

m_engine

protected WikiEngine m_engine
Constructor Detail

AssertionPlugin

public AssertionPlugin()
Method Detail

execute

public String execute(WikiContext context,
                      Map params)
Execute the plugin, obtaining the '_cmdline' parameter, processing accordingly, returning XHTML-compatible markup.

Specified by:
execute in interface WikiPlugin
Parameters:
context -
params -
Returns:
the generated output to be displayed on the wiki page.
See Also:
WikiPlugin.execute(com.ecyrd.jspwiki.WikiContext,java.util.Map)

getEngine

public WikiEngine getEngine()
Returns the WikiEngine supporting the wiki environment of this plugin.


convertToTerms

protected Stack convertToTerms(Map params,
                               String pagename)
                        throws PluginException
Converts the terms of the expression.

Throws:
PluginException

processExpression

protected void processExpression(StringBuffer out,
                                 String body,
                                 Stack terms)
                          throws QueryException,
                                 AssertionException,
                                 PluginException
Parses the parameter Map, processing and converting the terms as necessary.

Throws:
QueryException
AssertionException
PluginException

appendErrorMessage

protected boolean appendErrorMessage(StringBuffer out,
                                     Exception exception,
                                     Expression expr,
                                     String body)
Appends a suitable error message. Returns true if echo should be turned on, based on the kind of error.


assertionError

protected void assertionError(WikiContext context,
                              StringBuffer out,
                              Exception exception)
Process an error by clearing the existing buffer and populating it with an error message. The WikiContext is optional; if provided, it suggests help with a link to the "Assert" wiki page.


error

protected void error(WikiContext context,
                     StringBuffer out,
                     Exception e)
Process an error by clearing the existing buffer and populating it with an error message. The WikiContext is optional; if provided, it suggests help with a link to the "Assert" wiki page.


initialize

public void initialize(WikiContext context,
                       Map map)
                throws PluginException
For compliance with earlier versions of the InitializablePlugin API.

Throws:
PluginException

initialize

public void initialize(WikiEngine engine)
                throws PluginException
The initialization method. The context is to a Wiki page, and the parameters are exactly like in the execute() method. However, this method is not expected to return anything, as any output will be discarded.

Specified by:
initialize in interface InitializablePlugin
Throws:
PluginException


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