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..
Statement.Labeled
LanguageObject.Util
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 and Description |
---|
IfStatement()
Constructor for IfStatement.
|
IfStatement(Criteria criteria,
Block ifBlock)
Constructor for IfStatement.
|
IfStatement(Criteria criteria,
Block ifBlock,
Block elseBlock)
Constructor for IfStatement.
|
Modifier and Type | Method and 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.
|
public IfStatement()
public IfStatement(Criteria criteria, Block ifBlock, Block elseBlock)
criteria
- The criteria determining which bleck should be executedifBlock
- The IF Block
object.ifBlock
- The ELSE Block
object.public Block getIfBlock()
Block
object.public void setIfBlock(Block block)
block
- The IF Block
object.public Block getElseBlock()
Block
object.public void setElseBlock(Block block)
block
- The ELSE Block
object.public boolean hasElseBlock()
public Criteria getCondition()
Criteria
to determine block executionpublic void setCondition(Criteria criteria)
criteria
- The Criteria
to determine block executionpublic int getType()
public void acceptVisitor(LanguageVisitor visitor)
LanguageObject
visitor
- Visitor being usedpublic Object clone()
clone
in interface LanguageObject
clone
in class Statement
public boolean equals(Object obj)
public int hashCode()
Copyright © 2019. All rights reserved.