Search this API

y.base
Class CommandStream

java.lang.Object
  extended by y.base.CommandStream

public class CommandStream
extends java.lang.Object

Represents a stream of commands. It is useful for implementing undoable operations in applications.

 
Your browser does not support SVG content.

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 with respect to the order of the commands registered.
 boolean backwardPossible()
          Returns true iff it is possible to retrieve 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 with respect to the order of the commands registered.
 boolean forwardPossible()
          Returns true iff it is possible to retrieve a command by calling forward().
 java.lang.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(java.lang.Object token)
          Determines whether the stream is currently at the same position as it was at the time that the token has been obtained using getActiveToken().
 void push(Command com)
          Adds 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)
Adds the given command to this stream.


backwardPossible

public boolean backwardPossible()
Returns true iff it is possible to retrieve 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 with 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 retrieve a command by calling forward().


forward

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


getActiveToken

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

Returns:
A token.

isActiveToken

public boolean isActiveToken(java.lang.Object token)
Determines whether the stream is currently at the same position as it was at the time that the token has been obtained using getActiveToken().

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

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