Search in sources :

Example 1 with ChangeType

use of com.baremaps.osm.domain.Change.ChangeType in project baremaps by baremaps.

the class OsmChangeSpliterator method readChange.

private Change readChange() throws XMLStreamException {
    switch(reader.getLocalName()) {
        case ELEMENT_NAME_CREATE:
        case ELEMENT_NAME_DELETE:
        case ELEMENT_NAME_MODIFY:
            ChangeType type = ChangeType.valueOf(reader.getLocalName().toUpperCase());
            List<Entity> elements = new ArrayList<>();
            reader.nextTag();
            while (reader.getEventType() == XMLStreamConstants.START_ELEMENT) {
                elements.add(readElement());
                reader.nextTag();
            }
            return new Change(type, elements);
        default:
            throw new StreamException("Unexpected XML element: " + reader.getLocalName());
    }
}
Also used : Entity(com.baremaps.osm.domain.Entity) ChangeType(com.baremaps.osm.domain.Change.ChangeType) ArrayList(java.util.ArrayList) Change(com.baremaps.osm.domain.Change) XMLStreamException(javax.xml.stream.XMLStreamException) StreamException(com.baremaps.stream.StreamException)

Aggregations

Change (com.baremaps.osm.domain.Change)1 ChangeType (com.baremaps.osm.domain.Change.ChangeType)1 Entity (com.baremaps.osm.domain.Entity)1 StreamException (com.baremaps.stream.StreamException)1 ArrayList (java.util.ArrayList)1 XMLStreamException (javax.xml.stream.XMLStreamException)1