Building Parsers with Java

sjm.imperative
Class WhileCommand

java.lang.Object
  |
  +--sjm.imperative.Command
        |
        +--sjm.imperative.WhileCommand

public class WhileCommand
extends Command

This command mimics a normal "while" loop, executing a command in a loop, so long as some condition holds true.


Field Summary
protected  Command command
           
protected  BooleanTerm condition
           
 
Constructor Summary
WhileCommand(BooleanTerm condition, Command command)
          Construct a "while" command from the given condition and command.
 
Method Summary
 void execute()
          Execute this "while" command.
 java.lang.String toString()
          Returns a string description of this while command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

condition

protected BooleanTerm condition

command

protected Command command
Constructor Detail

WhileCommand

public WhileCommand(BooleanTerm condition,
                    Command command)
Construct a "while" command from the given condition and command.
Parameters:
condition - the condition to check each time before executing the body
command - the command to repeatedly execute
Method Detail

execute

public void execute()
Execute this "while" command. This means repeatedly checking the condition, and executing command from this object's command, so long as the condition is true.
Overrides:
execute in class Command

toString

public java.lang.String toString()
Returns a string description of this while command.
Overrides:
toString in class java.lang.Object
Returns:
a string description of this while command

by Steve Metsker