org.progeeks.cmd.stack
Class ForwardingStack

java.lang.Object
  extended by org.progeeks.cmd.stack.ForwardingStack
All Implemented Interfaces:
CommandProcessor, Environment, CommandProcessorStack, StackEnvironment

public class ForwardingStack
extends java.lang.Object
implements CommandProcessorStack, StackEnvironment

CommandProcessorStack implementation that will forward commands to the next entry in the stack if they cannot be run by the top entry. If no processors in the stack can handle the command then an exception is thrown. This implementation is also its own environment which theoretically should make it easier to provide custom root-level environment properties.

Version:
$Revision: 1.1 $
Author:
Paul Speed

Constructor Summary
ForwardingStack()
          Creates an empty command processor stack.
 
Method Summary
 Result execute(Command cmd)
          Executes the specified command using the top command processor in the stack if possible.
 StackableCommandProcessor peekCommandProcessor()
          Returns the current top command processor.
 StackableCommandProcessor popCommandProcessor()
          Pops the current command processor.
 void pushCommandProcessor(StackableCommandProcessor cmdProc)
          Pushes a new command processor onto the stack.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ForwardingStack

public ForwardingStack()
Creates an empty command processor stack.

Method Detail

execute

public Result execute(Command cmd)
Executes the specified command using the top command processor in the stack if possible. Otherwise, it will search down the stack for an appropriate processor to run the command.

Specified by:
execute in interface CommandProcessor
Parameters:
cmd - The command to invoke.
Returns:
A result container or null if the command returns no result.

pushCommandProcessor

public void pushCommandProcessor(StackableCommandProcessor cmdProc)
Pushes a new command processor onto the stack.

Specified by:
pushCommandProcessor in interface CommandProcessorStack

popCommandProcessor

public StackableCommandProcessor popCommandProcessor()
Pops the current command processor.

Specified by:
popCommandProcessor in interface CommandProcessorStack

peekCommandProcessor

public StackableCommandProcessor peekCommandProcessor()
Returns the current top command processor.

Specified by:
peekCommandProcessor in interface CommandProcessorStack


Copyright © 2002-2003 Paul Speed. All Rights Reserved.