Class ContentLoopExpression
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.expressions.Expression
-
- net.ssehub.easy.instantiation.core.model.templateModel.InContentExpression
-
- net.ssehub.easy.instantiation.core.model.templateModel.ContentLoopExpression
-
- All Implemented Interfaces:
IExpressionIterator
public class ContentLoopExpression extends InContentExpression implements IExpressionIterator
Implements a content loop expression.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<Expression>bodyprivate ExpressionendSeparatorprivate Expressioninitprivate VariableDeclarationiteratorprivate Expressionseparator
-
Constructor Summary
Constructors Constructor Description ContentLoopExpression(VariableDeclaration iterator, Expression init, Expression separator, Expression endSeparator, java.util.List<Expression> body)Creates a content loop expression.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectaccept(IExpressionVisitor visitor)Visits the expression.private voidassertSeparatorEx(Expression ex, java.lang.String text)Asserts that a separator expression evaluates to a String.ExpressiongetEndSeparator()Returns the optional end separator expression.ExpressiongetExpression(int index)Returns the specified body expression.intgetExpressionsCount()Returns the number of body expression.ExpressiongetInit()Returns the initialization expression.VariableDeclarationgetIterator()Returns the iterator declaration.ExpressiongetSeparator()Returns the optional separator expression.-
Methods inherited from class net.ssehub.easy.instantiation.core.model.templateModel.InContentExpression
inferType, replaceEmptyLine
-
-
-
-
Field Detail
-
iterator
private VariableDeclaration iterator
-
init
private Expression init
-
separator
private Expression separator
-
endSeparator
private Expression endSeparator
-
body
private java.util.List<Expression> body
-
-
Constructor Detail
-
ContentLoopExpression
public ContentLoopExpression(VariableDeclaration iterator, Expression init, Expression separator, Expression endSeparator, java.util.List<Expression> body) throws VilException
Creates a content loop expression.- Parameters:
iterator- the iteratorinit- the initialization expression (shall/cannot be assigned toiteratoras collection)separator- the optional element separator (may be null)endSeparator- the optional end separator (may be null)body- the loop body- Throws:
VilException- if creation fails
-
-
Method Detail
-
assertSeparatorEx
private void assertSeparatorEx(Expression ex, java.lang.String text) throws VilException
Asserts that a separator expression evaluates to a String.- Parameters:
ex- the expression, may be null (ignored then)text- text prefix if type assertion fails- Throws:
VilException- in case that obtaining the type fails
-
getIterator
public VariableDeclaration getIterator()
Returns the iterator declaration.- Returns:
- the iterator declaration
-
getInit
public Expression getInit()
Returns the initialization expression.- Returns:
- the initialization expression
-
getSeparator
public Expression getSeparator()
Returns the optional separator expression.- Returns:
- the expression or null
-
getEndSeparator
public Expression getEndSeparator()
Returns the optional end separator expression.- Returns:
- the expression or null
-
getExpressionsCount
public int getExpressionsCount()
Returns the number of body expression.- Specified by:
getExpressionsCountin interfaceIExpressionIterator- Returns:
- the number of expressions
-
getExpression
public Expression getExpression(int index)
Returns the specified body expression.- Specified by:
getExpressionin interfaceIExpressionIterator- Parameters:
index- the 0-based index of the expression- Returns:
- the expression
- Throws:
java.lang.IndexOutOfBoundsException- ifindex<0 || index>=#getBodyExpressionsCount()
-
accept
public java.lang.Object accept(IExpressionVisitor visitor) throws VilException
Description copied from class:ExpressionVisits the expression.- Specified by:
acceptin classExpression- Parameters:
visitor- the visitor- Returns:
- the result of visiting this expression (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
-