|
Evaluating Software Design Patterns — the "Gang of Four" patterns implemented in Java 6 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object dk.rode.thesis.command.SequenceCommand<E> dk.rode.thesis.command.ResetCommand<E>
E
- The type of result obtained by executing this command.
The type corresponds to the type of values delivered by
the receiver sequence.@Participant(value="ConcreteCommand") public class ResetCommand<E>
A reset command command will invoke reset()
on its receiving sequence
when it is
executed
.
Reset commands are undoable
if the receiving
sequence is a memorizable
sequence,
and/or if it is consistent
and
unique
. Notice, however, that the
time to undo a non-memorizable sequence by this command is not
constant: it is linear with the number of times next()
has to be invoked before the old sequence value is found
again.
Field Summary | |
---|---|
private E |
previous
The sequence value before the last reset. |
Fields inherited from class dk.rode.thesis.command.SequenceCommand |
---|
result, sequence |
Constructor Summary | |
---|---|
ResetCommand(Sequence<E> sequence)
Constructor. |
Method Summary | |
---|---|
ResetCommand<E> |
copy()
Creates a copy of this command, excluding internal state information required for execution and undo. |
protected List<Command<E>> |
doExecute(boolean saved)
Resets the sequence value and sets the result to the (new) current value. |
boolean |
isUndoable()
Returns true if this command has been executed and the receiving sequence used by this command is either memorizable and/or the sequence
is bounded and
consistent . |
E |
undo()
Performs undo of this sequence command if possible. |
Methods inherited from class dk.rode.thesis.command.SequenceCommand |
---|
equals, execute, getResult, hashCode, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private E previous
Can be null.
Constructor Detail |
---|
public ResetCommand(@Participant(value="Receiver") Sequence<E> sequence)
sequence
- The sequence; cannot be null.
NullPointerException
- If sequence
is null.Method Detail |
---|
public ResetCommand<E> copy()
Command
protected List<Command<E>> doExecute(boolean saved)
doExecute
in class SequenceCommand<E>
saved
- True if the before state was successfully saved before
this method is invoked, false if not.
processor
currently
executing this command. Can be null or empty.SequenceCommand.execute()
public boolean isUndoable()
memorizable
and/or the sequence
is bounded
and
consistent
.
isUndoable
in interface Command<E>
isUndoable
in class SequenceCommand<E>
public E undo() throws CommandException
SequenceCommand
If this command is not undoable
an
exception will be thrown. If this command cannot be undone
otherwise, null will be returned.
The command result value is cleared.
undo
in interface Command<E>
undo
in class SequenceCommand<E>
CommandException
- In case this command is not undoable.
|
Gunni Rode / rode.dk | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |