org.overturetool.vdmj.commands
Class CommandReader

java.lang.Object
  extended by org.overturetool.vdmj.commands.CommandReader
Direct Known Subclasses:
ClassCommandReader, DebuggerReader, ModuleCommandReader

public abstract class CommandReader
extends java.lang.Object

A class to read and perform commands from standard input.


Field Summary
protected  Interpreter interpreter
          The interpreter to use for the execution of commands.
protected  java.lang.String prompt
          The prompt for the user.
 
Constructor Summary
CommandReader(Interpreter interpreter, java.lang.String prompt)
          Create a command reader with the given interpreter and prompt.
 
Method Summary
 boolean assertFile(java.io.File filename)
           
protected  boolean doAssert(java.lang.String line)
           
protected  boolean doBreak(java.lang.String line)
           
protected  boolean doClasses(java.lang.String line)
           
protected  boolean doContinue(java.lang.String line)
           
protected  boolean doCoverage(java.lang.String line)
           
protected  boolean doCreate(java.lang.String line)
           
protected  boolean doDefault(java.lang.String line)
           
protected  boolean doDown(java.lang.String line)
           
protected  boolean doEnv(java.lang.String line)
           
protected  boolean doEvaluate(java.lang.String line)
           
protected  boolean doException(java.lang.Exception e)
           
protected  boolean doFiles()
           
protected  void doHelp(java.lang.String line)
           
protected  boolean doInit(java.lang.String line)
           
protected  boolean doList(java.lang.String line)
           
protected  boolean doLoad(java.lang.String line, java.util.List<java.io.File> filenames)
           
protected  boolean doLog(java.lang.String line)
           
protected  boolean doModules(java.lang.String line)
           
protected  boolean doNext(java.lang.String line)
           
protected  boolean doOut(java.lang.String line)
           
protected  boolean doPog(java.lang.String line)
           
protected  boolean doQuit(java.lang.String line)
           
protected  boolean doReLoad(java.lang.String line)
           
protected  boolean doRemove(java.lang.String line)
           
protected  boolean doSource(java.lang.String line)
           
protected  boolean doStack(java.lang.String line)
           
protected  boolean doState(java.lang.String line)
           
protected  boolean doStep(java.lang.String line)
           
protected  boolean doStop(java.lang.String line)
           
protected  boolean doThreads(java.lang.String line)
           
protected  boolean doTrace(java.lang.String line)
           
protected  boolean doUp(java.lang.String line)
           
protected  boolean notAvailable(java.lang.String line)
          Callable by "do" methods which want to make the command unavailable.
protected  java.lang.String plural(int n, java.lang.String s, java.lang.String pl)
           
protected static void print(java.lang.String m)
           
protected static void println(java.lang.String m)
           
 ExitStatus run(java.util.List<java.io.File> filenames)
          Read and execute commands from standard input.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

interpreter

protected final Interpreter interpreter
The interpreter to use for the execution of commands.


prompt

protected final java.lang.String prompt
The prompt for the user.

Constructor Detail

CommandReader

public CommandReader(Interpreter interpreter,
                     java.lang.String prompt)
Create a command reader with the given interpreter and prompt.

Parameters:
interpreter - The interpreter instance to use.
prompt - The user prompt.
Method Detail

run

public ExitStatus run(java.util.List<java.io.File> filenames)
Read and execute commands from standard input. The prompt passed to the constructor is used to prompt the user, and the interpreter passed is used to execute commands. Each command is directed through the corresponding "do" method in this class, the defaults for which print that the command is not available from the current context. Subclasses of CommandReader implement the "do" methods that apply to them. The only methods implemented at this level are the ones which are globally applicable.

The "do" methods return a boolean which indicates whether the command reader should loop and read/dispatch more commands, or exit.


doException

protected boolean doException(java.lang.Exception e)

doEvaluate

protected boolean doEvaluate(java.lang.String line)

doQuit

protected boolean doQuit(java.lang.String line)

doStop

protected boolean doStop(java.lang.String line)

doModules

protected boolean doModules(java.lang.String line)

doClasses

protected boolean doClasses(java.lang.String line)

doFiles

protected boolean doFiles()

doPog

protected boolean doPog(java.lang.String line)

doLog

protected boolean doLog(java.lang.String line)

doCreate

protected boolean doCreate(java.lang.String line)
                    throws java.lang.Exception
Throws:
java.lang.Exception

doDefault

protected boolean doDefault(java.lang.String line)
                     throws java.lang.Exception
Throws:
java.lang.Exception

doInit

protected boolean doInit(java.lang.String line)

doEnv

protected boolean doEnv(java.lang.String line)

doState

protected boolean doState(java.lang.String line)

doRemove

protected boolean doRemove(java.lang.String line)

doList

protected boolean doList(java.lang.String line)

doSource

protected boolean doSource(java.lang.String line)

doCoverage

protected boolean doCoverage(java.lang.String line)

doBreak

protected boolean doBreak(java.lang.String line)
                   throws java.lang.Exception
Throws:
java.lang.Exception

doTrace

protected boolean doTrace(java.lang.String line)
                   throws java.lang.Exception
Throws:
java.lang.Exception

doStep

protected boolean doStep(java.lang.String line)

doNext

protected boolean doNext(java.lang.String line)

doOut

protected boolean doOut(java.lang.String line)

doStack

protected boolean doStack(java.lang.String line)

doUp

protected boolean doUp(java.lang.String line)

doDown

protected boolean doDown(java.lang.String line)

doContinue

protected boolean doContinue(java.lang.String line)

doThreads

protected boolean doThreads(java.lang.String line)

doAssert

protected boolean doAssert(java.lang.String line)

doReLoad

protected boolean doReLoad(java.lang.String line)

doLoad

protected boolean doLoad(java.lang.String line,
                         java.util.List<java.io.File> filenames)

assertFile

public boolean assertFile(java.io.File filename)

doHelp

protected void doHelp(java.lang.String line)

notAvailable

protected boolean notAvailable(java.lang.String line)
Callable by "do" methods which want to make the command unavailable. The method just prints "Command not available in this context" and returns true.


print

protected static void print(java.lang.String m)

println

protected static void println(java.lang.String m)

plural

protected java.lang.String plural(int n,
                                  java.lang.String s,
                                  java.lang.String pl)


Copyright © 2009. All Rights Reserved.