From 40431d0a3860901d6e2a95203f245096cc6931d5 Mon Sep 17 00:00:00 2001 From: reciprocum Date: Wed, 16 Dec 2015 17:32:48 +0000 Subject: [PATCH 1/2] Update GPXParser.java 1) Doubly redundant nested while( ) 2) addExtensionData( ) should only be called if there is any data to add (data != null) --- src/com/urizev/gpx/GPXParser.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/com/urizev/gpx/GPXParser.java b/src/com/urizev/gpx/GPXParser.java index 6d2ba70..d0fcbfc 100644 --- a/src/com/urizev/gpx/GPXParser.java +++ b/src/com/urizev/gpx/GPXParser.java @@ -514,16 +514,11 @@ private Route parseRoute(Node node) throws Exception { } } else if (GPXConstants.EXTENSIONS_NODE.equals(currentNode .getNodeName())) { - Iterator it = this.extensionParsers - .iterator(); - while (it.hasNext()) { - while (it.hasNext()) { - IExtensionParser parser = it.next(); - Object data = parser - .parseRouteExtension(currentNode); - rte.addExtensionData(parser.getId(), data); - } - } + for ( IExtensionParser extensionParser : extensionParsers ) + { + Object data = extensionParser.parseTrackExtension( currentNode ); + if (data != null) trk.addExtensionData( extensionParser.getId( ), data ); + } } } } From ef5241594addab47cb02f8cf337245b39b1d3bcd Mon Sep 17 00:00:00 2001 From: reciprocum Date: Thu, 17 Dec 2015 02:38:50 +0000 Subject: [PATCH 2/2] Update GPXParser.java --- src/com/urizev/gpx/GPXParser.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/com/urizev/gpx/GPXParser.java b/src/com/urizev/gpx/GPXParser.java index d0fcbfc..7ce6290 100644 --- a/src/com/urizev/gpx/GPXParser.java +++ b/src/com/urizev/gpx/GPXParser.java @@ -516,8 +516,8 @@ private Route parseRoute(Node node) throws Exception { .getNodeName())) { for ( IExtensionParser extensionParser : extensionParsers ) { - Object data = extensionParser.parseTrackExtension( currentNode ); - if (data != null) trk.addExtensionData( extensionParser.getId( ), data ); + Object data = extensionParser.parseRouteExtension( currentNode ); + if (data != null) rte.addExtensionData( extensionParser.getId( ), data ); } } } @@ -563,15 +563,10 @@ private Track parseTrack(Node node) throws Exception { trk.addTrackSegment(segment); } else if (GPXConstants.EXTENSIONS_NODE.equals(currentNode .getNodeName())) { - Iterator it = this.extensionParsers - .iterator(); - while (it.hasNext()) { - while (it.hasNext()) { - IExtensionParser parser = it.next(); - Object data = parser - .parseTrackExtension(currentNode); - trk.addExtensionData(parser.getId(), data); - } + for ( IExtensionParser extensionParser : extensionParsers ) + { + Object data = extensionParser.parseTrackExtension( currentNode ); + if (data != null) trk.addExtensionData( extensionParser.getId( ), data ); } } }