@Override public void endElement(String uri, String localName, String qName) { depth--; if (depth == 1) { if (equalsOrSuffix(qName, "DiskSection")) { inDisk = false; builder.diskSection(diskHandler.getResult()); } else if (equalsOrSuffix(qName, "NetworkSection")) { inNetwork = false; builder.networkSection(networkHandler.getResult()); } else if (equalsOrSuffix(qName, "VirtualSystem")) { inVirtualSystem = false; builder.virtualSystem(virtualSystemHandler.getResult()); } else if (extensionHandlers.containsKey(qName)) { builder.additionalSection(qName, extensionHandler.getResult()); inExtensionSection = false; } else if (qName.endsWith("Section")) { builder.additionalSection(qName, defaultSectionHandler.getResult()); inSection = false; } } if (inDisk) { diskHandler.endElement(uri, localName, qName); } else if (inNetwork) { networkHandler.endElement(uri, localName, qName); } else if (inVirtualSystem) { virtualSystemHandler.endElement(uri, localName, qName); } else if (inExtensionSection) { extensionHandler.endElement(uri, localName, qName); } else if (inSection) { defaultSectionHandler.endElement(uri, localName, qName); } }
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs); depth++; if (depth == 2) { if (equalsOrSuffix(qName, "DiskSection")) { inDisk = true; } else if (equalsOrSuffix(qName, "NetworkSection")) { inNetwork = true; } else if (equalsOrSuffix(qName, "VirtualSystem")) { inVirtualSystem = true; } else if (extensionHandlers.containsKey(qName) || attributes.containsKey("type") && extensionHandlers.containsKey(attributes.get("type"))) { inExtensionSection = true; extensionHandler = extensionHandlers.get(qName).get(); } else if (qName.endsWith("Section")) { inSection = true; } } if (inDisk) { diskHandler.startElement(uri, localName, qName, attrs); } else if (inNetwork) { networkHandler.startElement(uri, localName, qName, attrs); } else if (inVirtualSystem) { virtualSystemHandler.startElement(uri, localName, qName, attrs); } else if (inExtensionSection) { extensionHandler.startElement(uri, localName, qName, attrs); } else if (inSection) { defaultSectionHandler.startElement(uri, localName, qName, attrs); } }
@Override public void characters(char ch[], int start, int length) { if (inDisk) { diskHandler.characters(ch, start, length); } else if (inNetwork) { networkHandler.characters(ch, start, length); } else if (inVirtualSystem) { virtualSystemHandler.characters(ch, start, length); } else if (inExtensionSection) { extensionHandler.characters(ch, start, length); } else if (inSection) { defaultSectionHandler.characters(ch, start, length); } }