/* (non-Javadoc)
* @see org.openquark.util.xml.XMLElementSerializer#storeToElement(org.openquark.util.xml.XMLSerializer, org.w3c.dom.Element, java.lang.Object)
*/
public void storeToElement(XMLSerializationManager manager, Element element, Object value) {
Attribute attribute = (Attribute) value;
Document doc = element.getOwnerDocument();
Element attrElement = doc.createElement(ROOT_TAG);
element.appendChild(attrElement);
// Name of the attribute is stored as an attribute of the XML element
attrElement.setAttribute(NAME_ATTRIBUTE, attribute.getName());
// The value(s) is/are stored as a child element(s). If there is only
// one value, just store it as is. Otherwise, wrap the list of values
// by a ListOfValues tag
List<?> values = attribute.getValues();
if (values.size() == 1) {
manager.storeToElement(attrElement, values.iterator().next());
} else {
Element lovElement = doc.createElement(LIST_OF_VALUES);
attrElement.appendChild(lovElement);
manager.storeToElement(lovElement, attribute.getValues());
}
}