/** {@inheritDoc} */ public Object evaluate(Attribute attribute, Request request) { if (attribute == null) { throw new IllegalArgumentException("The attribute cannot be null"); } Object retValue = attribute.getValue(); if (retValue == null) { Expression expression = attribute.getExpressionObject(); if (expression != null) { retValue = evaluate(attribute.getExpressionObject() .getExpression(), request); } } return retValue; } }
/** {@inheritDoc} */ public AttributeEvaluator getAttributeEvaluator(Attribute attribute) { Expression expression = attribute.getExpressionObject(); if (expression != null) { return getAttributeEvaluator(expression.getLanguage()); } return defaultEvaluator; } }
/** * 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(); } Expression targetExpressionObject = attribute.getExpressionObject(); if (targetExpressionObject != null && (expressionObject == null || expressionObject .getExpression() == null)) { expressionObject = new Expression(targetExpressionObject); } if (roles == null || roles.isEmpty()) { roles = attribute.getRoles(); } if (renderer == null) { renderer = attribute.getRenderer(); } }
/** * Replaces variables into a simple (not list) 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 static Attribute replaceVarsInSimpleAttribute(Attribute attr, Object... vars) { Attribute nuattr; nuattr = new Attribute(); nuattr.setRole(replace(attr.getRole(), vars)); nuattr.setRenderer(attr.getRenderer()); Expression expressionObject = attr.getExpressionObject(); if (expressionObject != null) { Expression newExpressionObject = Expression .createExpression(replace(expressionObject.getExpression(), vars), expressionObject.getLanguage()); nuattr.setExpressionObject(newExpressionObject); } Object value = attr.getValue(); if (value instanceof String) { value = replace((String) value, vars); } nuattr.setValue(value); return nuattr; }