public class LinearHistory extends java.lang.Object implements History
History.Listener| Constructor and Description |
|---|
LinearHistory() |
LinearHistory(int capacity) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
addAndExecute(Command command)
Appends the given command after the last executed one and execute it.
|
void |
addListener(History.Listener listener)
Appends a new listener to this history.
|
boolean |
contains(Command command)
Returns
true if this list contains the specified element. |
boolean |
executeNext()
Executes the next (most recently rolled back) command.
|
Command |
getNext()
Returns the next (most recently rolled back) command.
|
Command |
getPrevious()
Returns the previous (most recently executed) command.
|
boolean |
hasNext()
Returns
true if there is a next (most recently rolled back) command. |
boolean |
hasPrevious()
Returns
true if there is a previous (most recently executed) command. |
boolean |
isEmpty()
Returns
true if this history contains no commands. |
java.util.Iterator<Command> |
iterator()
Returns an iterator which iterates through the last executed path's commands.
|
boolean |
moveAfter(Command command)
Moves the internal pointer after the given command.
|
boolean |
moveBefore(Command command)
Moves the internal pointer before the given command.
|
boolean |
removeListener(History.Listener listener)
Removes a listener from this history.
|
boolean |
rollBackPrevious()
Rolls back the previous (most recently executed) command.
|
void |
setCapacity(int capacity)
Changes the capacity of this history.
|
public LinearHistory()
public LinearHistory(int capacity)
capacity - maximum number of commands in this historypublic java.util.Iterator<Command> iterator()
Historypublic boolean isEmpty()
Historytrue if this history contains no commands.public boolean contains(Command command)
Historytrue if this list contains the specified element.public boolean addAndExecute(Command command)
HistoryaddAndExecute in interface Historytrue if the command successfully executed and insertedpublic boolean hasNext()
Historytrue if there is a next (most recently rolled back) command.public Command getNext()
Historypublic boolean executeNext()
HistoryexecuteNext in interface Historytrue if a next command is successfully executedpublic boolean hasPrevious()
Historytrue if there is a previous (most recently executed) command.hasPrevious in interface Historytrue if there is a previous commandpublic Command getPrevious()
HistorygetPrevious in interface Historypublic boolean rollBackPrevious()
HistoryrollBackPrevious in interface Historytrue if a previous command is successfully rolled backpublic boolean moveBefore(Command command)
HistorymoveBefore in interface Historytrue if the command found and pointer successfully movedpublic boolean moveAfter(Command command)
Historypublic void addListener(History.Listener listener)
HistoryaddListener in interface Historylistener - the new listenerpublic boolean removeListener(History.Listener listener)
HistoryremoveListener in interface Historytrue if the listener found and removedpublic void setCapacity(int capacity)
capacity -