net.sf.tomp.xtcl.command
Class AbstractCommand

java.lang.Object
  extended by net.sf.tomp.xtcl.command.AbstractCommand
All Implemented Interfaces:
Command
Direct Known Subclasses:
CatchCommand, Dump, DumpContext, DumpContexts, Echo, End, Err, ExeCommand, Function, Help, JavaCommand, Label, Remove, Ret, Sequence, Template, Transform, TryBlock, VarCommand, Verbose

public class AbstractCommand
extends java.lang.Object
implements Command

Base class for (almost all) built-in Commands in XTCL. Provides utility instance methods such as done, initParameters, and static methods: listMap,...

Author:
tomp

Constructor Summary
AbstractCommand()
           
 
Method Summary
 int done(Context c, int i)
          Executed always after the command itself.
 int execute(Context c)
          Do-nothing execution of an empty command.
protected static int initParameters(java.util.Map params, java.util.Map realParams, Parametrized f, Context context)
          DOCUMENT ME!
static java.lang.String listArray(java.lang.Object[] os)
          Prettyprints an object array to a String
static java.lang.String listList(java.util.List m)
          As listArray but for Lists
static java.lang.String listMap(java.util.Map m)
          Prettyprints a Map
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCommand

public AbstractCommand()
Method Detail

execute

public int execute(Context c)
            throws java.lang.Exception
Do-nothing execution of an empty command.

Specified by:
execute in interface Command
Parameters:
c - Context this command will be executed in.
Returns:
always 0 == success, OK
Throws:
java.lang.Exception - only if I/O error occurs when reporting the result to user.

done

public int done(Context c,
                int i)
         throws java.lang.Exception
Executed always after the command itself. Prints the OK, ERR on the Context's std. out.

Parameters:
c - Context
i - result of previously called Command
Returns:
same as i
Throws:
java.lang.Exception - if I/O error occurs when reporting the result to user.

initParameters

protected static int initParameters(java.util.Map params,
                                    java.util.Map realParams,
                                    Parametrized f,
                                    Context context)
DOCUMENT ME!

Parameters:
params - contains formal parameters pairs (key->value) the values are used as keys to refer objects in the context values of such references are set to Parametrized f and put to realParams
realParams - here the real parameter pairs are put
f - here the real parameter pairs are set
context - context to get the real params from
Returns:
0 means OK, 1 means error: when strictParsing is on and a parameter reference is not found in the Context

listArray

public static java.lang.String listArray(java.lang.Object[] os)
Prettyprints an object array to a String

Parameters:
os - the array to be formatted
Returns:
resulting String

listList

public static java.lang.String listList(java.util.List m)
As listArray but for Lists

Parameters:
m - the List to be formatted
Returns:
the resulting String

listMap

public static java.lang.String listMap(java.util.Map m)
Prettyprints a Map

Parameters:
m - the Map
Returns:
the resulting String


Copyright © 2004-2005 Masaryk University in Brno, Faculty of Informatics, Czech Republic. All Rights Reserved.