Hyperic HQ Plugin API v. 4.4.0.2

org.hyperic.util.shell
Class ShellBase

java.lang.Object
  extended by org.hyperic.util.shell.ShellBase
All Implemented Interfaces:
ShellCommandMapper

public abstract class ShellBase
extends java.lang.Object
implements ShellCommandMapper


Field Summary
static java.lang.String PROP_PAGE_SIZE
           
 
Constructor Summary
ShellBase()
           
 
Method Summary
 java.util.Iterator getCommandNameIterator()
          Get an iterator for the command names.
 PageControl getDefaultPageControl()
           
 java.io.PrintStream getErrStream()
           
 ShellCommandHandler getHandler(java.lang.String command)
          Get the command handler for a command.
 java.lang.String getHiddenInput(java.lang.String prompt)
          If a command needs additional input via the console, they can get it this way.
 java.lang.String getInput(java.lang.String prompt)
          If a command needs additional input via the console, they can get it this way.
 java.lang.String getInput(java.lang.String prompt, boolean addToHistory)
          If a command needs additional input via the console, they can get it this way.
 java.io.PrintStream getOutStream()
           
 int getPageSize()
          Get the current page size used when paging data.
 void handleCommand(java.lang.String line)
           
 void handleCommand(java.lang.String line, java.lang.String[] args)
           
 void init(java.lang.String applicationName, java.io.PrintStream out, java.io.PrintStream err)
           
 boolean isRedirected()
          Check to see if the currently running shell command is being redirected to a file.
 void performPaging(PageFetcher fetcher)
           
 void performPaging(PageFetcher fetcher, PageControl control)
           
 void processCommand(ShellCommandHandler handler, java.lang.String[] args)
           
 void readRCFile(java.io.File rcFile, boolean echoCommands)
          Read a .rc file into the shell, invoking everything in it (without saving the actions to history)
 void registerCommandHandler(java.lang.String commandName, ShellCommandHandler handler)
          Register a new command handler.
 void run()
           
 void sendToErrStream(java.lang.String s)
          Write a string to this shell's output stream.
 void sendToOutStream(java.lang.String s)
          Write a string to this shell's output stream.
 void setPageSize(int size)
          Set the page size for data paging.
 void setPrompt(java.lang.String prompt)
          Change the prompt
 void shutdown()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_PAGE_SIZE

public static final java.lang.String PROP_PAGE_SIZE
See Also:
Constant Field Values
Constructor Detail

ShellBase

public ShellBase()
Method Detail

init

public void init(java.lang.String applicationName,
                 java.io.PrintStream out,
                 java.io.PrintStream err)

readRCFile

public void readRCFile(java.io.File rcFile,
                       boolean echoCommands)
                throws java.io.IOException
Read a .rc file into the shell, invoking everything in it (without saving the actions to history)

Parameters:
rcFile - File to read
Throws:
java.io.IOException

setPrompt

public void setPrompt(java.lang.String prompt)
Change the prompt

Parameters:
prompt -

registerCommandHandler

public void registerCommandHandler(java.lang.String commandName,
                                   ShellCommandHandler handler)
                            throws ShellCommandInitException
Register a new command handler.

Parameters:
commandName - The command that this handler will process.
handler - The handler to register.
Throws:
ShellCommandInitException

getInput

public java.lang.String getInput(java.lang.String prompt)
                          throws java.io.EOFException,
                                 java.io.IOException
If a command needs additional input via the console, they can get it this way.

Parameters:
prompt - The prompt to display.
Returns:
The data that the user typed in.
Throws:
java.io.EOFException
java.io.IOException

getInput

public java.lang.String getInput(java.lang.String prompt,
                                 boolean addToHistory)
                          throws java.io.EOFException,
                                 java.io.IOException
If a command needs additional input via the console, they can get it this way.

Parameters:
prompt - The prompt to display.
addToHistory - If true, the input entered will be added to the history file.
Returns:
The data that the user typed in.
Throws:
java.io.EOFException
java.io.IOException

getHiddenInput

public java.lang.String getHiddenInput(java.lang.String prompt)
                                throws java.io.EOFException,
                                       java.io.IOException
If a command needs additional input via the console, they can get it this way. The characters that the user types are not echoed.

Parameters:
prompt - The prompt to display.
Returns:
The data that the user typed in.
Throws:
java.io.EOFException
java.io.IOException

sendToOutStream

public void sendToOutStream(java.lang.String s)
Write a string to this shell's output stream.

Parameters:
s - The string to write to the output stream.

sendToErrStream

public void sendToErrStream(java.lang.String s)
Write a string to this shell's output stream.

Parameters:
s - The string to write to the output stream.

run

public void run()

handleCommand

public void handleCommand(java.lang.String line)

handleCommand

public void handleCommand(java.lang.String line,
                          java.lang.String[] args)

processCommand

public void processCommand(ShellCommandHandler handler,
                           java.lang.String[] args)
                    throws ShellCommandUsageException,
                           ShellCommandExecException
Throws:
ShellCommandUsageException
ShellCommandExecException

getOutStream

public java.io.PrintStream getOutStream()

getErrStream

public java.io.PrintStream getErrStream()

getHandler

public ShellCommandHandler getHandler(java.lang.String command)
Description copied from interface: ShellCommandMapper
Get the command handler for a command.

Specified by:
getHandler in interface ShellCommandMapper
See Also:
ShellCommandMapper.getHandler(java.lang.String)

getCommandNameIterator

public java.util.Iterator getCommandNameIterator()
Description copied from interface: ShellCommandMapper
Get an iterator for the command names.

Specified by:
getCommandNameIterator in interface ShellCommandMapper
See Also:
ShellCommandMapper.getCommandNameIterator()

shutdown

public void shutdown()

isRedirected

public boolean isRedirected()
Check to see if the currently running shell command is being redirected to a file.

Returns:
true if the shell is redirecting to a file, else false

setPageSize

public void setPageSize(int size)
Set the page size for data paging.

Parameters:
size - Number of rows to include in a page of data -- if 0, then unlimited rows will be used.

getPageSize

public int getPageSize()
Get the current page size used when paging data.

Returns:
the # of rows in the current page size.

getDefaultPageControl

public PageControl getDefaultPageControl()

performPaging

public void performPaging(PageFetcher fetcher)
                   throws PageFetchException
Throws:
PageFetchException

performPaging

public void performPaging(PageFetcher fetcher,
                          PageControl control)
                   throws PageFetchException
Throws:
PageFetchException

Hyperic HQ Plugin API v. 4.4.0.2

Copyright © 2004-2006 Hyperic, Inc. support@hyperic.net, All Rights Reserved.