2012-04-13 01:07:55 +00:00
|
|
|
package com.dougkeen.bart.networktasks;
|
2012-01-02 23:08:43 +00:00
|
|
|
|
|
|
|
import org.xml.sax.Attributes;
|
|
|
|
import org.xml.sax.SAXException;
|
|
|
|
import org.xml.sax.helpers.DefaultHandler;
|
|
|
|
|
|
|
|
public class FareContentHandler extends DefaultHandler {
|
|
|
|
public FareContentHandler() {
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
|
|
|
private String currentValue;
|
|
|
|
private boolean isParsingTag;
|
|
|
|
private String fare;
|
|
|
|
|
|
|
|
public String getFare() {
|
|
|
|
return fare;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void characters(char[] ch, int start, int length)
|
|
|
|
throws SAXException {
|
|
|
|
if (isParsingTag) {
|
|
|
|
currentValue = new String(ch, start, length);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void startElement(String uri, String localName, String qName,
|
|
|
|
Attributes attributes) throws SAXException {
|
|
|
|
if (localName.equals("fare")) {
|
|
|
|
isParsingTag = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void endElement(String uri, String localName, String qName)
|
|
|
|
throws SAXException {
|
|
|
|
if (localName.equals("fare")) {
|
|
|
|
fare = "$" + currentValue;
|
|
|
|
}
|
|
|
|
isParsingTag = false;
|
|
|
|
currentValue = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|