if (namespaces.length == 0)
{
return false;
}
final ConverterRegistry instance = ConverterRegistry.getInstance();
final ElementMetaData metaData = e.getMetaData();
boolean retval = false;
for (int namespaceIdx = 0; namespaceIdx < namespaces.length; namespaceIdx++)
{
final String namespace = namespaces[namespaceIdx];
final String[] names = e.getAttributeExpressionNames(namespace);
for (int nameIdx = 0; nameIdx < names.length; nameIdx++)
{
final String name = names[nameIdx];
final Expression ex = e.getAttributeExpression(namespace, name);
if (ex == null)
{
continue;
}
final AttributeMetaData attribute = metaData.getAttributeDescription(namespace, name);
if (attribute != null && attribute.isDesignTimeValue())
{
continue;
}
retval = true;
ex.setRuntime(getRuntime());
try
{
final Object value = evaluate(ex);
if (attribute == null)
{
// Not a declared attribute, but maybe one of the output-handlers can work on this one.
e.setAttribute(namespace, name, value);
}
else
{
final Class<?> type = attribute.getTargetType();
if (value == null || type.isAssignableFrom(value.getClass()))
{
e.setAttribute(namespace, name, value);
}
else if (value instanceof ErrorValue)
{
if (failOnErrors)
{
throw new InvalidReportStateException(String.format
("Failed to evaluate attribute-expression for attribute %s:%s on element [%s]", // NON-NLS
namespace, name,
FunctionUtilities.computeElementLocation(e)));
}
e.setAttribute(namespace, name, null);
}
else
{
final PropertyEditor propertyEditor = attribute.getEditor();
if (propertyEditor != null)
{
propertyEditor.setAsText(String.valueOf(value));
e.setAttribute(namespace, name, propertyEditor.getValue());
}
else
{
final ValueConverter valueConverter = instance.getValueConverter(type);
if (type.isAssignableFrom(String.class))
{
// the attribute would allow raw-string values, so copy the element ..
e.setAttribute(namespace, name, value);
}