use of org.talend.xml.sax.exception.EnoughDataException in project tdi-studio-se by Talend.
the class SimpleSAXLoopHandler method endElement.
/*
* (non-Javadoc)
*
* @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
*/
public void endElement(String uri, String localName, String qName) throws SAXException {
for (XMLNode node : nodes.getNodesCollection()) {
if (node.isLooping) {
if (node.outputText) {
if (node.hasValue == false) {
node.addTextValue("");
}
node.hasValue = true;
}
if ((node.isAsXML || node.isDot) && (this.currentPath.equals(node.nodePath) || this.currentPath.startsWith(node.nodePath + "/"))) {
if (node.isAsXML) {
node.addTextValue("</");
node.addTextValue(qName);
node.addTextValue(">");
}
if (this.currentPath.equals(node.nodePath)) {
node.hasValue = true;
}
}
}
node.outputText = false;
}
if (this.currentPath.equals(nodes.getLoopPath())) {
if (isNotNull(nodes.getNodesCollection(), nodes.size())) {
Map<String, String> map = new HashMap<String, String>();
for (XMLNode node : nodes.getNodesCollection()) {
map.put(node.originPath, node.getTextValue());
}
if (multiCache != null) {
HashMap<String, Map<String, String>> row = new HashMap<String, Map<String, String>>(1);
row.put(nodes.getOriginalLoopPath(), map);
multiCache.writeData(row);
} else {
bufferCache.writeData(map);
}
if (stop) {
throw new EnoughDataException("Get enough data,now stop the xml parse action");
}
}
nodes.resetAll();
}
this.currentPath = this.currentPath.substring(0, this.currentPath.lastIndexOf("/"));
}
Aggregations