X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=src%2Ftim%2Fprune%2Ffunction%2Fgpsies%2FGpsiesXmlHandler.java;fp=src%2Ftim%2Fprune%2Ffunction%2Fgpsies%2FGpsiesXmlHandler.java;h=0000000000000000000000000000000000000000;hp=c549c59c1a7a59d2f57a05e46067af0e1af6d19d;hb=8b20e3e027058cdf6ff52993ee5576193d08667a;hpb=2302358503c38817e19f6e529f6c9e530aac0e86 diff --git a/src/tim/prune/function/gpsies/GpsiesXmlHandler.java b/src/tim/prune/function/gpsies/GpsiesXmlHandler.java deleted file mode 100644 index c549c59..0000000 --- a/src/tim/prune/function/gpsies/GpsiesXmlHandler.java +++ /dev/null @@ -1,85 +0,0 @@ -package tim.prune.function.gpsies; - -import java.util.ArrayList; - -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; - -import tim.prune.function.search.SearchResult; - -/** - * XML handler for dealing with XML returned from gpsies.com - */ -public class GpsiesXmlHandler extends DefaultHandler -{ - private String _value = null; - private ArrayList _trackList = null; - private SearchResult _track = null; - - - /** - * React to the start of an XML tag - */ - public void startElement(String inUri, String inLocalName, String inTagName, - Attributes inAttributes) throws SAXException - { - if (inTagName.equals("tracks")) { - _trackList = new ArrayList(); - } - else if (inTagName.equals("track")) { - _track = new SearchResult(); - } - _value = null; - super.startElement(inUri, inLocalName, inTagName, inAttributes); - } - - /** - * React to the end of an XML tag - */ - public void endElement(String inUri, String inLocalName, String inTagName) - throws SAXException - { - if (inTagName.equals("track")) { - _trackList.add(_track); - } - else if (inTagName.equals("title")) { - _track.setTrackName(_value); - } - else if (inTagName.equals("description")) { - _track.setDescription(_value); - } - else if (inTagName.equals("fileId")) { - _track.setWebUrl("https://gpsies.com/map.do?fileId=" + _value); - } - else if (inTagName.equals("trackLengthM")) { - try { - _track.setLength(Double.parseDouble(_value)); - } - catch (NumberFormatException nfe) {} - } - else if (inTagName.equals("downloadLink")) { - _track.setDownloadLink(_value); - } - super.endElement(inUri, inLocalName, inTagName); - } - - /** - * React to characters received inside tags - */ - public void characters(char[] inCh, int inStart, int inLength) - throws SAXException - { - String value = new String(inCh, inStart, inLength); - _value = (_value==null?value:_value+value); - super.characters(inCh, inStart, inLength); - } - - /** - * @return the list of tracks - */ - public ArrayList getTrackList() - { - return _trackList; - } -}