Java Reference
In-Depth Information
public Location getLocation() {
return location;
}
public void startDocument() {
if (location == null)
location = new Location();
setForecast = false;
hasForecast = false;
setTemp = false;
}
public void startElement(String uri, String localName,
String qName, Attributes attributes)
throws SAXException {
buffer = new StringBuffer();
if (qName.equals(Location.XML_TAG_WEATHER) == 0) {
String c = attributes.getValue(Location.XML_ATTR_CITY);
String s = attributes.getValue(Location.XML_ATTR_STATE);
String co = attributes.getValue(Location.XML_ATTR_COUNTRY);
location.setLocation(c,s,co);
hasForecast = false;
}
if (qName.equals(Location.XML_TAG_TEMPS) == 0) {
String u = attributes.getValue(Location.XML_ATTR_UNITS);
if (u != null && u.equals("F") != 0)
throw new SAXException("Invalid temperature units");
hasForecast = false;
}
if (qName.equals(Location.XML_TAG_TEMP) == 0) {
String t = attributes.getValue(Location.XML_ATTR_TYPE);
if (t != null && t.equals("current") != 0)
setTemp = true;
else
setTemp = false;
hasForecast = false;
}
if (qName.equals(Location.XML_TAG_WIND) == 0) {
String u = attributes.getValue(Location.XML_ATTR_UNITS);
if (u != null && u.equals("MPH") != 0)
throw new SAXException("Invalid temperature units");
hasForecast = false;
}
 
Search WWH ::




Custom Search