package com.keas.droid.mobileapi.responseparsers;
import java.util.ArrayList;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import android.util.Log;
import com.keas.droid.models.OnlineToDoSummary;
public class ToDoSummaryHandler extends DefaultHandler {
ArrayList<OnlineToDoSummary> onlineToDoSummaries;
OnlineToDoSummary currentOnlineToDoSummary;
String code;
String displayText;
String currentTag;
public ArrayList<OnlineToDoSummary> getOnlineToDoSummaries(){
return onlineToDoSummaries;
}
public void startDocument(){
try {
super.startDocument();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
onlineToDoSummaries = new ArrayList<OnlineToDoSummary>();
}
public void characters(char[] ch, int start, int length) throws SAXException{
super.characters(ch, start, length);
if(currentTag.equalsIgnoreCase("onlineTodoSummary")){
}else if(currentTag.equalsIgnoreCase("dateClosed")){
currentOnlineToDoSummary.setDateClosed(new String(ch, start, length));
}else if(currentTag.equalsIgnoreCase("dateCreated")){
currentOnlineToDoSummary.setDateCreated(new String(ch, start, length));
}else if(currentTag.equalsIgnoreCase("displayName")){
currentOnlineToDoSummary.setDisplayName(new String(ch, start, length));
}else if(currentTag.equalsIgnoreCase("id")){
currentOnlineToDoSummary.setId(new String(ch, start, length));
}else if(currentTag.equalsIgnoreCase("online")){
currentOnlineToDoSummary.setOnline(new String(ch, start, length));
}else if(currentTag.equalsIgnoreCase("open")){
currentOnlineToDoSummary.setOpen(new String(ch, start, length));
}else if(currentTag.equalsIgnoreCase("planId")){
currentOnlineToDoSummary.setPlanId(new String(ch, start, length));
}else if(currentTag.equalsIgnoreCase("points")){
currentOnlineToDoSummary.setPoints(new String(ch, start, length));
}else if(currentTag.equalsIgnoreCase("todoType")){
}else if(currentTag.equalsIgnoreCase("priority")){
}else if(currentTag.equalsIgnoreCase("todoStage")){
}else if(currentTag.equalsIgnoreCase("urgentNow")){
currentOnlineToDoSummary.setUrgentNow(new String(ch, start, length));
}else if(currentTag.equalsIgnoreCase("code")){
code = new String(ch, start, length);
}else if(currentTag.equalsIgnoreCase("displayText")){
displayText = new String(ch, start, length);
}
}
public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException{
super.startElement(uri, localName, name, attributes);
if(localName.equalsIgnoreCase("onlineTodoSummary")){
Log.d("KeasAndroidx", "onlineTodoSummary");
currentOnlineToDoSummary = new OnlineToDoSummary();
}else if(localName.equalsIgnoreCase("dateClosed")){
}else if(localName.equalsIgnoreCase("dateCreated")){
}else if(localName.equalsIgnoreCase("displayName")){
}else if(localName.equalsIgnoreCase("id")){
}else if(localName.equalsIgnoreCase("online")){
}else if(localName.equalsIgnoreCase("open")){
}else if(localName.equalsIgnoreCase("planId")){
}else if(localName.equalsIgnoreCase("points")){
}else if(localName.equalsIgnoreCase("todoType")){
}else if(localName.equalsIgnoreCase("priority")){
}else if(localName.equalsIgnoreCase("todoStage")){
}else if(localName.equalsIgnoreCase("urgentNow")){
}else if(localName.equalsIgnoreCase("code")){
}else if(localName.equalsIgnoreCase("displayText")){
}
currentTag = new String(localName);
}
/* (non-Javadoc)
* @see org.xml.sax.helpers.DefaultHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
*/
@Override
public void endElement(String uri, String localName, String qName)
throws SAXException {
super.endElement(uri, localName, qName);
if(localName.equalsIgnoreCase("onlineTodoSummary")){
Log.d("KeasAndroidx", currentOnlineToDoSummary.toString());
onlineToDoSummaries.add(currentOnlineToDoSummary);
}else if(localName.equalsIgnoreCase("dateClosed")){
}else if(localName.equalsIgnoreCase("dateCreated")){
}else if(localName.equalsIgnoreCase("displayName")){
}else if(localName.equalsIgnoreCase("id")){
}else if(localName.equalsIgnoreCase("online")){
}else if(localName.equalsIgnoreCase("open")){
}else if(localName.equalsIgnoreCase("planId")){
}else if(localName.equalsIgnoreCase("points")){
}else if(localName.equalsIgnoreCase("todoType")){
currentOnlineToDoSummary.setToDoType(code, displayText);
code = null;
displayText = null;
}else if(localName.equalsIgnoreCase("priority")){
currentOnlineToDoSummary.setPriority(code, displayText);
code = null;
displayText = null;
}else if(localName.equalsIgnoreCase("todoStage")){
currentOnlineToDoSummary.setToDoStage(code, displayText);
code = null;
displayText = null;
}else if(localName.equalsIgnoreCase("urgentNow")){
}else if(localName.equalsIgnoreCase("code")){
}else if(localName.equalsIgnoreCase("displayText")){
}
}
}
|