Class WhileStatement

  • All Implemented Interfaces:
    Cloneable, LanguageObject, Statement.Labeled

    public class WhileStatement
    extends Statement
    implements Statement.Labeled

    This class represents a while statement in the storedprocedure language. It extends the Statement that could part of a block. This statement has a block and a criteria that determines when to exit the while loop.

    • Constructor Detail

      • WhileStatement

        public WhileStatement​(Criteria criteria,
                              Block block)
        Constructor for IfStatement.
        Parameters:
        criteria - The criteria determining which block should be executed
        block - The block to execute
    • Method Detail

      • 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 - The Criteria to determine block execution
      • getBlock

        public Block getBlock()
        Returns:
      • setBlock

        public void setBlock​(Block block)
        Parameters:
        block -
      • getType

        public int getType()
        Return the type for this statement, this is one of the types defined on the statement object.
        Specified by:
        getType in class Statement
        Returns:
        The statement type
      • 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.
        Specified by:
        acceptVisitor in interface LanguageObject
        Parameters:
        visitor - Visitor being used
      • clone

        public Object clone()
        Deep clone statement to produce a new identical statement.
        Specified by:
        clone in interface LanguageObject
        Specified by:
        clone in class Statement
        Returns:
        Deep clone
      • equals

        public boolean equals​(Object obj)
        Compare two WhileStatements for equality. They will only evaluate to equal if they are IDENTICAL: the block is same and the condition on is same.
        Overrides:
        equals in class Object
        Parameters:
        obj - Other object
        Returns:
        True if equal
      • hashCode

        public int hashCode()
        Get hashcode for WhileStatement. WARNING: This hash code relies on the hash codes of the block and the criteria. Hash code is only valid after the block has been completely constructed.
        Overrides:
        hashCode in class Object
        Returns:
        Hash code