end = jj_consume_token(DIRECTIVE_END); children = MixedContentElements(); cblock = new ConditionalBlock(condition, children, ConditionalBlock.TYPE_IF); cblock.setLocation(template, start, end, children); ifBlock = new IfBlock(cblock); label_8: end = LooseDirectiveEnd(); children = MixedContentElements(); cblock = new ConditionalBlock(condition, children, ConditionalBlock.TYPE_ELSE_IF); cblock.setLocation(template, t, end, children); ifBlock.addBlock(cblock); t = jj_consume_token(ELSE); children = MixedContentElements(); cblock = new ConditionalBlock(null, children, ConditionalBlock.TYPE_ELSE); cblock.setLocation(template, t, t, children); ifBlock.addBlock(cblock); break;
@Override TemplateElement postParseCleanup(boolean stripWhitespace) throws ParseException { if (getChildCount() == 1) { ConditionalBlock cblock = (ConditionalBlock) getChild(0); cblock.setLocation(getTemplate(), cblock, this); return cblock.postParseCleanup(stripWhitespace); } else { return super.postParseCleanup(stripWhitespace); } }
@Override protected String dump(boolean canonical) { if (canonical) { StringBuilder buf = new StringBuilder(); int ln = getChildCount(); for (int i = 0; i < ln; i++) { ConditionalBlock cblock = (ConditionalBlock) getChild(i); buf.append(cblock.dump(canonical)); } buf.append("</#if>"); return buf.toString(); } else { return getNodeTypeSymbol(); } }
@Override protected String dump(boolean canonical) { StringBuilder buf = new StringBuilder(); if (canonical) buf.append('<'); buf.append(getNodeTypeSymbol()); if (condition != null) { buf.append(' '); buf.append(condition.getCanonicalForm()); } if (canonical) { buf.append(">"); buf.append(getChildrenCanonicalForm()); if (!(getParentElement() instanceof IfBlock)) { buf.append("</#if>"); } } return buf.toString(); }
@Override TemplateElement[] accept(Environment env) throws TemplateException, IOException { if (condition == null || condition.evalToBoolean(env)) { return getChildBuffer(); } return null; }
ConditionalBlock(Expression condition, TemplateElements children, int type) { this.condition = condition; setChildren(children); this.type = type; }
@Override protected String dump(boolean canonical) { StringBuilder buf = new StringBuilder(); if (canonical) buf.append('<'); buf.append(getNodeTypeSymbol()); if (condition != null) { buf.append(' '); buf.append(condition.getCanonicalForm()); } if (canonical) { buf.append(">"); buf.append(getChildrenCanonicalForm()); if (!(getParentElement() instanceof IfBlock)) { buf.append("</#if>"); } } return buf.toString(); }
@Override TemplateElement[] accept(Environment env) throws TemplateException, IOException { int ln = getChildCount(); for (int i = 0; i < ln; i++) { ConditionalBlock cblock = (ConditionalBlock) getChild(i); Expression condition = cblock.condition; env.replaceElementStackTop(cblock); if (condition == null || condition.evalToBoolean(env)) { return cblock.getChildBuffer(); } } return null; }
ConditionalBlock(Expression condition, TemplateElements children, int type) { this.condition = condition; setChildren(children); this.type = type; }
TemplateElement postParseCleanup(boolean stripWhitespace) throws ParseException { if (nestedElements.size() == 1) { ConditionalBlock cblock = (ConditionalBlock) nestedElements.get(0); cblock.isSimple = true; cblock.setLocation(getTemplate(), cblock, this); return cblock.postParseCleanup(stripWhitespace); } else { return super.postParseCleanup(stripWhitespace); } }
end = jj_consume_token(DIRECTIVE_END); children = MixedContentElements(); cblock = new ConditionalBlock(condition, children, ConditionalBlock.TYPE_IF); cblock.setLocation(template, start, end, children); ifBlock = new IfBlock(cblock); label_8: end = LooseDirectiveEnd(); children = MixedContentElements(); cblock = new ConditionalBlock(condition, children, ConditionalBlock.TYPE_ELSE_IF); cblock.setLocation(template, t, end, children); ifBlock.addBlock(cblock); t = jj_consume_token(ELSE); children = MixedContentElements(); cblock = new ConditionalBlock(null, children, ConditionalBlock.TYPE_ELSE); cblock.setLocation(template, t, t, children); ifBlock.addBlock(cblock); break;
@Override protected String dump(boolean canonical) { StringBuilder buf = new StringBuilder(); if (canonical) buf.append('<'); buf.append(getNodeTypeSymbol()); if (condition != null) { buf.append(' '); buf.append(condition.getCanonicalForm()); } if (canonical) { buf.append(">"); buf.append(getChildrenCanonicalForm()); if (!(getParentElement() instanceof IfBlock)) { buf.append("</#if>"); } } return buf.toString(); }
@Override TemplateElement[] accept(Environment env) throws TemplateException, IOException { if (condition == null || condition.evalToBoolean(env)) { return getChildBuffer(); } return null; }
ConditionalBlock(Expression condition, TemplateElements children, int type) { this.condition = condition; setChildren(children); this.type = type; }
@Override protected String dump(boolean canonical) { if (canonical) { StringBuilder buf = new StringBuilder(); int ln = getChildCount(); for (int i = 0; i < ln; i++) { ConditionalBlock cblock = (ConditionalBlock) getChild(i); buf.append(cblock.dump(canonical)); } buf.append("</#if>"); return buf.toString(); } else { return getNodeTypeSymbol(); } }
@Override TemplateElement postParseCleanup(boolean stripWhitespace) throws ParseException { if (getChildCount() == 1) { ConditionalBlock cblock = (ConditionalBlock) getChild(0); cblock.setLocation(getTemplate(), cblock, this); return cblock.postParseCleanup(stripWhitespace); } else { return super.postParseCleanup(stripWhitespace); } }
end = jj_consume_token(DIRECTIVE_END); children = MixedContentElements(); cblock = new ConditionalBlock(condition, children, ConditionalBlock.TYPE_IF); cblock.setLocation(template, start, end, children); ifBlock = new IfBlock(cblock); label_8: end = LooseDirectiveEnd(); children = MixedContentElements(); cblock = new ConditionalBlock(condition, children, ConditionalBlock.TYPE_ELSE_IF); cblock.setLocation(template, t, end, children); ifBlock.addBlock(cblock); t = jj_consume_token(ELSE); children = MixedContentElements(); cblock = new ConditionalBlock(null, children, ConditionalBlock.TYPE_ELSE); cblock.setLocation(template, t, t, children); ifBlock.addBlock(cblock); break;
@Override TemplateElement[] accept(Environment env) throws TemplateException, IOException { if (condition == null || condition.evalToBoolean(env)) { return getChildBuffer(); } return null; }
@Override protected String dump(boolean canonical) { if (canonical) { StringBuilder buf = new StringBuilder(); int ln = getChildCount(); for (int i = 0; i < ln; i++) { ConditionalBlock cblock = (ConditionalBlock) getChild(i); buf.append(cblock.dump(canonical)); } buf.append("</#if>"); return buf.toString(); } else { return getNodeTypeSymbol(); } }
@Override TemplateElement postParseCleanup(boolean stripWhitespace) throws ParseException { if (getChildCount() == 1) { ConditionalBlock cblock = (ConditionalBlock) getChild(0); cblock.setLocation(getTemplate(), cblock, this); return cblock.postParseCleanup(stripWhitespace); } else { return super.postParseCleanup(stripWhitespace); } }