public Attribute getAttributeValueByName(final String name) { return this.element.getAttributeValueByName(name); }
public Location getLocation() { return this.element.getLocation(); }
@Override public void startElement(final TreeElement treeElement) { LOG.finest(() -> "Start element: " + treeElement); final Consumer<TreeElement> consumer = this.startElementListeners.getOrDefault( treeElement.getElement().getName().getLocalPart(), this.defaultStartElementListener); if (consumer == null) { LOG.warning(() -> "No consumer for event " + treeElement); return; } try { consumer.accept(treeElement); } catch (final Exception e) { throw new ImporterException("Error handling " + treeElement + " with consumer " + consumer + ": " + e.getMessage(), e); } }
public static StartElementEvent create(final String uri, final String localName, final String qName, final Attributes attributes, final Location location) { final Map<String, Attribute> attributeMap = Attribute.buildMap(attributes); final QName qualifiedName = QNameFactory.create(uri, localName, qName); return new StartElementEvent(qualifiedName, attributeMap, location); }
@Override public void startElement(final String uri, final String localName, final String qName, final Attributes attributes) throws SAXException { LOG.finest(() -> "Start element: uri=" + uri + ", localName=" + localName + ", qName=" + qName); final StartElementEvent event = StartElementEvent.create(uri, localName, qName, attributes, getCurrentLocation()); this.delegate.startElement(event); }
@Override public void startElement(final TreeElement treeElement) { LOG.finest(() -> "Start element: " + treeElement); final Consumer<TreeElement> consumer = this.startElementListeners.getOrDefault( treeElement.getElement().getName().getLocalPart(), this.defaultStartElementListener); if (consumer == null) { LOG.warning(() -> "No consumer for event " + treeElement); return; } try { consumer.accept(treeElement); } catch (final Exception e) { throw new ImporterException("Error handling " + treeElement + " with consumer " + consumer + ": " + e.getMessage(), e); } }
public static StartElementEvent create(final String uri, final String localName, final String qName, final Attributes attributes, final Location location) { final Map<String, Attribute> attributeMap = Attribute.buildMap(attributes); final QName qualifiedName = QNameFactory.create(uri, localName, qName); return new StartElementEvent(qualifiedName, attributeMap, location); }
@Override public void startElement(final String uri, final String localName, final String qName, final Attributes attributes) throws SAXException { LOG.finest(() -> "Start element: uri=" + uri + ", localName=" + localName + ", qName=" + qName); final StartElementEvent event = StartElementEvent.create(uri, localName, qName, attributes, getCurrentLocation()); this.delegate.startElement(event); }
@Override public void endElement(final EndElementEvent event) { if (this.stack.isEmpty()) { throw new IllegalStateException("Got closing event " + event + " but stack is empty"); } final TreeElement topElement = this.stack.peek(); if (!topElement.getElement().getName().equals(event.getName())) { throw new IllegalStateException("Top stack element is " + topElement.getElement() + " but got end event for " + event); } final TreeElement closedElement = this.stack.pop(); this.getDelegate().endElement(closedElement); }
public Location getLocation() { return this.element.getLocation(); }
public Attribute getAttributeValueByName(final String name) { return this.element.getAttributeValueByName(name); }
@Override public void endElement(final EndElementEvent event) { if (this.stack.isEmpty()) { throw new IllegalStateException("Got closing event " + event + " but stack is empty"); } final TreeElement topElement = this.stack.peek(); if (!topElement.getElement().getName().equals(event.getName())) { throw new IllegalStateException("Top stack element is " + topElement.getElement() + " but got end event for " + event); } final TreeElement closedElement = this.stack.pop(); this.getDelegate().endElement(closedElement); }