}
@Override
public void doExecute(ExpressionContext context, TagNode tag, Writer out) throws TemplateEvaluationException, IOException {
try {
Iter iter = new Iter();
int n = number.asInt(context);
for (int i = 0; i != n; i++) {
if (i == n - 1) {
iter.setLast();
}
context.put(Expressions.CURRENT_OBJECT, i);
context.put(Expressions.ITER_OBJECT, iter);
tag.execute(context, out);
iter.next();
}
} catch (ExpressionEvaluationException e) {
throw new TemplateEvaluationException(e, "Could not execute the expression: " +
e.getMessage() + ", on line: " + tag.getBeginLine() + ", column: " +
tag.getBeginColumn(), tag.getBeginLine(), tag.getBeginColumn(), tag.getTagName());