/** @author Adrian Cole */ public class NetworkSectionHandler extends SectionHandler<NetworkSection, NetworkSection.Builder> { protected Network.Builder networkBuilder = Network.builder(); @Inject public NetworkSectionHandler(Provider<NetworkSection.Builder> builderProvider) { super(builderProvider); } public void startElement(String uri, String localName, String qName, Attributes attrs) { Map<String, String> attributes = SaxUtils.cleanseAttributes(attrs); if (equalsOrSuffix(qName, "Network")) { networkBuilder.name(attributes.get("name")); } } @Override public void endElement(String uri, String localName, String qName) { if (equalsOrSuffix(qName, "Info")) { builder.info(currentOrNull(currentText)); } else if (equalsOrSuffix(qName, "Description")) { networkBuilder.description(currentOrNull(currentText)); } else if (equalsOrSuffix(qName, "Network")) { try { builder.network(networkBuilder.build()); } finally { networkBuilder = Network.builder(); } } super.endElement(uri, localName, qName); } }
@Override public void endElement(String uri, String localName, String qName) { if (equalsOrSuffix(qName, "Info")) { builder.info(currentOrNull(currentText)); } else if (equalsOrSuffix(qName, "Description")) { networkBuilder.description(currentOrNull(currentText)); } else if (equalsOrSuffix(qName, "Network")) { try { builder.network(networkBuilder.build()); } finally { networkBuilder = Network.builder(); } } super.endElement(uri, localName, qName); }