public boolean conditionMet(ExpressionContext context) throws ExpressionEvaluationException { return expression == null || expression.asBoolean(context); }
public void modify(ExpressionContext context, ModifyableTag tag) throws ExpressionEvaluationException { if (expression.asBoolean(context)) { tag.getTagParts().add(new SimpleAttribute("selected", "selected", getLine(), getCol())); } }
public void eval(ExpressionContext context, Writer out) throws IOException, TemplateEvaluationException { if (firstCondition == null) { return; } try { if (firstCondition.expression.asBoolean(context)) { firstCondition.tag.eval(context, out); return; } if (alternateConditions == null && defaultCondition == null) { return; } if (alternateConditions != null) { for (Condition c : alternateConditions) { if (c.expression.asBoolean(context)) { c.tag.eval(context, out); return; } } } if (defaultCondition != null) { defaultCondition.eval(context, out); } } catch (ExpressionEvaluationException e) { e.printStackTrace(); } }
public void modify(ExpressionContext context, ModifyableTag tag) throws ExpressionEvaluationException { if (!expression.asBoolean(context)) { int remove = -1; boolean next = false; for (int i = 0; i < tag.getTagParts().size(); i++) { TagPart t = tag.getTagParts().get(i); if (t == attribute) { next = true; } else { if (next) { if (t instanceof Attribute) { Attribute a = (Attribute) t; if (!a.isDynamic()) { remove = i; } } } } } if (remove != -1) { tag.getTagParts().remove(remove); } } }
@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()); } }