comshell
Class Command

java.lang.Object
  |
  +--comshell.Command

public class Command
extends java.lang.Object

Supports methods for a command line interface

Author:
Scott Sanner

Field Summary
 java.io.BufferedReader br
           
 java.lang.String[] comnames
          Command/Help index
 boolean echo
           
static int ECHO
           
static int EXEC
           
static int HELP
           
 java.lang.String[] helpstring
           
 java.io.InputStream is
           
static int LISTE
          Basic common commands
static int MAX_COMMANDS
           
static int MAX_INPUT
          Static members
 java.io.PrintStream os
           
 java.util.ArrayList params
           
static int REXEC
           
static int SET
           
 int type
          Class members
 int UNKNOWN
           
 
Constructor Summary
Command(java.io.InputStream is, java.io.PrintStream os)
          Constructor
 
Method Summary
 int addCommand(java.lang.String cname, java.lang.String helpstr)
          Registers a new command with the interface
 void clear()
          Clears the last command and resets to UNKNOWN
 java.lang.String getParam(int index)
          Retrieves a parameter for a command
 int numParams()
          Returns number of params for command
 void parseStream()
          Parses the current input stream.
 void setEcho(boolean e)
          Turns echo on or off
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_INPUT

public static final int MAX_INPUT
Static members

MAX_COMMANDS

public static final int MAX_COMMANDS

LISTE

public static final int LISTE
Basic common commands

SET

public static final int SET

HELP

public static final int HELP

ECHO

public static final int ECHO

EXEC

public static final int EXEC

REXEC

public static final int REXEC

UNKNOWN

public int UNKNOWN

comnames

public java.lang.String[] comnames
Command/Help index

helpstring

public java.lang.String[] helpstring

type

public int type
Class members

echo

public boolean echo

params

public java.util.ArrayList params

br

public java.io.BufferedReader br

is

public java.io.InputStream is

os

public java.io.PrintStream os
Constructor Detail

Command

public Command(java.io.InputStream is,
               java.io.PrintStream os)
Constructor
Parameters:
is - InputStream to process
os - OutputStream to write data to
Method Detail

addCommand

public int addCommand(java.lang.String cname,
                      java.lang.String helpstr)
Registers a new command with the interface
Parameters:
cname - The command name (as it will be invoked)
helpstr - Help information to printed out when listing this command
Returns:
ID for the new command

setEcho

public void setEcho(boolean e)
Turns echo on or off
Parameters:
e - Set true for echo on

clear

public void clear()
Clears the last command and resets to UNKNOWN

numParams

public int numParams()
Returns number of params for command
Returns:
Number of valid parameters

getParam

public java.lang.String getParam(int index)
Retrieves a parameter for a command
Parameters:
index - Which parameter to access
Returns:
The string for the parameter index

parseStream

public void parseStream()
                 throws java.io.IOException
Parses the current input stream. Handles file/terminal IO as well as Windows and UNIX carriage-return/linefeed issues.