In GpxImporter, support cases when the content is null.

This commit is contained in:
Jimmy Shih
2012-06-26 18:13:41 -07:00
parent 82b83b6e79
commit 663c96e781
@@ -410,6 +410,10 @@ public class GpxImporter extends DefaultHandler {
return; return;
} }
if (content == null) {
return;
}
// Parse the time // Parse the time
long time; long time;
try { try {
@@ -452,7 +456,7 @@ public class GpxImporter extends DefaultHandler {
* On altitude element end. * On altitude element end.
*/ */
private void onAltitudeElementEnd() throws SAXException { private void onAltitudeElementEnd() throws SAXException {
if (location != null) { if (location != null && content != null) {
try { try {
location.setAltitude(Double.parseDouble(content)); location.setAltitude(Double.parseDouble(content));
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
@@ -465,14 +469,18 @@ public class GpxImporter extends DefaultHandler {
* On name element end. * On name element end.
*/ */
private void onNameElementEnd() { private void onNameElementEnd() {
track.setName(content.toString().trim()); if (content != null) {
track.setName(content.toString().trim());
}
} }
/** /**
* On description element end. * On description element end.
*/ */
private void onDescriptionElementEnd() { private void onDescriptionElementEnd() {
track.setDescription(content.toString().trim()); if (content != null) {
track.setDescription(content.toString().trim());
}
} }
/** /**