y.base
Class CommandStream

java.lang.Object
  |
  +--y.base.CommandStream

public class CommandStream
extends Object

This class represents a stream of Commands. It is useful for implementing undoable operations in applications.


Constructor Summary
CommandStream()
          Initializes a new CommandStream object with unlimited size
 
Method Summary
 Command backward()
          Returns the next command for which an undo operation is meaningful and consistent in respect to the order of the commands registered.
 boolean backwardPossible()
          Returns true iff it is possible to retrive a command by calling backward().
 void clear()
          Clears this stream
 void clearTo(Command com)
          Clears the stream up to the given command (exclusive)
 Command forward()
          Returns the next command for which a redo operation is meaningful and consistent in respect to the order of the commands registered.
 boolean forwardPossible()
          Returns true iff it is possible to retrive a command by calling forward().
 Object getActiveToken()
          Obtains a token which determines the currently active position in the stream.
 int getMaximumSize()
          Returns the maximum size of this stream
 boolean isActiveToken(Object token)
          determines, whether the stream is currently at the same position, the time the token was obtained using CommandStream.getActiveToken()
 void push(Command com)
          Addes the given command to this stream
 void setMaximumSize(int maxSize)
          Sets the maximum size of this stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandStream

public CommandStream()
Initializes a new CommandStream object with unlimited size

Method Detail

setMaximumSize

public void setMaximumSize(int maxSize)
Sets the maximum size of this stream


getMaximumSize

public int getMaximumSize()
Returns the maximum size of this stream


push

public void push(Command com)
Addes the given command to this stream


backwardPossible

public boolean backwardPossible()
Returns true iff it is possible to retrive a command by calling backward().


clearTo

public void clearTo(Command com)
Clears the stream up to the given command (exclusive)


clear

public void clear()
Clears this stream


backward

public Command backward()
Returns the next command for which an undo operation is meaningful and consistent in respect to the order of the commands registered. If no such command exists null is returned.


forwardPossible

public boolean forwardPossible()
Returns true iff it is possible to retrive a command by calling forward().


forward

public Command forward()
Returns the next command for which a redo operation is meaningful and consistent in respect to the order of the commands registered. If no such command exists null is returned.


getActiveToken

public Object getActiveToken()
Obtains a token which determines the currently active position in the stream. CommandStream.isActiveToken(Object) can be used to determine, whether the current stream position equals the position at the time to token was obtained

Returns:
a token

isActiveToken

public boolean isActiveToken(Object token)
determines, whether the stream is currently at the same position, the time the token was obtained using CommandStream.getActiveToken()

Parameters:
token - the token
Returns:
true if the stream is at the same position

© Copyright 2000-2003,
yWorks GmbH.
All rights reserved.

2003