use of org.freeplane.core.io.IElementWriter in project freeplane by freeplane.
the class TreeXmlWriter method addElement.
@SuppressWarnings("unchecked")
public void addElement(final Object userObject, final XMLElement element) throws IOException {
final boolean isString = userObject instanceof String;
if (elementStarted == false && xmlElement != null) {
xmlwriter.write(xmlElement, !isString, 0, true, false);
}
final String name = element.getName();
xmlElement = element;
elementStarted = false;
{
final Iterator<IAttributeWriter> iterator = getAttributeWriters().iterator(name);
while (iterator.hasNext()) {
final IAttributeWriter as = iterator.next();
as.writeAttributes(this, userObject, name);
}
if (userObject instanceof List<?>) {
addExtensionAttributes(userObject, (List<IExtension>) userObject);
}
}
if (isString) {
addElementContent((String) userObject);
} else {
final Iterator<IElementWriter> iterator = getNodeWriters().iterator(name);
while (iterator.hasNext()) {
final IElementWriter nw = iterator.next();
nw.writeContent(this, userObject, name);
}
if (userObject instanceof List<?>) {
addExtensionNodes(userObject, (List<IExtension>) userObject);
}
}
if (elementStarted == false) {
xmlwriter.write(xmlElement, true, 0, true, true);
elementStarted = true;
} else {
xmlwriter.endElement(name, true);
}
}
Aggregations