|
|||||||||
| 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 ContentHandlerstartElement in class DefaultHandleruri - 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 relationships
private 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 parsed
public void endElement(String uri,
String localName,
String qName)
throws SAXException
endElement in interface ContentHandlerendElement in class DefaultHandleruri - 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 type
public void characters(char[] ch,
int start,
int length)
characters in interface ContentHandlercharacters in class DefaultHandlerch - character bufferstart - data startlength - number of characters to processpublic void setDocumentLocator(Locator locator)
setDocumentLocator in interface ContentHandlersetDocumentLocator in class DefaultHandlerlocator - a document locator
public void error(SAXParseException e)
throws SAXException
error in interface ErrorHandlererror in class DefaultHandlere - parsing exception to handle
SAXException - always
public void fatalError(SAXParseException e)
throws SAXException
fatalError in interface ErrorHandlerfatalError in class DefaultHandlere - parsing exception to handle
SAXException - alwayspublic void warning(SAXParseException e)
warning in interface ErrorHandlerwarning in class DefaultHandlere - parsing exception to handle
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||