org.progeeks.cmd.stack
Class QueuingStack

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

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

CommandProcessorStack implementation that will queue commands that cannot be executed by the top entry. When a new command processor becomes the top entry, and saved commands are reprocessed. This implementation is also its own environment which theoretically should make it easier to provide custom root-level environment properties.

Version:
$Revision: 1.3 $
Author:
Paul Speed

Constructor Summary
QueuingStack()
          Creates an empty command processor stack.
 
Method Summary
 void clearQueue()
          Clears the queue of commands waiting to be run.
 Result execute(Command cmd)
          Executes the specified command using the top command processor in the stack if possible.
 int getQueueSize()
          Returns the number of commands that are waiting for a command processor that can run them.
 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

QueuingStack

public QueuingStack()
Creates an empty command processor stack.

Method Detail

getQueueSize

public int getQueueSize()
Returns the number of commands that are waiting for a command processor that can run them.


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

clearQueue

public void clearQueue()
Clears the queue of commands waiting to be run.



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