michael@0: package org.gege.caldavsyncadapter.caldav.xml; michael@0: michael@0: import org.gege.caldavsyncadapter.caldav.xml.sax.MultiStatus; michael@0: import org.gege.caldavsyncadapter.caldav.xml.sax.Prop; michael@0: import org.gege.caldavsyncadapter.caldav.xml.sax.PropStat; michael@0: import org.gege.caldavsyncadapter.caldav.xml.sax.Response; michael@0: import org.xml.sax.Attributes; michael@0: import org.xml.sax.SAXException; michael@0: import org.xml.sax.helpers.DefaultHandler; michael@0: michael@0: michael@0: public class MultiStatusHandler extends DefaultHandler { michael@0: public MultiStatus mMultiStatus; michael@0: private Response mResponse; michael@0: private PropStat mPropStat; michael@0: private Prop mProp; michael@0: private String mCurrentValue; michael@0: michael@0: private String RESPONSE = "response"; michael@0: private String HREF = "href"; michael@0: private String PROPSTAT = "propstat"; michael@0: private String PROP = "prop"; michael@0: private String STATUS = "status"; michael@0: private String CALENDARDATA = "calendar-data"; michael@0: private String GETETAG = "getetag"; michael@0: michael@0: public MultiStatusHandler() { michael@0: mMultiStatus = new MultiStatus(); michael@0: } michael@0: michael@0: @Override michael@0: public void characters(char[] ch, int start, int length) throws SAXException { michael@0: mCurrentValue += new String(ch, start, length); michael@0: } michael@0: michael@0: @Override michael@0: public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException { michael@0: mCurrentValue = ""; michael@0: if (localName.equals(RESPONSE)) { michael@0: mResponse = new Response(); michael@0: mMultiStatus.ResponseList.add(mResponse); michael@0: } else if (localName.equals(PROPSTAT)) { michael@0: mPropStat = new PropStat(); michael@0: mResponse.propstat = mPropStat; michael@0: } else if (localName.equals(PROP)) { michael@0: mProp = new Prop(); michael@0: mPropStat.prop = mProp; michael@0: } michael@0: } michael@0: michael@0: @Override michael@0: public void endElement(String uri, String localName, String qName) throws SAXException { michael@0: if (localName.equals(HREF)) { michael@0: mResponse.href = mCurrentValue; michael@0: } else if (localName.equals(STATUS)) { michael@0: if (mPropStat != null) michael@0: mPropStat.status = mCurrentValue; michael@0: } else if (localName.equals(CALENDARDATA)) { michael@0: mProp.calendardata = mCurrentValue; michael@0: } else if (localName.equals(GETETAG)) { michael@0: mProp.getetag = mCurrentValue; michael@0: } michael@0: } michael@0: }