org.ceryle.wiki.plugin.util
Class CommandLineParser

java.lang.Object
  extended by org.ceryle.wiki.plugin.util.CommandLineParser
All Implemented Interfaces:
PluginConstants

public class CommandLineParser
extends Object
implements PluginConstants

The CommandLineParser provides a plugin command line parser that also provides parsing of the "body" as a balanced query or assertion expression. It accepts either an existing parameter Map or a "{}" delimited plugin command line. All methods are static.

Parses the initial, required part of the plugin command line with four permitted variants:

        '[{XYZ name='value' [Monster] eats [Sandwich]}]'
  or:   '[{XYZPlugin name='value' [Monster] eats [Sandwich]}]'
  or:   '[{java.package.path.XYZPlugin name='value' [Monster] eats [Sandwich]}]'
  or:   '[{INSERT java.package.path.XYZPlugin name='value' [Monster] eats [Sandwich]}]'
 

NOTE: This doesn't actually validate the plugin identifier because we can safely assume it must match one of the forms of the plugin name or it wouldn't have been called in the first place.

Provides

A parameter Map containing the name-value pairs, where each element in the Map can be obtained via the Map.get(Object) method. In addition to the named elements, there are two additional outputs:

Author:
Murray Altheim

Field Summary
static String PARAM_BODY
          The identifier for the body parameter, _body.
static String PARAM_EXPRESSION
          The identifier for the expression parameter, _expression.
 
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
CommandLineParser()
           
 
Method Summary
static Map parse(WikiEngine engine, Map params)
          Process the incoming parameter Map map, returning a newly-parsed replacement parameter Map.
static Map parse(WikiEngine engine, String commandline)
          Process the incoming plugin command line commandline, creating a parameter Map that includes both a _body parameter containing all post-argument content as a String, and a _expression parameter, a balanced Stack of tokens.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PARAM_BODY

public static final String PARAM_BODY
The identifier for the body parameter, _body.

See Also:
Constant Field Values

PARAM_EXPRESSION

public static final String PARAM_EXPRESSION
The identifier for the expression parameter, _expression.

See Also:
Constant Field Values
Constructor Detail

CommandLineParser

public CommandLineParser()
Method Detail

parse

public static Map parse(WikiEngine engine,
                        Map params)
                 throws PluginException
Process the incoming parameter Map map, returning a newly-parsed replacement parameter Map. Returns the original Map parameter if there is no command line content.

Parameters:
engine - the WikiEngine providing support to the plugin.
params - the incoming parameter Map containing the _cmdline parameter source
Returns:
the generated parameter Map
Throws:
PluginException - if a parsing error occurs
See Also:
parse(WikiEngine,String)

parse

public static Map parse(WikiEngine engine,
                        String commandline)
                 throws PluginException
Process the incoming plugin command line commandline, creating a parameter Map that includes both a _body parameter containing all post-argument content as a String, and a _expression parameter, a balanced Stack of tokens. Returns an empty Map if the command line is null, composed of whitespace or an empty string.

Parameters:
engine - the WikiEngine providing support to the plugin.
commandline - the incoming command line to be parsed
Returns:
the generated parameter Map
Throws:
PluginException - if a parsing error occurs


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