Package org.teiid.query.sql.proc
Class IfStatement
- java.lang.Object
-
- org.teiid.query.sql.proc.Statement
-
- org.teiid.query.sql.proc.IfStatement
-
- All Implemented Interfaces:
Cloneable
,LanguageObject
public class IfStatement extends Statement
This class represents an if-else statement in the storedprocedure language. It extends the
Statement
that could part of a block. This statement has an IF block and an optional ELSE block, it also holds reference to the criteria that determines which block should be executed..
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.teiid.query.sql.proc.Statement
Statement.Labeled
-
Nested classes/interfaces inherited from interface org.teiid.query.sql.LanguageObject
LanguageObject.Util
-
-
Field Summary
-
Fields inherited from class org.teiid.query.sql.proc.Statement
TYPE_ASSIGNMENT, TYPE_BREAK, TYPE_COMMAND, TYPE_COMPOUND, TYPE_CONTINUE, TYPE_DECLARE, TYPE_ERROR, TYPE_IF, TYPE_LEAVE, TYPE_LOOP, TYPE_RETURN, TYPE_UNKNOWN, TYPE_UPDATE, TYPE_WHILE
-
-
Constructor Summary
Constructors Constructor Description IfStatement()
Constructor for IfStatement.IfStatement(Criteria criteria, Block ifBlock)
Constructor for IfStatement.IfStatement(Criteria criteria, Block ifBlock, Block elseBlock)
Constructor for IfStatement.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
acceptVisitor(LanguageVisitor visitor)
Method for accepting a visitor.Object
clone()
Deep clone statement to produce a new identical statement.boolean
equals(Object obj)
Compare two IfStatements for equality.Criteria
getCondition()
Get the condition that determines which block needs to be executed.Block
getElseBlock()
Get the statement's ELSE block.Block
getIfBlock()
Get the statement's IF block.int
getType()
Return the type for this statement, this is one of the types defined on the statement object.boolean
hasElseBlock()
Return a boolean indicating if the statement has an else block.int
hashCode()
Get hashcode for IfStatement.void
setCondition(Criteria criteria)
Set the condition that determines which block needs to be executed.void
setElseBlock(Block block)
Set the statement's ELSE block.void
setIfBlock(Block block)
Set the statement's IF block.
-
-
-
Constructor Detail
-
IfStatement
public IfStatement()
Constructor for IfStatement.
-
IfStatement
public IfStatement(Criteria criteria, Block ifBlock, Block elseBlock)
Constructor for IfStatement.- Parameters:
criteria
- The criteria determining which block should be executedifBlock
- The IFBlock
object.elseBlock
- The ELSEBlock
object.
-
-
Method Detail
-
getIfBlock
public Block getIfBlock()
Get the statement's IF block.- Returns:
- The IF
Block
object.
-
setIfBlock
public void setIfBlock(Block block)
Set the statement's IF block.- Parameters:
block
- The IFBlock
object.
-
getElseBlock
public Block getElseBlock()
Get the statement's ELSE block.- Returns:
- The ELSE
Block
object.
-
setElseBlock
public void setElseBlock(Block block)
Set the statement's ELSE block.- Parameters:
block
- The ELSEBlock
object.
-
hasElseBlock
public boolean hasElseBlock()
Return a boolean indicating if the statement has an else block.- Returns:
- A boolean indicating if the statement has an else block
-
getCondition
public Criteria getCondition()
Get the condition that determines which block needs to be executed.- Returns:
- The
Criteria
to determine block execution
-
setCondition
public void setCondition(Criteria criteria)
Set the condition that determines which block needs to be executed.- Parameters:
criteria
- TheCriteria
to determine block execution
-
getType
public int getType()
Return the type for this statement, this is one of the types defined on the statement object.
-
acceptVisitor
public void acceptVisitor(LanguageVisitor visitor)
Description copied from interface:LanguageObject
Method for accepting a visitor. It is the responsibility of the language object to call back on the visitor.- Parameters:
visitor
- Visitor being used
-
clone
public Object clone()
Deep clone statement to produce a new identical statement.- Specified by:
clone
in interfaceLanguageObject
- Specified by:
clone
in classStatement
- Returns:
- Deep clone
-
equals
public boolean equals(Object obj)
Compare two IfStatements for equality. They will only evaluate to equal if they are IDENTICAL: their if, else blocks are same and the condition on the ifBlock is same.
-
hashCode
public int hashCode()
Get hashcode for IfStatement. WARNING: This hash code relies on the hash codes of the if-else blocks anf the criteria determining the block on this statement. Hash code is only valid after the block has been completely constructed.
-
-