Class SwitchStatement

    • Constructor Detail

      • SwitchStatement

        SwitchStatement()
        Constructor for serialization.
      • SwitchStatement

        public SwitchStatement​(Expression switchExpression,
                               VariableDeclaration implicitVar,
                               java.util.List<SwitchStatement.Alternative> alternatives)
                        throws VilException
        Creates a new switch expression.
        Parameters:
        switchExpression - the switch expression
        implicitVar - the implicit variable representing the actual value of the switch expression
        alternatives - the alternatives in the switch including an optional default alternative
        Throws:
        VilException - in case of semantic problems while creating this instance
      • SwitchStatement

        public SwitchStatement​(Expression switchExpression,
                               VariableDeclaration implicitVar,
                               SwitchStatement.Alternative[] alternatives)
                        throws VilException
        Creates a new switch expression.
        Parameters:
        switchExpression - the switch expression
        implicitVar - the implicit variable representing the actual value of the switch expression
        alternatives - the alternatives in the switch including an optional default alternative
        Throws:
        VilException - in case of semantic problems while creating this instance
    • Method Detail

      • toArray

        public static final SwitchStatement.Alternative[] toArray​(java.util.List<SwitchStatement.Alternative> alternatives)
        Transforms the given alternatives into an array.
        Parameters:
        alternatives - the alternatives, may be null
        Returns:
        the alternatives as an array, null if the input was null
      • getSwitchExpression

        public Expression getSwitchExpression()
        Returns the switch expression.
        Returns:
        the switch expression
      • getAlternativeCount

        public int getAlternativeCount()
        Get the number of alternatives of this switch statement.
        Returns:
        The number of alternatives of this switch statement.
      • getAlternative

        public SwitchStatement.Alternative getAlternative​(int index)
        Get the alternative of this statement at the specified index.
        Parameters:
        index - The 0-based index of the alternative to be returned.
        Returns:
        The alternative at the given index.
        Throws:
        java.lang.IndexOutOfBoundsException - if index < 0 || index >=getAlternativeCount()
      • getImplicitVariable

        public VariableDeclaration getImplicitVariable()
        Returns the implicit variable defined by this switch statement.
        Returns:
        the implicit variable
      • accept

        public java.lang.Object accept​(IVisitor visitor)
                                throws VilException
        Description copied from interface: ITemplateLangElement
        Accepts the visitor for visiting.
        Parameters:
        visitor - the visitor to be used
        Returns:
        the result of visiting this instance (may be null)
        Throws:
        VilException - in case that visiting fails (e.g., execution)
      • isBlock

        public boolean isBlock()
        Description copied from interface: ITemplateElement
        Returns whether this element is a block (opposite is a single statement).
        Returns:
        true if it is a block, false else
      • setParent

        protected void setParent​(ILanguageElement parent)
        Description copied from class: AbstractTemplateElement
        Changes the parent. Please override if children must be adjusted according. Shall be called only once per instance, but there is no limitation.
        Overrides:
        setParent in class AbstractTemplateElement
        Parameters:
        parent - the parent
      • endsWithContentStatement

        public boolean endsWithContentStatement()
        Description copied from interface: ITemplateElement
        Returns whether this element ends with a content statement.
        Returns:
        true for end with content statement, false else