use of org.freeplane.core.io.IElementContentHandler in project freeplane by freeplane.
the class TreeXmlReader method elementAttributesProcessed.
/*
* (non-Javadoc)
* @see
* freeplane.persistence.xml.n3.nanoxml.IXMLBuilder#elementAttributesProcessed
* (java.lang.String, java.lang.String, java.lang.String)
*/
public void elementAttributesProcessed(final String name, final String nsPrefix, final String nsURI) throws Exception {
xmlBuilder.elementAttributesProcessed(name, nsPrefix, nsURI);
if (saveAsXmlUntil != null || nodeCreator != null) {
return;
}
final Iterator<IElementHandler> iterator = getElementHandlers().iterator(tag);
final XMLElement lastBuiltElement = xmlBuilder.getLastBuiltElement();
while (iterator.hasNext() && currentElement == null) {
nodeCreator = iterator.next();
try {
currentElement = nodeCreator.createElement(parentElement, name, lastBuiltElement);
} catch (Exception e) {
LogUtils.severe("Can not process element" + name, e);
}
}
if (currentElement != null) {
if (nodeCreator instanceof IElementContentHandler) {
parser.notParseNextElementContent();
}
attributeHandlersForTag = getAttributeLoaders().get(tag);
if (attributeHandlersForTag == null) {
return;
}
final Enumeration<String> attributeNames = lastBuiltElement.enumerateAttributeNames();
while (attributeNames.hasMoreElements()) {
final String atName = (String) attributeNames.nextElement();
if (addAttribute(atName, lastBuiltElement.getAttribute(atName, null))) {
lastBuiltElement.removeAttribute(atName);
}
}
} else {
currentElement = null;
nodeCreator = null;
saveAsXmlUntil = lastBuiltElement;
}
}
use of org.freeplane.core.io.IElementContentHandler in project freeplane by freeplane.
the class TreeXmlReader method endElement.
/*
* (non-Javadoc)
* @see
* freeplane.persistence.xml.n3.nanoxml.IXMLBuilder#endElement(java.lang
* .String, java.lang.String, java.lang.String)
*/
public void endElement(final String name, final String nsPrefix, final String nsURI) throws Exception {
final XMLElement lastBuiltElement = xmlBuilder.getParentElement();
xmlBuilder.endElement(name, nsPrefix, nsURI);
if (saveAsXmlUntil == lastBuiltElement) {
saveAsXmlUntil = null;
}
if (saveAsXmlUntil != null) {
return;
}
tag = null;
if (0 == elementStack.size()) {
return;
}
final Object element = currentElement;
currentElement = elementStack.removeLast();
try {
if (nodeCreator instanceof IElementContentHandler) {
((IElementContentHandler) nodeCreator).endElement(currentElement, name, element, lastBuiltElement, elementContentAsString);
} else if (nodeCreator instanceof IElementDOMHandler) {
((IElementDOMHandler) nodeCreator).endElement(currentElement, name, element, lastBuiltElement);
}
} catch (Exception e) {
LogUtils.severe("Can not process element" + name, e);
}
final XMLElement top = lastBuiltElement.getParent();
if (nodeCreator != null && top != null && top.hasChildren()) {
final int lastChildIndex = top.getChildrenCount() - 1;
top.removeChildAtIndex(lastChildIndex);
}
nodeCreator = (IElementHandler) nodeCreatorStack.removeLast();
elementContentAsString = null;
}
Aggregations