private TagNode getNextTag(TagNode t) { TemplateNode next = t.getNextSibling(); TemplateNode nextNext = null; if (next instanceof TextNode && ((TextNode) next).isWhiteSpace()) { nextNext = next.getNextSibling(); } return (next instanceof TagNode) ? (TagNode) next : (nextNext instanceof TagNode) ? (TagNode) nextNext : null; }
public void pack() { if (current != null) { add(current); } mergeConditionalBlocks(); for (Fragment f : this) { f.pack(); } }
public FragmentList append(String contents) { if (!(current instanceof StaticFragment)) { if (current != null) { add(current); } current = new StaticFragment(); } ((StaticFragment) current).append(contents); return this; }
public void modify(TemplateDocument doc, String value, TagNode t) { ArrayList<Tag> tags = t.getElementsByTagName("img"); for (Tag tag : tags) { if (!tag.hasAttribute("alt")) { tag.addAttribute(new SimpleAttribute("alt", "", line, col)); } } if (t.getTagName().equalsIgnoreCase("img")) { if (!t.hasAttribute("alt")) { t.addAttribute(new SimpleAttribute("alt", "", line, col)); } } }
public ForeachBehavior get(DynamicAttribute keyAttribute, Map<AttributeKey, Attribute> attributes, int line, int col) throws ExpressionParsingException, BehaviorInstantiationException { AttributeKey asKey = new AttributeKey(keyAttribute.getAttributeNameSpace(), "as"); Attribute asAttribute = attributes.get(asKey); AttributeKey iterKey = new AttributeKey(keyAttribute.getAttributeNameSpace(), "iter"); Attribute iterAttribute = attributes.get(iterKey); Expression e = keyAttribute.getExpression(); return new ForeachBehavior(e, asAttribute == null ? null : asAttribute.getValue(), iterAttribute == null ? null : iterAttribute.getValue(), line, col); } };
public FragmentList normalizeUntil(TemplateNode n, boolean inclusive) throws BehaviorInstantiationException { FragmentList list = new FragmentList(expressionLanguage); for (TemplateNode t : children) { if (t.normalizeUntil(this, n, list, inclusive)) { break; } } list.pack(); return list; }
public void modify(ExpressionContext context, ModifyableTag tag) throws ExpressionEvaluationException { if (expression.asBoolean(context)) { tag.getTagParts().add(new SimpleAttribute("selected", "selected", getLine(), getCol())); } }
public Tag addExpression(Expression expression) throws ExpressionParsingException { addChild(new ExpressionNode("", expression)); return this; }
@Override public boolean normalizeUntil(TemplateDocument doc, TemplateNode reference, FragmentList f, boolean inclusive) throws BehaviorInstantiationException { if (reference == this) { if (inclusive) { f.addFragment(this); } return true; } else { f.addFragment(this); return false; } }
public void printTo(Writer out) throws IOException, TemplateEvaluationException { for (Fragment f : fragments) { f.eval(context, out); } }
public Tag getElementById(String id) { for (TemplateNode t : children) { Tag n = t.getElementById(id); if (n != null) { return n; } } return null; }
public void addFragment(Fragment f) { if (current != null) { add(current); } current = f; }
public WithBehavior get(DynamicAttribute keyAttribute, Map<AttributeKey, Attribute> attributes, int line, int col) throws ExpressionParsingException, BehaviorInstantiationException { AttributeKey asKey = new AttributeKey(keyAttribute.getAttributeNameSpace(), "as"); Attribute asAttribute = attributes.get(asKey); return new WithBehavior(keyAttribute.getExpression(), asAttribute == null ? null : asAttribute.getValue(), line, col); } };
@Override final boolean normalizeUntil(TemplateDocument doc, TemplateNode reference, FragmentList f, boolean inclusive) { if (reference == this) { if (inclusive) { f.addFragment(this); } return true; } else { f.addFragment(this); return false; } }
private void printFragments(ExpressionContext context, Writer out) throws IOException, TemplateEvaluationException { if (fragments != null) { for (Fragment f : fragments) { f.eval(context, out); } } }
@Override boolean normalizeUntil(TemplateDocument doc, TemplateNode reference, FragmentList f, boolean inclusive) { if (reference == this) { if (inclusive) { f.addFragment(this); } return true; } else { f.addFragment(this); return false; } }
@Override void normalize(TemplateDocument doc, FragmentList fList) throws BehaviorInstantiationException { fList.addFragment(this); }