/** {@inheritDoc} */ public Object evaluate(Attribute attribute, TilesRequestContext request) { if (attribute == null) { throw new IllegalArgumentException("The attribute cannot be null"); } Object retValue = attribute.getValue(); if (retValue == null) { retValue = evaluate(attribute.getExpression(), request); } return retValue; } }
/** * Inherits an attribute, i.e. overwrites null properties with the ones * provided by the attribute. * * @param attribute The attribute to inherit. * @since 2.1.2 */ public void inherit(Attribute attribute) { if (value == null) { value = attribute.getValue(); } if (expression == null) { expression = attribute.getExpression(); } if (roles == null || roles.isEmpty()) { roles = attribute.getRoles(); } if (renderer == null) { renderer = attribute.getRenderer(); } }
/** * 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; }