org.overlord.sramp.shell
Class AbstractShellCommandReader

java.lang.Object
  extended by org.overlord.sramp.shell.AbstractShellCommandReader
All Implemented Interfaces:
ShellCommandReader
Direct Known Subclasses:
ConsoleShellCommandReader, FileShellCommandReader, InteractiveShellCommandReader, StdInShellCommandReader

public abstract class AbstractShellCommandReader
extends Object
implements ShellCommandReader

A base class for all shell command readers.

Author:
eric.wittmann@redhat.com

Constructor Summary
AbstractShellCommandReader(ShellCommandFactory factory, ShellContext context)
          Constructor.
 
Method Summary
 void close()
          Called by the shell when exiting.
protected  Writer getCommandOutput()
          Gets the output stream that should be used by commands when they need to print a message to the console.
 ShellContext getContext()
           
 ShellCommandFactory getFactory()
           
abstract  void open()
          Called to open the shell command reader.
 ShellCommand read()
          Reads the next command from the input source.
protected abstract  String readLine()
          Reads a single line from the input source (e.g.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractShellCommandReader

public AbstractShellCommandReader(ShellCommandFactory factory,
                                  ShellContext context)
Constructor.

Parameters:
factory -
context -
Method Detail

open

public abstract void open()
                   throws IOException
Description copied from interface: ShellCommandReader
Called to open the shell command reader.

Specified by:
open in interface ShellCommandReader
Throws:
IOException
See Also:
org.overlord.sramp.common.shell.ShellCommandReader#open()

read

public final ShellCommand read()
                        throws Exception
Description copied from interface: ShellCommandReader
Reads the next command from the input source.

Specified by:
read in interface ShellCommandReader
Throws:
Exception
See Also:
org.overlord.sramp.common.shell.ShellCommandReader#read()

getCommandOutput

protected Writer getCommandOutput()
Gets the output stream that should be used by commands when they need to print a message to the console.


readLine

protected abstract String readLine()
                            throws IOException
Reads a single line from the input source (e.g. user input) and returns it.

Throws:
IOException

close

public void close()
           throws IOException
Description copied from interface: ShellCommandReader
Called by the shell when exiting.

Specified by:
close in interface ShellCommandReader
Throws:
IOException
See Also:
org.overlord.sramp.common.shell.ShellCommandReader#close()

getFactory

public ShellCommandFactory getFactory()
Returns:
the factory

getContext

public ShellContext getContext()
Returns:
the context


Copyright © 2011-2013 JBoss, a division of Red Hat. All Rights Reserved.