final String namespace,
final String name,
final String attributeValue,
final ReportAttributeMap attributes) throws ParseException
{
final AttributeMetaData attributeMetaData = metaData.getAttributeDescription(namespace, name);
if (attributeMetaData == null || attributeValue == null)
{
element.setAttribute(namespace, name, attributeValue);
return;
}
if (attributeMetaData.isTransient())
{
return;
}
if ("Resource".equals(attributeMetaData.getValueRole()))
{
try
{
final Object type = attributes.getAttribute(AttributeNames.Core.NAMESPACE, "resource-type");
if ("url".equals(type))
{
element.setAttribute(namespace, name, new URL(attributeValue));
return;
}
if ("file".equals(type))
{
element.setAttribute(namespace, name, new File(attributeValue));
return;
}
if ("local-ref".equals(type))
{
element.setAttribute(namespace, name, attributeValue);
return;
}
if ("resource-key".equals(type))
{
final ResourceManager resourceManager = getRootHandler().getResourceManager();
final ResourceKey key = getRootHandler().getContext();
final ResourceKey parent = key.getParent();
final ResourceKey valueKey = resourceManager.deserialize(parent, attributeValue);
// make local ..
final ResourceKey resourceKey = localizeKey(resourceManager, valueKey);
element.setAttribute(namespace, name, resourceKey);
return;
}
element.setAttribute(namespace, name, attributeValue);
return;
}
catch (MalformedURLException e)
{
throw new ParseException("Failed to parse URL value", e);
}
catch (ResourceKeyCreationException e)
{
throw new ParseException("Failed to parse resource-key value", e);
}
}
final Class type = attributeMetaData.getTargetType();
if (String.class.equals(type))
{
element.setAttribute(namespace, name, attributeValue);
}
else
{
try
{
final PropertyEditor propertyEditor = attributeMetaData.getEditor();
if (propertyEditor != null)
{
propertyEditor.setAsText(attributeValue);
element.setAttribute(namespace, name, propertyEditor.getValue());
}