com.metamatrix.query.processor.proc
Class IfInstruction

java.lang.Object
  extended by com.metamatrix.query.processor.program.ProgramInstruction
      extended by com.metamatrix.query.processor.proc.IfInstruction
All Implemented Interfaces:
Describable, java.lang.Cloneable

public class IfInstruction
extends ProgramInstruction

This instruction an holds an if block and an else block and a criteria that determines which block will be executed. These blocks are Program objects that could contain nested if-else block. Therefore, this ProgramInstruction implements an arbitrarily deep if-else if-....else block.

During processing, the Criteria is evaluated and if it evaluates to true, the "if" block is executed else the "else" block if there is one is executed. These programs are placed on the stack.


Field Summary
 
Fields inherited from interface com.metamatrix.query.processor.Describable
PROP_BINDINGS, PROP_CHILDREN, PROP_CONDITIONS, PROP_CRITERIA, PROP_DATA_COL, PROP_DEFAULT, PROP_DEFAULT_PROGRAM, PROP_ELSE, PROP_ENCODING, PROP_EXECUTION_PLAN, PROP_EXPRESSION, PROP_FORMATTED, PROP_GROUP, PROP_GROUP_COLS, PROP_IN_MEMORY, PROP_INTO_GROUP, PROP_IS_STAGING, PROP_JOIN_CRITERIA, PROP_JOIN_STRATEGY, PROP_JOIN_TYPE, PROP_MESSAGE, PROP_MODEL_NAME, PROP_NAMESPACE, PROP_NAMESPACE_DECL, PROP_NODE_COST_ESTIMATES, PROP_NODE_STATS_LIST, PROP_NODE_STATS_PROPS, PROP_OPTIONAL, PROP_OUTPUT_COLS, PROP_PROGRAM, PROP_PROGRAMS, PROP_RECURSE_DIR, PROP_REMOVE_DUPS, PROP_RESULT_SET, PROP_ROW_LIMIT, PROP_ROW_OFFSET, PROP_SELECT_COLS, PROP_SORT_COLS, PROP_SQL, PROP_TAG, PROP_THEN, PROP_TYPE, PROP_VARIABLE
 
Constructor Summary
IfInstruction(Criteria condition, Program ifProgram)
          Constructor for IfInstruction.
IfInstruction(Criteria condition, Program ifProgram, Program elseProgram)
          Constructor for IfInstruction.
 
Method Summary
 java.lang.Object clone()
          Returns a deep clone
 java.util.Collection getChildPlans()
          Finds all nested plans and returns them.
 java.util.Map getDescriptionProperties()
          Get a description as a set of properties of primitive types such as String, Integer, etc.
 Program getElseProgram()
           
 Program getIfProgram()
           
 void process(ProcedurePlan procEnv)
          This instruction will evaluate it's criteria, if it evaluates to true, it will push the corresponding sub Program on to the top of the program stack, and break from the loop.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IfInstruction

public IfInstruction(Criteria condition,
                     Program ifProgram,
                     Program elseProgram)
Constructor for IfInstruction.

Parameters:
condition - The Criteria used to determine which block to execute
ifProgram - The Program representing the "if" block
elseProgram - The Program representing the "else" block

IfInstruction

public IfInstruction(Criteria condition,
                     Program ifProgram)
Constructor for IfInstruction.

Parameters:
condition - The Criteria used to determine which block to execute
ifProgram - The Program representing the "if" block
Method Detail

process

public void process(ProcedurePlan procEnv)
             throws BlockedException,
                    MetaMatrixComponentException,
                    MetaMatrixProcessingException
This instruction will evaluate it's criteria, if it evaluates to true, it will push the corresponding sub Program on to the top of the program stack, and break from the loop. Regardless if whether any criteria evaluate to true, this instruction will increment the program counter of the current program.

Specified by:
process in class ProgramInstruction
Throws:
MetaMatrixProcessingException
BlockedException
MetaMatrixComponentException
See Also:
ProgramInstruction.process(ProcedurePlan)

getIfProgram

public Program getIfProgram()

getElseProgram

public Program getElseProgram()

clone

public java.lang.Object clone()
Returns a deep clone

Overrides:
clone in class ProgramInstruction
Returns:
shallow clone

toString

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

getDescriptionProperties

public java.util.Map getDescriptionProperties()
Description copied from interface: Describable
Get a description as a set of properties of primitive types such as String, Integer, etc.

Specified by:
getDescriptionProperties in interface Describable
Overrides:
getDescriptionProperties in class ProgramInstruction
Returns:
Map of properties

getChildPlans

public java.util.Collection getChildPlans()
Description copied from class: ProgramInstruction
Finds all nested plans and returns them.

Overrides:
getChildPlans in class ProgramInstruction
Returns:
List of ProcessorPlan
Since:
4.2
See Also:
ProgramInstruction.getChildPlans()


Copyright © 2009. All Rights Reserved.