com.sun.slamd.scripting.engine
Class IfElseInstruction

java.lang.Object
  extended bycom.sun.slamd.scripting.engine.Instruction
      extended bycom.sun.slamd.scripting.engine.IfElseInstruction

public class IfElseInstruction
extends Instruction

This class defines an instruction that will be executed if the associated condition is true. It may also define an instruction that will be executed if the associated condition is not true.


Constructor Summary
IfElseInstruction(int lineNumber, Argument condition, Instruction ifInstruction)
          Creates a new if instruction with no else clause.
IfElseInstruction(int lineNumber, Argument condition, Instruction ifInstruction, Instruction elseInstruction)
          Creates a new if instruction with an optional else clause.
 
Method Summary
 void debugExecute(JobClass jobThread)
          Performs the function associated with this instruction, writing debug information about its execution to the client's message writer using the writeVerbose method.
 void execute(JobClass jobThread)
          Performs the function associated with this instruction.
 Argument getCondition()
          Retrieves the condition that will be evaluated at runtime to determine whether the primary instruction is executed.
 Instruction getInstructionIfFalse()
          Retrieves the instruction that will be executed if the condition evaluates to false.
 Instruction getInstructionIfTrue()
          Retrieves the instruction that will be executed if the condition evaluates to true.
 java.lang.String toString(int indent)
          Retrieves a string representation of this instruction as could be found in a script file.
 
Methods inherited from class com.sun.slamd.scripting.engine.Instruction
getLineNumber, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IfElseInstruction

public IfElseInstruction(int lineNumber,
                         Argument condition,
                         Instruction ifInstruction)
Creates a new if instruction with no else clause.

Parameters:
lineNumber - The line number on which the if statement occurs in the script.
condition - The condition that will be evaluated to determine whether the primary instruction is executed.
ifInstruction - The primary instruction to execute if the condition is true.

IfElseInstruction

public IfElseInstruction(int lineNumber,
                         Argument condition,
                         Instruction ifInstruction,
                         Instruction elseInstruction)
Creates a new if instruction with an optional else clause.

Parameters:
lineNumber - The line number on which the if statement occurs in the script.
condition - The condition that will be evaluated to determine whether the primary instruction is executed.
ifInstruction - The primary instruction to execute if the condition is true.
elseInstruction - The optional instruction to execute if the condition is false.
Method Detail

getCondition

public Argument getCondition()
Retrieves the condition that will be evaluated at runtime to determine whether the primary instruction is executed.

Returns:
The condition that will be evaluated.

getInstructionIfTrue

public Instruction getInstructionIfTrue()
Retrieves the instruction that will be executed if the condition evaluates to true.

Returns:
The instruction that will be executed if the condition evaluates to true.

getInstructionIfFalse

public Instruction getInstructionIfFalse()
Retrieves the instruction that will be executed if the condition evaluates to false.

Returns:
The instruction that will be executed if the condition evaluates to false, or null if no such instruction has been defined.

execute

public void execute(JobClass jobThread)
             throws ScriptException
Performs the function associated with this instruction.

Specified by:
execute in class Instruction
Parameters:
jobThread - The job thread that will be executing the script.
Throws:
ScriptException - If a problem occurs while processing this instruction.

debugExecute

public void debugExecute(JobClass jobThread)
                  throws ScriptException
Performs the function associated with this instruction, writing debug information about its execution to the client's message writer using the writeVerbose method.

Specified by:
debugExecute in class Instruction
Parameters:
jobThread - The job thread that will be executing the script.
Throws:
ScriptException - If a problem occurs while processing this instruction.

toString

public java.lang.String toString(int indent)
Retrieves a string representation of this instruction as could be found in a script file. It may consist of multiple lines if necessary.

Specified by:
toString in class Instruction
Parameters:
indent - The number of spaces to indent the output.
Returns:
A string representation of this instruction as could be found in a script file.