Package org.h2gis.functions.io.gpx.model
Class AbstractGpxParserDefault
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- org.h2gis.functions.io.gpx.model.AbstractGpxParser
-
- org.h2gis.functions.io.gpx.model.AbstractGpxParserDefault
-
- All Implemented Interfaces:
ContentHandler,DTDHandler,EntityResolver,ErrorHandler
- Direct Known Subclasses:
GpxParser
public abstract class AbstractGpxParserDefault extends AbstractGpxParser
Main class to parse the GPX file- Author:
- Erwan Bocher
-
-
Field Summary
Fields Modifier and Type Field Description static intSTRINGSTACK_SIZE
-
Constructor Summary
Constructors Constructor Description AbstractGpxParserDefault(Connection connection, File fileName, String encoding, boolean deleteTable)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Initialisation of all the indicators used to read the document.voidendElement(String uri, String localName, String qName)Fires whenever an XML end markup is encountered.StringgetCreator()Gives the name or URL of the software that created the GPX document.StringgetDesc()Gives a description of the contents of the GPX file.StringgetFullAuthor()Gives the name of person or organization who created the GPX file.StringgetFullLink()Gives URLs associated with the location described in the file.StringgetKeywords()Gives keywords associated with the file.doublegetMaxLat()Gives the maximum latitude given by<bounds>element.doublegetMaxLon()Gives the maximum longitude given by<bounds>element.doublegetMinLat()Gives the minimum latitude given by<bounds>element.doublegetMinLon()Gives the minimum longitude given by<bounds>element.StringgetName()Gives the name of the document.AbstractGpxParserRtegetRteParser()Gives the parser used to parse routes.StringgetTime()Gives the date when this file is created.AbstractGpxParserTrkgetTrkParser()Givers the parser used to parse the trackStringgetVersion()Gives the version number of the GPX document.AbstractGpxParserWptgetWptParser()Gives the parser used to parse waypoint.String[]read(String tableName, org.h2gis.api.ProgressVisitor progress)Reads the document and parses it.The other methods are called automatically when corresponding markup is found.voidsetAuthorLink(String authorLink)Set the link related to the author of the ducument.voidsetAuthorLinkText(String authorLinkText)Set the description of the link related to the author.voidsetAuthorName(String authorName)Set the name of the author of the document.voidsetEmail(String email)Set the email of the author of the document.voidsetLink(String link)Set the link related to the document.voidsetLinkText(String linkText)Set the description of hte document link.voidsetName(String name)Set the name of the document.voidsetRteParser(AbstractGpxParserRte rteParser)Set the parser used to parse routes.voidsetTrkParser(AbstractGpxParserTrk trkParser)Set the parser used to parse the trackvoidsetWptParser(AbstractGpxParserWpt wptParser)Set the parser used to parse waypoint.voidstartElement(String uri, String localName, String qName, Attributes attributes)Fires whenever an XML start markup is encountered.-
Methods inherited from class org.h2gis.functions.io.gpx.model.AbstractGpxParser
characters, getContentBuffer, getCurrentElement, getCurrentLine, getCurrentPoint, getCurrentSegment, getElementNames, getGeometryFactory, getReader, getRtePreparedStmt, getRteptPreparedStmt, getTrkPointsPreparedStmt, getTrkPreparedStmt, getTrkSegmentsPreparedStmt, getWptPreparedStmt, isSpecificElement, setContentBuffer, setCurrentElement, setCurrentLine, setCurrentPoint, setCurrentSegment, setElementNames, setReader, setRtePreparedStmt, setRteptPreparedStmt, setSpecificElement, setTrkPointsPreparedStmt, setTrkPreparedStmt, setTrkSegmentsPreparedStmt, setWptPreparedStmt
-
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
-
-
-
-
Field Detail
-
STRINGSTACK_SIZE
public static final int STRINGSTACK_SIZE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractGpxParserDefault
public AbstractGpxParserDefault(Connection connection, File fileName, String encoding, boolean deleteTable)
-
-
Method Detail
-
clear
public void clear()
Initialisation of all the indicators used to read the document.
-
read
public String[] read(String tableName, org.h2gis.api.ProgressVisitor progress) throws SQLException, FileNotFoundException
Reads the document and parses it.The other methods are called automatically when corresponding markup is found.- Parameters:
tableName- the table used to create all tablesprogress-- Returns:
- a boolean value if the parser ends successfully or not
- Throws:
SQLException- if the creation of the tables failedFileNotFoundException
-
startElement
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
Fires whenever an XML start markup is encountered. It takes general information about the document. It change the ContentHandler to parse specific informations when<wpt>,<rte>or<trk>markup are found.- 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
-
endElement
public void endElement(String uri, String localName, String qName)
Fires whenever an XML end markup is encountered. It catches attributes of the different elements and saves them in corresponding values[].- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classDefaultHandler- Parameters:
uri- URI of the local elementlocalName- Name of the local element (without prefix)qName- qName of the local element (with prefix)
-
getTime
public String getTime()
Gives the date when this file is created.- Returns:
-
getVersion
public String getVersion()
Gives the version number of the GPX document.- Returns:
-
getCreator
public String getCreator()
Gives the name or URL of the software that created the GPX document.- Returns:
-
getMinLon
public double getMinLon()
Gives the minimum longitude given by<bounds>element.- Returns:
-
getMaxLon
public double getMaxLon()
Gives the maximum longitude given by<bounds>element.- Returns:
-
getMinLat
public double getMinLat()
Gives the minimum latitude given by<bounds>element.- Returns:
-
getMaxLat
public double getMaxLat()
Gives the maximum latitude given by<bounds>element.- Returns:
-
getDesc
public String getDesc()
Gives a description of the contents of the GPX file.- Returns:
-
getKeywords
public String getKeywords()
Gives keywords associated with the file. Search engines or databases can use this information to classify the data.- Returns:
-
getFullLink
public String getFullLink()
Gives URLs associated with the location described in the file.- Returns:
-
getFullAuthor
public String getFullAuthor()
Gives the name of person or organization who created the GPX file. Also gives an email address if exist. Also gives a link to Web site or other external information about person if exist.- Returns:
-
setAuthorLink
public void setAuthorLink(String authorLink)
Set the link related to the author of the ducument.- Parameters:
authorLink-
-
setAuthorLinkText
public void setAuthorLinkText(String authorLinkText)
Set the description of the link related to the author.- Parameters:
authorLinkText-
-
setAuthorName
public void setAuthorName(String authorName)
Set the name of the author of the document.- Parameters:
authorName-
-
setEmail
public void setEmail(String email)
Set the email of the author of the document.- Parameters:
email-
-
setLink
public void setLink(String link)
Set the link related to the document.- Parameters:
link-
-
setLinkText
public void setLinkText(String linkText)
Set the description of hte document link.- Parameters:
linkText-
-
getName
public String getName()
Gives the name of the document.- Returns:
-
setName
public void setName(String name)
Set the name of the document.- Parameters:
name-
-
getWptParser
public AbstractGpxParserWpt getWptParser()
Gives the parser used to parse waypoint.- Returns:
-
setWptParser
public void setWptParser(AbstractGpxParserWpt wptParser)
Set the parser used to parse waypoint.- Parameters:
wptParser-
-
setRteParser
public void setRteParser(AbstractGpxParserRte rteParser)
Set the parser used to parse routes.- Parameters:
rteParser-
-
getRteParser
public AbstractGpxParserRte getRteParser()
Gives the parser used to parse routes.- Returns:
-
setTrkParser
public void setTrkParser(AbstractGpxParserTrk trkParser)
Set the parser used to parse the track- Parameters:
trkParser-
-
getTrkParser
public AbstractGpxParserTrk getTrkParser()
Givers the parser used to parse the track- Returns:
-
-