|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.xml.sax.helpers.DefaultHandler
us.zuercher.gpx2map.data.GpxContentHandler
public class GpxContentHandler
GpxContentHandler is a ContentHandler
that understands the GPX XSD,
version 1.1 and earlier. It endeavors to ignore all portions of the GPX
file that it is not capable of processing and makes as few assumptions as
possible about the structure of the GPX file.
Field Summary | |
---|---|
private StringBuffer |
characters
Characters seen since the last call to startElement(String, String, String, Attributes) . |
private Route |
currentRoute
The route currently being read. |
private RoutePoint |
currentRoutePoint
The route point currently being read. |
private Track |
currentTrack
The track currently being read. |
private TrackPoint |
currentTrackPoint
The track point currently being read. |
private TrackSegment |
currentTrackSegment
The track segment currently being read. |
private WayPoint |
currentWayPoint
The way point currently being read. |
private static SimpleDateFormat |
dateFormatter
Date formatter. |
private List<Throwable> |
errors
List of errors encountered durig processing. |
static String |
GPX_DATE_FORMAT
Date format string. |
private Locator |
locator
Current location in the file. |
private List<Route> |
routes
Routes found in the file. |
private List<Track> |
tracks
Tracks found in the file. |
private List<WayPoint> |
wayPoints
WayPoints found in the file. |
Constructor Summary | |
---|---|
GpxContentHandler(List<Throwable> errors)
Constructs a new GpxContentHandler that stores errors in the given list. |
Method Summary | |
---|---|
void |
characters(char[] ch,
int start,
int length)
Character data event. |
void |
endElement(String uri,
String localName,
String qName)
Handle element end event. |
void |
error(SAXParseException e)
Override error processing. |
void |
fatalError(SAXParseException e)
Override error processing. |
private LatLon |
getLocation(String type,
Attributes attributes)
Convert element attributes into a LatLon. |
(package private) List<Route> |
getRoutes()
Return the loaded routes. |
(package private) List<Track> |
getTracks()
Return the loaded tracks. |
(package private) List<WayPoint> |
getWayPoints()
Return the loaded way-points. |
void |
setDocumentLocator(Locator locator)
Mutator to configure the document locator object. |
private void |
setProperty(AbstractGpxEntity entity,
String name,
String value)
Set the given property on the given entity. |
void |
startElement(String uri,
String localName,
String qName,
Attributes attributes)
Handle element start. |
void |
warning(SAXParseException e)
Override warning processing. |
Methods inherited from class org.xml.sax.helpers.DefaultHandler |
---|
endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.xml.sax.ContentHandler |
---|
endDocument, endPrefixMapping, ignorableWhitespace, processingInstruction, skippedEntity, startDocument, startPrefixMapping |
Field Detail |
---|
public static final String GPX_DATE_FORMAT
private static final SimpleDateFormat dateFormatter
private StringBuffer characters
startElement(String, String, String, Attributes)
.
private Locator locator
private List<Track> tracks
private Track currentTrack
private TrackSegment currentTrackSegment
private TrackPoint currentTrackPoint
private List<WayPoint> wayPoints
private WayPoint currentWayPoint
private List<Route> routes
private Route currentRoute
private RoutePoint currentRoutePoint
private List<Throwable> errors
Constructor Detail |
---|
GpxContentHandler(List<Throwable> errors)
errors
- modifiable list where parsing errors will be stored.Method Detail |
---|
List<Track> getTracks()
List<WayPoint> getWayPoints()
List<Route> getRoutes()
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
startElement
in interface ContentHandler
startElement
in class DefaultHandler
uri
- namespace URIlocalName
- element's local nameqName
- element's qualified nameattributes
- element attributes
SAXException
- if there's a parsing error related to ordering
or elements or element parent-child relationshipsprivate LatLon getLocation(String type, Attributes attributes) throws SAXParseException
type
- element type, used for exceptionsattributes
- the element attributes to search for "lat" and "lon"
SAXParseException
- if the attributes cannot be found or parsedpublic void endElement(String uri, String localName, String qName) throws SAXException
endElement
in interface ContentHandler
endElement
in class DefaultHandler
uri
- element namespace urilocalName
- element's local nameqName
- element's qualified name
SAXException
- if there's an error converting element character
data (see characters
) into a non-String
property value.private void setProperty(AbstractGpxEntity entity, String name, String value) throws SAXParseException
entity
- entity to set the property onname
- property namevalue
- property value
SAXParseException
- if the value cannot be converted to the
required typepublic void characters(char[] ch, int start, int length)
characters
in interface ContentHandler
characters
in class DefaultHandler
ch
- character bufferstart
- data startlength
- number of characters to processpublic void setDocumentLocator(Locator locator)
setDocumentLocator
in interface ContentHandler
setDocumentLocator
in class DefaultHandler
locator
- a document locatorpublic void error(SAXParseException e) throws SAXException
error
in interface ErrorHandler
error
in class DefaultHandler
e
- parsing exception to handle
SAXException
- alwayspublic void fatalError(SAXParseException e) throws SAXException
fatalError
in interface ErrorHandler
fatalError
in class DefaultHandler
e
- parsing exception to handle
SAXException
- alwayspublic void warning(SAXParseException e)
warning
in interface ErrorHandler
warning
in class DefaultHandler
e
- parsing exception to handle
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |