/** {@inheritDoc} */ @Override public void begin(String namespace, String name, Attributes attributes) throws Exception { Attribute attribute = (Attribute) digester.peek(); attribute.setValue(attributes.getValue("value")); attribute.setExpression(attributes.getValue("expression")); attribute.setRole(attributes.getValue("role")); attribute.setRenderer(attributes.getValue("type")); } }
/** * Creates a template attribute, starting from the expression to evaluate to * obtain the template. * * @param templateExpression The expression to evaluate. * @return The template attribute. * @since 2.1.2 */ public static Attribute createTemplateAttributeWithExpression( String templateExpression) { Attribute attribute = new Attribute(); attribute.setExpression(templateExpression); attribute.setRenderer(TEMPLATE_RENDERER); return attribute; }
/** {@inheritDoc} */ @Override public void begin(String namespace, String name, Attributes attributes) throws Exception { Definition definition = (Definition) digester.peek(); definition.setName(attributes.getValue("name")); definition.setPreparer(attributes.getValue("preparer")); definition.setExtends(attributes.getValue("extends")); String template = attributes.getValue("template"); Attribute attribute = Attribute.createTemplateAttribute(template); attribute.setExpression(attributes.getValue("templateExpression")); attribute.setRole(attributes.getValue("role")); String templateType = attributes.getValue("templateType"); if (templateType != null) { attribute.setRenderer(templateType); } definition.setTemplateAttribute(attribute); } }
/** * Replaces variables into an attribute. * * @param attr The attribute to be used as a basis, containing placeholders * for variables. * @param vars The variables to replace. * @return A new instance of an attribute, whose properties have been * replaced with variables' values. */ private Attribute replaceVarsInAttribute(Attribute attr, Map<Integer, String> vars) { Attribute nuattr = new Attribute(); nuattr.setRole(replace(attr.getRole(), vars)); nuattr.setRenderer(attr.getRenderer()); nuattr.setExpression(attr.getExpression()); Object value = attr.getValue(); if (value instanceof String) { value = replace((String) value, vars); } nuattr.setValue(value); return nuattr; }