2012-10-09 20:51:00 +00:00
|
|
|
package com.dougkeen.bart.networktasks;
|
|
|
|
|
|
|
|
import org.xml.sax.Attributes;
|
|
|
|
import org.xml.sax.SAXException;
|
|
|
|
import org.xml.sax.helpers.DefaultHandler;
|
|
|
|
|
2016-10-28 14:05:40 +00:00
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Map;
|
|
|
|
|
2012-10-09 20:51:00 +00:00
|
|
|
public class FareContentHandler extends DefaultHandler {
|
2015-08-12 01:56:23 +00:00
|
|
|
public FareContentHandler() {
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
|
|
|
private String fare;
|
|
|
|
|
|
|
|
public String getFare() {
|
|
|
|
return fare;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void startElement(String uri, String localName, String qName,
|
|
|
|
Attributes attributes) throws SAXException {
|
|
|
|
if (localName.equals("fare")) {
|
2016-10-28 14:05:40 +00:00
|
|
|
Map<String, String> attributeMap = new HashMap<>();
|
|
|
|
for (int i = attributes.getLength() - 1; i >= 0; i--) {
|
|
|
|
attributeMap.put(attributes.getLocalName(i), attributes.getValue(i));
|
|
|
|
}
|
|
|
|
if (attributeMap.containsKey("class") && attributeMap.get("class").equals("cash")) {
|
|
|
|
fare = "$" + attributeMap.get("amount");
|
|
|
|
}
|
2015-08-12 01:56:23 +00:00
|
|
|
}
|
|
|
|
}
|
2012-10-09 20:51:00 +00:00
|
|
|
}
|