Class ZestLoop<T>

    • Constructor Detail

      • ZestLoop

        protected ZestLoop()
        Instantiates a new zest loop.
      • ZestLoop

        protected ZestLoop​(int index)
      • ZestLoop

        public ZestLoop​(String variableName)
    • Method Detail

      • init

        protected void init​(ZestLoopTokenSet<T> set,
                            List<ZestStatement> statements)
        Inits the Loop.
        Parameters:
        set - the initialization token set
        statements - the list of statements inside the loop
      • init

        public void init​(ZestRuntime runtime)
        inits the loop refreshing the current state to the first considered state
        Parameters:
        runtime - the Zest runtime.
      • setSet

        protected void setSet​(ZestLoopTokenSet<T> newSet)
        sets the current state to the new one (for subclasses).
        Parameters:
        newSet - the new sets the
      • setStatements

        public List<ZestStatement> setStatements​(List<ZestStatement> stmts)
        Sets the statements list.
        Parameters:
        stmts - the stmts list
        Returns:
        the previous statement list
      • getStatements

        public List<ZestStatement> getStatements()
        Gets the statements.
        Returns:
        the statements list
      • loop

        protected boolean loop​(ZestLoopTokenSet<T> set)
        increase the current state (ignoring all the statements which are still to be computed for this loop: a new one starts).
        Parameters:
        set - the set of tokens to continue the loop.
        Returns:
        the new state (of the following loop)
      • endLoop

        protected void endLoop​(ZestLoopTokenSet<T> set)
        ends the loop and set the state to the final value.
        Parameters:
        set - the set of tokens to end the loop.
      • addStatement

        public void addStatement​(ZestStatement stmt)
        adds a new statement inside the loop.
        Parameters:
        stmt - the new statement to add
      • add

        public void add​(int index,
                        ZestStatement stmt)
        Adds the statement in the specified index in the script.
        Parameters:
        index - the index at which the statement will be added
        stmt - the statement to add
      • getCurrentState

        public ZestLoopState<T> getCurrentState()
        returns the current state of the loop.
        Returns:
        the current state
      • setCurrentState

        protected void setCurrentState​(ZestLoopState<T> newState)
        Sets the current state.
        Parameters:
        newState - the new current state
      • getCurrentToken

        public T getCurrentToken()
        return the current token considered inside the loop.
        Returns:
        the current token considered inside the loop
      • getCurrentIndex

        public int getCurrentIndex()
        returns the current index (related to the current token) of the loop
        Returns:
        the current index (related to the current token)
      • getCurrentStatementIndex

        public int getCurrentStatementIndex()
        returns the current statement index
        Returns:
        the index of the statement currently considered
      • getSet

        public abstract ZestLoopTokenSet<T> getSet()
        returns the set of the tokens in this loop.
        Returns:
        the set of the tokens in this loop
      • isSameSubclass

        public boolean isSameSubclass​(ZestElement ze)
        Description copied from class: ZestElement
        Checks if is same subclass.
        Overrides:
        isSameSubclass in class ZestStatement
        Parameters:
        ze - the ze
        Returns:
        true, if is same subclass
      • getVariableNames

        public Set<String> getVariableNames()
        Description copied from interface: ZestContainer
        Returns all of the variable names defined by this staement and its children.
        Specified by:
        getVariableNames in interface ZestContainer
        Returns:
        the tokens
      • isLastState

        public abstract boolean isLastState()
        checks if the loop is on its last state
        Returns:
        true if the loop is over
      • increase

        protected abstract void increase()
        increase the loop indexes
      • toLastState

        public abstract void toLastState()
        ends the loop taking its current state to the last state
      • onControlBreak

        public void onControlBreak()
        act as a BREAK
      • onControlNext

        public void onControlNext()
        act as a NEXT
      • copyStatements

        public List<ZestStatement> copyStatements()
        Copy statements.
        Returns:
        the list of copied statements
      • getVariableName

        public String getVariableName()
        Returns the variable name.
        Returns:
        the variable name
      • setVariableName

        public void setVariableName​(String name)
        Sets the variable name.
        Parameters:
        name - the new variable name
      • isPassive

        public boolean isPassive()
        Description copied from class: ZestStatement
        Checks if is passive.
        Specified by:
        isPassive in class ZestStatement
        Returns:
        true, if is passive