Refine search
protected boolean isInNamespace(String namespace) { if (namespace.length() == 0) { return true; } return getUris().contains(namespace); } }
@Override public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { if (localName.equals(ROOT_ELEMENT_NAME) && ("".equals(uri) || JAVAEE_URIS.contains(uri))) { processRootElement(attributes); return; } if (currentContainer == null) { Container container = getContainer(uri, localName); if (container != null) { if (seenContainers.contains(container)) { container.handleMultiple(); } currentContainer = container; } } else { currentContainer.processStartChildElement(uri, localName, qName, attributes); // The current container is interested in the content of this element if (currentContainer.getNestedElements().contains(localName)) { buffer = new StringBuilder(); } } }
@Override public void endElement(String uri, String localName, String qName) throws SAXException { if (currentContainer != null) { currentContainer.processEndChildElement(uri, localName, qName, buffer != null ? buffer.toString() : null); // The current container was interested in this element if (currentContainer.getNestedElements().contains(localName)) { buffer = null; } Container container = getContainer(uri, localName); if (container != null) { // We are exiting the container, record it so we know it's already been declared (for error reporting) seenContainers.add(container); // And stop work until we find another container of interest currentContainer = null; } } }
private static Container getContainer(String uri, String localName, Collection<Container> containers) { for (Container container : containers) { if (uri.length() == 0) { if (container.getLocalName().equals(localName)) { return container; } } else { if (container.getLocalName().equals(localName) && container.getUris().contains(uri)) { return container; } } } return null; }