Class LoopStatement
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.templateModel.AbstractTemplateElement
-
- net.ssehub.easy.instantiation.core.model.templateModel.LoopStatement
-
- All Implemented Interfaces:
ILanguageElement,ITemplateElement,ITemplateLangElement
public class LoopStatement extends AbstractTemplateElement
Representation of a loop-statement in VIL which allows multiple processing of aWorkflowElementBlockinstance.- Author:
- kroeher
-
-
Field Summary
Fields Modifier and Type Field Description private ExpressioncontainerExpressionprivate ExpressionfinalSeparatorExpressionprivate VariableDeclarationiteratorVarprivate ExpressionseparatorExpressionprivate ITemplateElementstatement
-
Constructor Summary
Constructors Constructor Description LoopStatement()Constructor for serialization.LoopStatement(VariableDeclaration iteratorVar, Expression containerExpression, ITemplateElement statement, Expression separatorExpression, Expression finalSeparatorExpression)Create a loop-statement.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectaccept(IVisitor visitor)Accepts the visitor for visiting.booleanendsWithContentStatement()Returns whether this element ends with a content statement.ExpressiongetContainerExpression()Get the expression of this loop which defines the set of elements to iterate over.ExpressiongetFinalSeparatorExpression()Returns the optional final separator expression.VariableDeclarationgetIteratorVariable()Returns the iterator variable.ITemplateElementgetLoopStatement()Get the loop-statement which may subsume a set of template elements that will be processed multiple times.ExpressiongetSeparatorExpression()Returns the optional separator expression.TypeDescriptor<?>inferType()Infers the type of this language element.booleanisBlock()Returns whether this element is a block (opposite is a single statement).protected voidsetParent(ILanguageElement parent)Changes the parent.-
Methods inherited from class net.ssehub.easy.instantiation.core.model.templateModel.AbstractTemplateElement
getParent
-
-
-
-
Field Detail
-
iteratorVar
private VariableDeclaration iteratorVar
-
containerExpression
private Expression containerExpression
-
statement
private ITemplateElement statement
-
separatorExpression
private Expression separatorExpression
-
finalSeparatorExpression
private Expression finalSeparatorExpression
-
-
Constructor Detail
-
LoopStatement
LoopStatement()
Constructor for serialization.
-
LoopStatement
public LoopStatement(VariableDeclaration iteratorVar, Expression containerExpression, ITemplateElement statement, Expression separatorExpression, Expression finalSeparatorExpression) throws VilException
Create a loop-statement.- Parameters:
iteratorVar- the iterator variable (name and type of iterator variable)containerExpression- the container to iterate overstatement- the loop-statement which may subsumes a set of template elements that will be processed multiple times.separatorExpression- an optional separator expression to be emitted between elements (may be null)finalSeparatorExpression- an optional separator expression to be emitted after the last element (may be null)- Throws:
VilException- in case of semantic problems while creating this loop object
-
-
Method Detail
-
getSeparatorExpression
public Expression getSeparatorExpression()
Returns the optional separator expression.- Returns:
- the separator expression or null
-
getFinalSeparatorExpression
public Expression getFinalSeparatorExpression()
Returns the optional final separator expression.- Returns:
- the separator expression or null
-
getIteratorVariable
public VariableDeclaration getIteratorVariable()
Returns the iterator variable.- Returns:
- The iterator variable.
-
getContainerExpression
public Expression getContainerExpression()
Get the expression of this loop which defines the set of elements to iterate over.- Returns:
- The
Expressionof this loop.
-
getLoopStatement
public ITemplateElement getLoopStatement()
Get the loop-statement which may subsume a set of template elements that will be processed multiple times.- Returns:
- The template element that represents the loop-statement/block.
-
accept
public java.lang.Object accept(IVisitor visitor) throws VilException
Description copied from interface:ITemplateLangElementAccepts 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:ITemplateElementReturns whether this element is a block (opposite is a single statement).- Returns:
trueif it is a block,falseelse
-
inferType
public TypeDescriptor<?> inferType() throws VilException
Description copied from interface:ITemplateElementInfers the type of this language element.- Returns:
- the type of this language element
- Throws:
VilException- in case that type errors occur
-
setParent
protected void setParent(ILanguageElement parent)
Description copied from class:AbstractTemplateElementChanges the parent. Please override if children must be adjusted according. Shall be called only once per instance, but there is no limitation.- Overrides:
setParentin classAbstractTemplateElement- Parameters:
parent- the parent
-
endsWithContentStatement
public boolean endsWithContentStatement()
Description copied from interface:ITemplateElementReturns whether this element ends with a content statement.- Returns:
truefor end with content statement,falseelse
-
-