* @param value
* Value for the simple content.
* @return The attribute with simple content type.
*/
private Attribute setSimpleContentValue(Attribute attribute, Object value) {
Property simpleContent = null;
if (attribute instanceof ComplexAttribute) {
simpleContent = ((ComplexAttribute)attribute).getProperty(ComplexFeatureConstants.SIMPLE_CONTENT);
}
if (simpleContent == null) {
Collection<Property> contents = new ArrayList<Property>();
simpleContent = buildSimpleContent(attribute.getType(), value);
contents.add(simpleContent);
ArrayList<Attribute> nestedAttContents = new ArrayList<Attribute>();
Attribute nestedAtt = new ComplexAttributeImpl(contents, attribute.getDescriptor(),
attribute.getIdentifier());
nestedAttContents.add(nestedAtt);
attribute.setValue(nestedAttContents);
return nestedAtt;
} else {
PropertyType simpleContentType = getSimpleContentType((AttributeType) simpleContent.getType());
Object convertedValue = FF.literal(value).evaluate(value,
simpleContentType.getBinding());
simpleContent.setValue(convertedValue);
return attribute;
}
}