org.hyperic.sigar.shell
Class ShellCommandBase

java.lang.Object
  extended by org.hyperic.sigar.shell.ShellCommandBase
All Implemented Interfaces:
ShellCommandHandler
Direct Known Subclasses:
MultiwordShellCommand, ShellCommand_alias, ShellCommand_get, ShellCommand_help, ShellCommand_quit, ShellCommand_set, ShellCommand_sleep, ShellCommand_source, SigarCommandBase

public class ShellCommandBase
extends java.lang.Object
implements ShellCommandHandler


Field Summary
protected  java.lang.String itsCommandName
           
protected  ShellBase itsShell
           
 
Constructor Summary
ShellCommandBase()
           
 
Method Summary
 java.lang.String getCommandName()
           
 java.io.PrintStream getErrStream()
           
 java.io.PrintStream getOutStream()
           
 ShellBase getShell()
           
 java.lang.String getSyntax()
          Get a description of the syntax for how a command should be invoked.
 java.lang.String getSyntaxArgs()
           
 java.lang.String getUsageHelp(java.lang.String[] args)
          Get some info on how to invoke this command.
 java.lang.String getUsageShort()
          Get a very brief (40 character) description of the command
 void init(java.lang.String commandName, ShellBase shell)
          Initialize this command handler.
 void processCommand(java.lang.String[] args)
          Handle a command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

itsCommandName

protected java.lang.String itsCommandName

itsShell

protected ShellBase itsShell
Constructor Detail

ShellCommandBase

public ShellCommandBase()
Method Detail

getCommandName

public java.lang.String getCommandName()

getShell

public ShellBase getShell()

getOutStream

public java.io.PrintStream getOutStream()

getErrStream

public java.io.PrintStream getErrStream()

init

public void init(java.lang.String commandName,
                 ShellBase shell)
          throws ShellCommandInitException
Description copied from interface: ShellCommandHandler
Initialize this command handler.

Specified by:
init in interface ShellCommandHandler
Parameters:
commandName - The name of the command.
shell - The shell. This is useful for command that need to be able to interpret other commands, like the "help" command, and for commands that need to get additional user input, for example a login command that presents a password prompt.
Throws:
ShellCommandInitException

processCommand

public void processCommand(java.lang.String[] args)
                    throws ShellCommandUsageException,
                           ShellCommandExecException
Description copied from interface: ShellCommandHandler
Handle a command.

Specified by:
processCommand in interface ShellCommandHandler
Parameters:
args - The args to the command.
Throws:
ShellCommandUsageException - If the args are malformed.
ShellCommandExecException - If an error occurred executing the command.

getSyntax

public java.lang.String getSyntax()
Description copied from interface: ShellCommandHandler
Get a description of the syntax for how a command should be invoked.

Specified by:
getSyntax in interface ShellCommandHandler
Returns:
A description of the syntax

getSyntaxArgs

public java.lang.String getSyntaxArgs()

getUsageShort

public java.lang.String getUsageShort()
Description copied from interface: ShellCommandHandler
Get a very brief (40 character) description of the command

Specified by:
getUsageShort in interface ShellCommandHandler
Returns:
A description of the command.

getUsageHelp

public java.lang.String getUsageHelp(java.lang.String[] args)
Description copied from interface: ShellCommandHandler
Get some info on how to invoke this command.

Specified by:
getUsageHelp in interface ShellCommandHandler
Returns:
Some usage information on how this command is expected to be invoked.


Copyright ? 2004-2009 Hyperic. All Rights Reserved.