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); }
public static EndElementEvent create(final String uri, final String localName, final String qName, final Location location) { final QName qualifiedName = QNameFactory.create(uri, localName, qName); return new EndElementEvent(qualifiedName, location); }
public Location getLocation() { return this.element.getLocation(); }
public static Map<String, Attribute> buildMap(final Attributes attr) { final Map<String, Attribute> attributes = new HashMap<>(); for (int i = 0; i < attr.getLength(); i++) { final Attribute attribute = new Attribute(attr.getQName(i), attr.getValue(i)); attributes.put(attribute.getQname(), attribute); } return attributes; }
@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 Attribute getAttributeValueByName(final String name) { return this.element.getAttributeValueByName(name); }
@Override public void endElement(final String uri, final String localName, final String qName) throws SAXException { LOG.finest( () -> "End element: uri=" + uri + ", localName=" + localName + ", qName=" + qName); final EndElementEvent event = EndElementEvent.create(uri, localName, qName, getCurrentLocation()); this.delegate.endElement(event); }
@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); } }
final String defaultDoctype = doctypeAttribute.getValue(); this.handler.pushDelegate( new SpecObjectsHandlerBuilder(this.file, defaultDoctype, this.listener)
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); }
public static EndElementEvent create(final String uri, final String localName, final String qName, final Location location) { final QName qualifiedName = QNameFactory.create(uri, localName, qName); return new EndElementEvent(qualifiedName, location); }
public static Map<String, Attribute> buildMap(final Attributes attr) { final Map<String, Attribute> attributes = new HashMap<>(); for (int i = 0; i < attr.getLength(); i++) { final Attribute attribute = new Attribute(attr.getQName(i), attr.getValue(i)); attributes.put(attribute.getQname(), attribute); } return attributes; }
@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 String uri, final String localName, final String qName) throws SAXException { LOG.finest( () -> "End element: uri=" + uri + ", localName=" + localName + ", qName=" + qName); final EndElementEvent event = EndElementEvent.create(uri, localName, qName, getCurrentLocation()); this.delegate.endElement(event); }
@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); } }
final String defaultDoctype = doctypeAttribute.getValue(); this.handler.pushDelegate( new SpecObjectsHandlerBuilder(this.file, defaultDoctype, this.listener)