us.zuercher.gpx2map.data
Class GpxParser

java.lang.Object
  extended by us.zuercher.gpx2map.data.GpxParser

public class GpxParser
extends Object

GpxParser parses GPX files and provides accessors for the tracks, way-points, and routes contained in them.

Author:
Stephan Zuercher

Field Summary
private  GpxContentHandler contentHandler
          Content handler used to perform the parsing.
private  List<Throwable> errors
          Errors encountered durig parsing.
private  File gpxFile
          GPX file location.
private  URL gpxUrl
          GPX URL.
 
Constructor Summary
GpxParser()
          Constructs a new GpxParser with no file or URL.
GpxParser(File gpxFile)
          Constructs a new GpxParser for the given file.
GpxParser(URL gpxUrl)
          Constructs a new GpxParser for the given URL.
 
Method Summary
 List<Throwable> getErrors()
          Returns the GPX parsing error list.
 List<Route> getRoutes()
          Returns the list of routes from the GPX data.
 List<Track> getTracks()
          Returns the list of tracks from the GPX data.
 List<WayPoint> getWayPoints()
          Returns the list of way-points from the GPX data.
 boolean parse()
          Parses the configured GPX file.
 void setGpxFile(File gpxFile)
          Change the parsing target to the given file.
 void setGpxUrl(URL gpxUrl)
          Change the parsing target to the given URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

gpxFile

private File gpxFile
GPX file location.


gpxUrl

private URL gpxUrl
GPX URL.


errors

private List<Throwable> errors
Errors encountered durig parsing.


contentHandler

private GpxContentHandler contentHandler
Content handler used to perform the parsing.

Constructor Detail

GpxParser

public GpxParser()
Constructs a new GpxParser with no file or URL.


GpxParser

public GpxParser(File gpxFile)
Constructs a new GpxParser for the given file.

Parameters:
gpxFile - GPX file location.

GpxParser

public GpxParser(URL gpxUrl)
Constructs a new GpxParser for the given URL.

Parameters:
gpxUrl - GPX URL.
Method Detail

setGpxFile

public void setGpxFile(File gpxFile)
Change the parsing target to the given file. Overrides any information that may have been passed to the constructor.

Parameters:
gpxFile - GPX file location.

setGpxUrl

public void setGpxUrl(URL gpxUrl)
Change the parsing target to the given URL. Overrides any information that may have been passed to the constructor.

Parameters:
gpxUrl - GPX URL.

parse

public boolean parse()
Parses the configured GPX file. On parsing errors, see getErrors() for a list of errors. On parsing success, see getTracks(), getWayPoints(), and getRoutes() for GPX data.

Returns:
true if the file is successfully parsed, false if there are parsing errors.
Throws:
NullPointerException - if the GPX file or URL is not set.

getErrors

public List<Throwable> getErrors()
Returns the GPX parsing error list.

Returns:
the GPX parsing error list.

getTracks

public List<Track> getTracks()
Returns the list of tracks from the GPX data.

Returns:
the list of tracks from the GPX data.

getWayPoints

public List<WayPoint> getWayPoints()
Returns the list of way-points from the GPX data.

Returns:
the list of way-points from the GPX data.

getRoutes

public List<Route> getRoutes()
Returns the list of routes from the GPX data.

Returns:
the list of routes from the GPX data.