Package org.h2gis.functions.io.gpx.model
Class GpxPreparser
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- org.h2gis.functions.io.gpx.model.GpxPreparser
-
- All Implemented Interfaces:
ContentHandler,DTDHandler,EntityResolver,ErrorHandler
public final class GpxPreparser extends DefaultHandler
GpxPreparser class just reads the document. It says what type of elements (waypoints, routes ,routepoints, tracks, track segments, trackpoints) the document contains. It also counts each type of elements.- Author:
- Antonin Piasco, Erwan Bocher
-
-
Constructor Summary
Constructors Constructor Description GpxPreparser()Initializing of the pre-parser.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetTotalRte()Gives the total number of routes contained in the GPX file.intgetTotalRtept()Gives the total number of routepoints contained in the GPX file.intgetTotalTrk()Gives the total number of tracks contained in the GPX file.intgetTotalTrkpt()Gives the total number of trackpoints contained in the GPX file.intgetTotalTrkseg()Gives the total number of track segments contained in the GPX file.intgetTotalWpt()Gives the total number of waypoints contained in the GPX file.StringgetVersion()Gives the version of the gpx file.booleanread(File inputFile, String encoding)Reads the document and pre-parses it.voidstartElement(String uri, String localName, String qName, Attributes attributes)Fires whenever an XML start markup is encountered.-
Methods inherited from class org.xml.sax.helpers.DefaultHandler
characters, endDocument, endElement, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
-
-
-
-
Method Detail
-
read
public boolean read(File inputFile, String encoding) throws SAXException, IOException
Reads the document and pre-parses it. The other method is called automatically when a start markup is found.- Parameters:
inputFile- the file to read- Returns:
- a boolean if the parser ends successfully or not
- Throws:
SAXExceptionIOException
-
startElement
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
Fires whenever an XML start markup is encountered. It indicates which version of gpx file is to be parsed. It counts the waypoints, routes, routepoints, tracks, track segments and trackpoints.- Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler- Parameters:
uri- URI of the local elementlocalName- Name of the local element (without prefix)qName- qName of the local element (with prefix)attributes- Attributes of the local element (contained in the markup)- Throws:
SAXException- Any SAX exception, possibly wrapping another exception
-
getVersion
public String getVersion()
Gives the version of the gpx file.- Returns:
-
getTotalWpt
public int getTotalWpt()
Gives the total number of waypoints contained in the GPX file.- Returns:
- the total number of waypoints
-
getTotalRte
public int getTotalRte()
Gives the total number of routes contained in the GPX file.- Returns:
- the total number of routes
-
getTotalRtept
public int getTotalRtept()
Gives the total number of routepoints contained in the GPX file.- Returns:
- the total number of routepoints
-
getTotalTrk
public int getTotalTrk()
Gives the total number of tracks contained in the GPX file.- Returns:
- the total number of tracks
-
getTotalTrkseg
public int getTotalTrkseg()
Gives the total number of track segments contained in the GPX file.- Returns:
- the total number of track segments
-
getTotalTrkpt
public int getTotalTrkpt()
Gives the total number of trackpoints contained in the GPX file.- Returns:
- the total number of trackpoints
-
-