VASSAL.command
Class Command

java.lang.Object
  |
  +--VASSAL.command.Command
Direct Known Subclasses:
AddPiece, AddSecretNoteCommand, BoardPicker.SetBoards, ChangePiece, Chatter.DisplayText, DrawPile.PlaceDeck, EventLog.StoreEvents, GameState.SetupCommand, ModuleExtension.RegCmd, MovePiece, NullCommand, ObscurableOptions.SetAllowed, PlayerRoster.Add, RemovePiece, SetPrivateTextCommand, SetupStack.MarkInitialized, SpecialDiceButton.ShowResults

public abstract class Command
extends java.lang.Object

Command is an abstract class that does something. Any action that takes place during a game should be encapsulated in a Command object. When performing actions during a game, corresponding Commands will be logged in the current logfile and/or sent to other players on the server. Commands can be strung together into compound commands with the append(VASSAL.command.Command) method.

See Also:
CommandEncoder

Constructor Summary
Command()
           
 
Method Summary
 Command append(Command c)
          Append a subcommand to this Command.
 void execute()
          Execute this command by first invoking executeCommand(), then invoking execute() recursively on all subcommands.
protected abstract  void executeCommand()
          Perform the action which this Command represents
 Command[] getSubCommands()
           
 Command getUndoCommand()
           
protected  boolean hasNullSubcommands()
           
 boolean isLoggable()
           
 boolean isNull()
           
protected abstract  Command myUndoCommand()
          If the action can be undone, return a Command that performs the inverse action.
 void stripSubCommands()
          Remove all subcommands.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Command

public Command()
Method Detail

getSubCommands

public Command[] getSubCommands()

execute

public void execute()
Execute this command by first invoking executeCommand(), then invoking execute() recursively on all subcommands.

executeCommand

protected abstract void executeCommand()
Perform the action which this Command represents

myUndoCommand

protected abstract Command myUndoCommand()
If the action can be undone, return a Command that performs the inverse action. The Command returned should only undo executeCommand(), not the actions of subcommands

stripSubCommands

public void stripSubCommands()
Remove all subcommands.

isNull

public boolean isNull()
Returns:
true if this command does nothing

isLoggable

public boolean isLoggable()
Returns:
true if this command should be stored in a logfile

hasNullSubcommands

protected boolean hasNullSubcommands()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

append

public Command append(Command c)
Append a subcommand to this Command.

getUndoCommand

public Command getUndoCommand()
Returns:
a Command that undoes not only this Command's action, but also the actions of all its subcommands.