src/main/java/de/blau/android/osm/Changeset.java
/**
     * Create a new Changeset from an InputStream in XML format
     * 
     * @param parser an XmlPullParser instance
     * @param is the InputStream
     * @return a Changeset
     * @throws XmlPullParserException if parsing fails
     * @throws IOException if an IO operation fails
     */
Create a new Changeset from an InputStream in XML format


Create a new Changeset from an InputStream in XML format
@NonNull
    static Changeset parse(@NonNull XmlPullParser parser, @NonNull InputStream is) throws XmlPullParserException, IOException {
        parser.setInput(is, null);
        int eventType;
        Changeset result = new Changeset();
        while ((eventType = parser.next()) != XmlPullParser.END_DOCUMENT) {
            String tagName = parser.getName();
            if (eventType == XmlPullParser.START_TAG) {
                switch (tagName) {
                case OsmXml.CHANGESET:
                    result.open = TRUE.equals(parser.getAttributeValue(null, OPEN_ATTR));
                    try {
                        result.osmId = Long.parseLong(parser.getAttributeValue(null, "id"));
                    } catch (NumberFormatException nex) {
                        throw new XmlPullParserException(nex.getMessage());
                    }
                    break;
                case OsmElement.TAG:
                    String k = parser.getAttributeValue(null, OsmElement.TAG_KEY_ATTR);
                    String v = parser.getAttributeValue(null, OsmElement.TAG_VALUE_ATTR);
                    result.tags.put(k, v);
                    break;
                default:
                }
                Log.d(DEBUG_TAG, "#" + result.osmId + " is " + (result.open ? "open" : "closed"));
            }
        }
        return result;
    }
@ NonNull static Changeset parse ( @ NonNull XmlPullParser parser , @ NonNull InputStream is ) throws XmlPullParserException , IOException { parser . setInput ( is , null ) ; int eventType ; Changeset result = new Changeset ( ) ; while ( ( eventType = parser . next ( ) ) != XmlPullParser . END_DOCUMENT ) { String tagName = parser . getName ( ) ; if ( eventType == XmlPullParser . START_TAG ) { switch ( tagName ) { case OsmXml . CHANGESET : result . open = TRUE . equals ( parser . getAttributeValue ( null , OPEN_ATTR ) ) ; try { result . osmId = Long . parseLong ( parser . getAttributeValue ( null , "id" ) ) ; } catch ( NumberFormatException nex ) { throw new XmlPullParserException ( nex . getMessage ( ) ) ; } break ; case OsmElement . TAG : String k = parser . getAttributeValue ( null , OsmElement . TAG_KEY_ATTR ) ; String v = parser . getAttributeValue ( null , OsmElement . TAG_VALUE_ATTR ) ; result . tags . put ( k , v ) ; break ; default : } Log . d ( DEBUG_TAG , "#" + result . osmId + " is " + ( result . open ? "open" : "closed" ) ) ; } } return result ; }
Create a new Changeset from an InputStream in XML format
Create a new Changeset from an InputStream in XML format
// nothing