}
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);
}
else if (valueConverter != null)
{
final Object o = ConverterRegistry.toPropertyValue(String.valueOf(value), type);
e.setAttribute(namespace, name, o);
}
else
{
// undo any previous computation
e.setAttribute(namespace, name, null);
}
}
}
}
}
catch (InvalidReportStateException exception)
{
throw exception;
}
catch (Exception exception)
{
if (logger.isDebugEnabled())
{
logger.debug(String.format
("Failed to evaluate attribute-expression for attribute %s:%s on element [%s]", // NON-NLS
namespace, name,
FunctionUtilities.computeElementLocation(e)), exception);
}
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)), exception);
}
e.setAttribute(namespace, name, null);