- WeatherActivity.zip
- vatsag.samples.weatherdisplay.WeatherActivity
- .classpath
- .project
- .settings
- AndroidManifest.xml
- assets
- bin
- AndroidManifest.xml
- classes.dex
- classes
- vatsag
- samples
- weatherdisplay
- BinderData$ViewHolder.class
- BinderData.class
- BuildConfig.class
- R$attr.class
- R$drawable.class
- R$id.class
- R$layout.class
- R$menu.class
- R$string.class
- R$style.class
- R.class
- SampleActivity.class
- WeatherActivity$1.class
- WeatherActivity.class
- jarlist.cache
- res
- drawable-hdpi
- ic_action_search.png
- ic_launcher.png
- drawable-ldpi
- ic_launcher.png
- drawable-mdpi
- ic_action_search.png
- ic_launcher.png
- drawable-xhdpi
- arrow.png
- cloudy.png
- dcloudy.png
- drainy.png
- dsnowing.png
- dsunny.png
- dthunder.png
- ic_action_search.png
- ic_launcher.png
- pcloudy.png
- rainy.png
- snowing.png
- sunny.png
- thunder.png
- resources.ap_
- vatsag.samples.weatherdisplay.WeatherActivity.apk
- gen
- vatsag
- samples
- weatherdisplay
- ic_launcher-web.png
- libs
- android-support-v4.jar
- proguard-project.txt
- project.properties
- res
- drawable-hdpi
- ic_action_search.png
- ic_launcher.png
- drawable-ldpi
- ic_launcher.png
- drawable-mdpi
- ic_action_search.png
- ic_launcher.png
- drawable-xhdpi
- layout
- menu
- values
- values-v11
- values-v14
- src
- vatsag
- samples
- weatherdisplay
|
package vatsag.samples.weatherdisplay;
import java.util.ArrayList;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
/*
* Default Notification handler class for receiving ContentHandler
* events raised by the SAX Parser
*
* */
public class XParser extends DefaultHandler {
ArrayList<String> idlist = new ArrayList<String>();
ArrayList<String> citylist = new ArrayList<String>();
ArrayList<String> condilist = new ArrayList<String>();
ArrayList<String> templist = new ArrayList<String>();
ArrayList<String> speedlist = new ArrayList<String>();
ArrayList<String> iconlist = new ArrayList<String>();
//temp variable to store the data chunk read while parsing
private String tempStore = null;
public XParser() {
// TODO Auto-generated constructor stub
}
/*
* Clears the tempStore variable on every start of the element
* notification
*
* */
public void startElement (String uri, String localName, String qName,
Attributes attributes) throws SAXException {
super.startElement(uri, localName, qName, attributes);
if (localName.equalsIgnoreCase("id")) {
tempStore = "";
} else if (localName.equalsIgnoreCase("city")) {
tempStore = "";
}
else if (localName.equalsIgnoreCase("tempc")) {
tempStore = "";
}
else if (localName.equalsIgnoreCase("condition")) {
tempStore = "";
}
else if (localName.equalsIgnoreCase("windspeed")) {
tempStore = "";
}
else if (localName.equalsIgnoreCase("icon")) {
tempStore = "";
}
else {
tempStore = "";
}
}
/*
* updates the value of the tempStore variable into
* corresponding list on receiving end of the element
* notification
* */
public void endElement(String uri, String localName, String qName)
throws SAXException {
super.endElement(uri, localName, qName);
if (localName.equalsIgnoreCase("id")) {
idlist.add(tempStore);
}
else if (localName.equalsIgnoreCase("city")) {
citylist.add(tempStore);
}
else if (localName.equalsIgnoreCase("tempc")) {
templist.add(tempStore);
}
else if (localName.equalsIgnoreCase("condition")) {
condilist.add(tempStore);
}
else if (localName.equalsIgnoreCase("windspeed")) {
speedlist.add(tempStore);
}
else if (localName.equalsIgnoreCase("icon")) {
iconlist.add(tempStore);
}
tempStore = "";
}
/*
* adds the incoming data chunk of character data to the
* temp data variable - tempStore
*
* */
public void characters(char[] ch, int start, int length)
throws SAXException {
super.characters(ch, start, length);
tempStore += new String(ch, start, length);
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Software Developer, Cinephile, Dromomaniac, Animal lover, Self proclaimed Photographer not necessarily in the same order.