private void iterateIterable(ExpressionContext context, TagNode tag, Writer out, Iterable<Object> o) throws IOException, TemplateEvaluationException { Iter iter = new Iter(); context.put(getIterObjectName(), iter); Iterator<?> it = o.iterator(); while (it.hasNext()) { Object o1 = it.next(); if (!it.hasNext()) { iter.setLast(); } context.put(getCurrentObjectName(), o1); tag.execute(context, out); iter.next(); } }
private void iterateArray(ExpressionContext context, TagNode tag, Writer out, Object[] o) throws IOException, TemplateEvaluationException { Iter iter = new Iter(); context.put(getIterObjectName(), iter); for (int i=0; i<o.length; i++) { if (i == o.length-1) iter.setLast(); context.put(getCurrentObjectName(), o[i]); tag.execute(context, out); iter.next(); } }
private void iterateInt(ExpressionContext context, TagNode tag, Writer out, int[] o) throws IOException, TemplateEvaluationException { Iter iter = new Iter(); context.put(getIterObjectName(), iter); for (int i=0; i<o.length; i++) { if (i == o.length-1) iter.setLast(); context.put(getCurrentObjectName(), o[i]); tag.execute(context, out); iter.next(); } }
private void iterateFloat(ExpressionContext context, TagNode tag, Writer out, float[] o) throws IOException, TemplateEvaluationException { Iter iter = new Iter(); context.put(getIterObjectName(), iter); for (int i=0; i<o.length; i++) { if (i == o.length-1) iter.setLast(); context.put(getCurrentObjectName(), o[i]); tag.execute(context, out); iter.next(); } }
private void iterateByte(ExpressionContext context, TagNode tag, Writer out, byte[] o) throws IOException, TemplateEvaluationException { Iter iter = new Iter(); context.put(getIterObjectName(), iter); for (int i=0; i<o.length; i++) { if (i == o.length-1) iter.setLast(); context.put(getCurrentObjectName(), o[i]); tag.execute(context, out); iter.next(); } }
private void iterateDouble(ExpressionContext context, TagNode tag, Writer out, double[] o) throws IOException, TemplateEvaluationException { Iter iter = new Iter(); context.put(getIterObjectName(), iter); for (int i=0; i<o.length; i++) { if (i == o.length-1) iter.setLast(); context.put(getCurrentObjectName(), o[i]); tag.execute(context, out); iter.next(); } }
private void iterateChar(ExpressionContext context, TagNode tag, Writer out, char[] o) throws IOException, TemplateEvaluationException { Iter iter = new Iter(); context.put(getIterObjectName(), iter); for (int i=0; i<o.length; i++) { if (i == o.length-1) iter.setLast(); context.put(getCurrentObjectName(), o[i]); tag.execute(context, out); iter.next(); } }
private void iterateBoolean(ExpressionContext context, TagNode tag, Writer out, boolean[] o) throws IOException, TemplateEvaluationException { Iter iter = new Iter(); context.put(getIterObjectName(), iter); for (int i=0; i<o.length; i++) { if (i == o.length-1) iter.setLast(); context.put(getCurrentObjectName(), o[i]); tag.execute(context, out); iter.next(); } }
@Override public void doExecute(ExpressionContext context, TagNode tag, Writer out) throws TemplateEvaluationException, IOException { try { Iter iter = new Iter(); while (expression.asBoolean(context)) { 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()); } }
@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()); } }
@Override public void doExecute(ExpressionContext context, TagNode tag, Writer out) throws TemplateEvaluationException, IOException { try { Iter iter = new Iter(); for (int i = from.asInt(context); i <= to.asInt(context); i++) { if (i == to.asInt(context)) 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()); } }