VASSAL.command
Class ChangePiece

java.lang.Object
  |
  +--VASSAL.command.Command
        |
        +--VASSAL.command.ChangePiece
Direct Known Subclasses:
TrackPiece

public class ChangePiece
extends Command

This Command changes the state of a GamePiece. Its undo Command is another ChangePiece with the new and old states reversed.


Field Summary
protected  java.lang.String newState
           
protected  java.lang.String oldState
           
 
Constructor Summary
ChangePiece(java.lang.String id, java.lang.String newState)
          Deprecated.  
ChangePiece(java.lang.String id, java.lang.String oldState, java.lang.String newState)
           
 
Method Summary
 Command append(Command c)
          Append a subcommand to this Command.
protected  void executeCommand()
          Changes the state of a GamePiece by invoking GamePiece.setState(java.lang.String)
 java.lang.String getId()
           
 java.lang.String getNewState()
           
 java.lang.String getOldState()
           
 boolean isNull()
           
protected  Command myUndoCommand()
          If the action can be undone, return a Command that performs the inverse action.
 
Methods inherited from class VASSAL.command.Command
execute, getSubCommands, getUndoCommand, hasNullSubcommands, isLoggable, stripSubCommands, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

newState

protected java.lang.String newState

oldState

protected java.lang.String oldState
Constructor Detail

ChangePiece

public ChangePiece(java.lang.String id,
                   java.lang.String oldState,
                   java.lang.String newState)
Parameters:
id - the id of the GamePiece to change
oldState - the previous state of the piece
newState - the new state of the piece

ChangePiece

public ChangePiece(java.lang.String id,
                   java.lang.String newState)
Deprecated.  

When using this constructor, the previous state will be set to that of the piece when this Command is executed.
Method Detail

executeCommand

protected void executeCommand()
Changes the state of a GamePiece by invoking GamePiece.setState(java.lang.String)
Overrides:
executeCommand in class Command

append

public Command append(Command c)
Description copied from class: Command
Append a subcommand to this Command.
Overrides:
append in class Command

myUndoCommand

protected Command myUndoCommand()
Description copied from class: Command
If the action can be undone, return a Command that performs the inverse action. The Command returned should only undo Command.executeCommand(), not the actions of subcommands
Overrides:
myUndoCommand in class Command

getId

public java.lang.String getId()

getNewState

public java.lang.String getNewState()

getOldState

public java.lang.String getOldState()

isNull

public boolean isNull()
Overrides:
isNull in class Command
Following copied from class: VASSAL.command.Command
Returns:
true if this command does nothing