Class Command

java.lang.Object
  |
  +--Command
Direct Known Subclasses:
DefineNamedXYZCommand, DefinePositionCommand, GotoNamedXYZCommand, GotoPositionCommand, HomeCommand, MoveJointCommand, MoveXYZCommand, SpeedCommand, WaitCommand

public abstract class Command
extends java.lang.Object

A class that encapsulates a simulator command. This class and its subclasses implement the Command Pattern, as demonstrated in Gamma et al (page 236). A REMOTE command knows how to operate on the Robot class to achieve a specific action; the SimulationEngine class only needs to know the Command class, not the details of how a particular Command is implemented. This encapsulation allows new Command classes to be added in the future to work with new robot language parsers.

See Also:
SimulationEngine, CommandQueue

Constructor Summary
Command(int lineNumber)
          Creates a new Command, associated with a given line number in the simulation program.
 
Method Summary
abstract  void Execute()
          Executes the Command's function.
 int getSourceLine()
          Returns the line number in the source file which generated this Command.
 void setSourceLine(int lineNumber)
          Sets the line number in the source file which generated this Command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Command

public Command(int lineNumber)
Creates a new Command, associated with a given line number in the simulation program.
Parameters:
lineNumber - the source line for this command.
Method Detail

Execute

public abstract void Execute()
                      throws java.lang.Exception
Executes the Command's function. The SimulationEngine will call this method in order to activate the Command and effect change on either the Robot's state or the state of the simulation.
Throws:
thrown - if an error occurs attempting to execute the command.

getSourceLine

public int getSourceLine()
Returns the line number in the source file which generated this Command.
Returns:
the line number of this Command in the source file.

setSourceLine

public void setSourceLine(int lineNumber)
Sets the line number in the source file which generated this Command.
Parameters:
lineNumber - the line number of this Command in the source file.