diff --git a/android/AkvoRSR/AndroidManifest.xml b/android/AkvoRSR/AndroidManifest.xml index 7256ec00..d710dcf2 100644 --- a/android/AkvoRSR/AndroidManifest.xml +++ b/android/AkvoRSR/AndroidManifest.xml @@ -1,8 +1,8 @@ . - */ - -package org.akvo.rsr.up.xml; - -import org.akvo.rsr.up.dao.RsrDbAdapter; -import org.akvo.rsr.up.domain.Project; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; - -/* - * Example input: - * - - 0 - This is a project created for donation tests - - - /api/v1/invoice/1609/ - - - - - EUR - 1347 - DonationTestProject1364643561.13 - - - /api/v1/category/9/ - - H - 6992.52 - This is a project created for donation tests - 2013-03-30 - This is a project created for donation tests - - - - - http://test.akvo.org/rsr/media/db/project/141/Project_141_current_image_2011-04-06_10.40.13.jpg - - http://test.akvo.org/rsr/media/db/project/141/Project_141_current_image_2011-04-06_10.40.13_jpg_160x120_autocrop_detail_q85.jpg - - ..or.. - - - - - /api/v1/budget_item/3480/ - /rsr/project/1347/7.487000.00/api/v1/benchmark/14743//api/v1/benchmark/14744/This is a project created for donation tests/api/v1/project/1347/ - - /api/v1/partnership/4591/0This is a project created for donation tests/api/v1/invoice/1607/EUR1346DonationTestProject1364471063.03/api/v1/category/9/H6992.52This is a project created for donation tests2013-03-28This is a project created for donation tests/api/v1/budget_item/3479//rsr/project/1346/7.487000.00/api/v1/benchmark/14741//api/v1/benchmark/14742/This is a project created for donation tests/api/v1/project/1346//api/v1/partnership/4590/0This is a project created for donation testsEUR1345DonationTestProject1364470674.77/api/v1/category/9/H0.00This is a project created for donation tests2013-03-28This is a project created for donation tests/api/v1/budget_item/3478//rsr/project/1345/1000000.001000000.00/api/v1/benchmark/14739//api/v1/benchmark/14740/This is a project created for donation tests/api/v1/project/1345//api/v1/partnership/4589/0This is a project created for donation tests/api/v1/invoice/1608/EUR1344DonationTestProject1364470500.91/api/v1/category/9/H0.00This is a project created for donation tests2013-03-28This is a project created for donation tests/api/v1/budget_item/3477//rsr/project/1344/1000000.001000000.00/api/v1/benchmark/14737//api/v1/benchmark/14738/This is a project created for donation tests/api/v1/project/1344//api/v1/partnership/4588/ - - Example of location: - - - Nairobi - /api/v1/country/27/ - True - 36.819185 - /api/v1/project/1350/ - PO Box 36655-0200 - Suite 425 Parklands Road, Westlands - -1.267924 - 2069/api/v1/project_location/2069/ - - - */ - - - -public class ProjectListHandler extends DefaultHandler { - - - // =========================================================== - // Fields - // =========================================================== - - private boolean in_project = false; - private boolean in_id = false; - private boolean in_title = false; - private boolean in_subtitle = false; - private boolean in_summary = false; - private boolean in_funds = false; - - private boolean in_current_image = false; - private boolean in_thumbnails = false; - private boolean in_thumbnail_url = false; - - private boolean in_location = false; - private boolean in_country = false; - private boolean in_state = false; - private boolean in_city = false; - private boolean in_long = false; - private boolean in_lat = false; - - private Project currentProj; - - private int depth = 0; - private int projectCount = 0; - private boolean syntaxError = false; - private String buffer; //used to accumulate a tag ocntent - - //where to store results - private RsrDbAdapter dba; - -// private ParsedExampleDataSet myParsedExampleDataSet = new ParsedExampleDataSet(); - - - /* - * constructor - */ - public ProjectListHandler(RsrDbAdapter aDba){ - super(); - dba = aDba; - } - // =========================================================== - // Getter & Setter - // =========================================================== - - public boolean getError() { - return syntaxError; - } - - public int getCount() { - return projectCount; - } - - // =========================================================== - // Methods - // =========================================================== - @Override - public void startDocument() throws SAXException { - dba.open(); - depth = 0; - projectCount = 0; - } - - @Override - public void endDocument() throws SAXException { - dba.close(); - } - - /** Gets be called on opening tags like: - * - * Can provide attribute(s), when xml was like: - * */ - @Override - public void startElement(String namespaceURI, String localName, - String qName, Attributes atts) throws SAXException { - buffer = ""; - if (localName.equals("object") && depth == 2) { //ignore root tag completely - this.in_project = true; - currentProj = new Project(); - } else if (in_project) - if (localName.equals("id") && depth == 3) { - this.in_id = true; - } else if (localName.equals("title") && depth == 3) { - this.in_title = true; - } else if (localName.equals("subtitle") && depth == 3) { - this.in_subtitle = true; - } else if (localName.equals("funds")) { - this.in_funds = true; - } else if (localName.equals("primary_location")) { - this.in_location = true; - /* - } else if (localName.equals("tagwithnumber")) { - // Extract an Attribute - String attrValue = atts.getValue("thenumber"); - int i = Integer.parseInt(attrValue); - myParsedExampleDataSet.setExtractedInt(i); - */ - } else if (localName.equals("project_plan_summary") && depth==3) { - this.in_summary = true; - } else if (localName.equals("current_image") && depth==3) { - this.in_current_image = true; - } else if (localName.equals("country") && in_location) { - this.in_country = true; - } else if (localName.equals("state") && in_location) { - this.in_state = true; - } else if (localName.equals("city") && in_location) { - this.in_city = true; - } else if (localName.equals("latitude") && in_location) { - this.in_lat = true; - } else if (localName.equals("longitude") && in_location) { - this.in_long = true; - } else if (localName.equals("thumbnails") && in_current_image) { - this.in_thumbnails = true; - } else if (localName.equals("map_thumb") && in_thumbnails) { - this.in_thumbnail_url = true; - } - depth++; - } - - - /** Gets called on closing tags like: - * */ - @Override - public void endElement(String namespaceURI, String localName, String qName) - throws SAXException { - depth--; - if (localName.equals("id") && depth==3) { - this.in_id= false; - currentProj.setId(buffer); - } else if (localName.equals("title") && depth==3) { - this.in_title = false; - currentProj.setTitle(buffer); - } else if (localName.equals("subtitle") && depth==3) { - this.in_subtitle = false; - currentProj.setSubtitle(buffer); - } else if (localName.equals("funds")) { - this.in_funds = false; - try { - currentProj.setFunds(Double.parseDouble(buffer)); - } catch (NumberFormatException e) { - syntaxError = true; - } - } else if (localName.equals("primary_location")) { - this.in_location = false; - } else if (localName.equals("object") && depth==2) { - this.in_project = false; - if (currentProj != null) { - dba.saveProject(currentProj); - currentProj = null; - projectCount++; - } - } else if (localName.equals("project_plan_summary") && depth==3) { - this.in_summary = false; - currentProj.setSummary(buffer); - } else if (localName.equals("current_image") && depth==3) { - this.in_current_image = false; - } else if (localName.equals("country") && in_location) { - this.in_country = false; - currentProj.setCountry(buffer); - } else if (localName.equals("state") && in_location) { - this.in_state = false; - currentProj.setState(buffer); - } else if (localName.equals("city") && in_location) { - this.in_city = false; - currentProj.setCity(buffer); - } else if (localName.equals("latitude") && in_location) { - this.in_lat = false; - currentProj.setLatitude(buffer); - } else if (localName.equals("longitude") && in_location) { - this.in_long = false; - currentProj.setLongitude(buffer); - } else if (localName.equals("thumbnails") && in_current_image) { - this.in_thumbnails = false; - } else if (localName.equals("map_thumb") && in_thumbnails) { - this.in_thumbnail_url = false; - currentProj.setThumbnailUrl(buffer); - } - } - - - /** Gets called on the following structure: - * characters */ - @Override - public void characters(char ch[], int start, int length) { - if (currentProj != null) { - if (this.in_id || - this.in_summary || - this.in_thumbnail_url || - this.in_title || - this.in_subtitle || - this.in_country || - this.in_state || - this.in_city || - this.in_funds || - this.in_long || - this.in_lat - ) { - buffer += new String(ch, start, length); - } - } else - syntaxError = true; //set error flag - } - - // extract id from things like /api/v1/project/574/ - private String idFromUrl(String s) { - if (s.endsWith("/")) { - int i = s.lastIndexOf('/',s.length()-2); - if (i>=0) { - return s.substring(i+1, s.length()-1); - } else syntaxError = true; - } else syntaxError = true; - return null; - } - -} diff --git a/android/AkvoRSR/src/org/akvo/rsr/up/xml/UpdateExtraRestListHandler.java b/android/AkvoRSR/src/org/akvo/rsr/up/xml/UpdateExtraRestListHandler.java index 437081a9..799f6673 100644 --- a/android/AkvoRSR/src/org/akvo/rsr/up/xml/UpdateExtraRestListHandler.java +++ b/android/AkvoRSR/src/org/akvo/rsr/up/xml/UpdateExtraRestListHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012-2014 Stichting Akvo (Akvo Foundation) + * Copyright (C) 2012-2015 Stichting Akvo (Akvo Foundation) * * This file is part of Akvo RSR. * @@ -31,9 +31,11 @@ import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; +import android.util.Log; + /* - * Class to handle XML parsing for a project update from REST API. + * Class to handle XML parsing for a project update, with expanded nested objects, from REST API. * Always requested as a list, where each update object's tags of the XML will be encapsulated in * Example start of list: * @@ -98,13 +100,15 @@ public class UpdateExtraRestListHandler extends DefaultHandler { + private static final String TAG = "UpdateExtraRestListHandler"; + private static String ID = "id"; private static String LIST_ITEM = "list-item"; private static String PRIMARY_LOCATION = "primary_location"; private static String COUNTRY = "country"; private static String USER = "user"; private static String ORGANISATION = "organisation"; - + private static String CITY = "city"; // =========================================================== // Fields @@ -135,23 +139,23 @@ public class UpdateExtraRestListHandler extends DefaultHandler { private int countryCount; private boolean syntaxError = false; - private boolean insert; //insert parsed objects in the database + private boolean mInsert; //mInsert parsed objects in the database private int depth = 0; - private SimpleDateFormat df1; + private SimpleDateFormat mDateFormat; private String buffer; //where to store results - private RsrDbAdapter dba; + private RsrDbAdapter mDba; /* * constructor */ public UpdateExtraRestListHandler(RsrDbAdapter aDba, boolean insert, String serverRsrVersion) { super(); - dba = aDba; - this.insert = insert; - df1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.US); - df1.setTimeZone(TimeZone.getTimeZone("UTC")); + mDba = aDba; + mInsert = insert; + mDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.US); + mDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); } // =========================================================== // Getter & Setter @@ -166,7 +170,7 @@ public int getCount() { } public Update getLastUpdate() { - return currentUpd; //only valid if insert==False + return currentUpd; //only valid if mInsert==False } // =========================================================== @@ -174,7 +178,7 @@ public Update getLastUpdate() { // =========================================================== @Override public void startDocument() throws SAXException { - dba.open(); + mDba.open(); updateCount = 0; countryCount = 0; userCount = 0; @@ -185,21 +189,23 @@ public void startDocument() throws SAXException { @Override public void endDocument() throws SAXException { - dba.close(); + mDba.close(); } - + //location of update void startLocationElement(String localName) { if (localName.equals(COUNTRY)) { this.in_country = true; + currentCountry = new Country(); } else if ( localName.equals("state") - || localName.equals("city") + || localName.equals(CITY) || localName.equals("latitude") || localName.equals("longitude")) { in_leaf = true; } } + //country of location of update void startCountryElement(String localName) { if ( localName.equals(ID) || localName.equals("name") @@ -209,6 +215,7 @@ void startCountryElement(String localName) { } } + //org of user of update void startOrgElement(String localName) { //TODO: We do not care about org location yet // if (localName.equals(PRIMARY_LOCATION)) { @@ -221,6 +228,7 @@ void startOrgElement(String localName) { } } + //user of update void startUserElement(String localName) { if (localName.equals(ORGANISATION)) { this.in_org = true; @@ -295,7 +303,7 @@ public void endCountryElement(String localName) throws SAXException { currentCountry.setContinent(buffer); } else if (localName.equals("country")) { this.in_country = false; - dba.saveCountry(currentCountry); + mDba.saveCountry(currentCountry); countryCount++; currentCountry = null; } @@ -315,7 +323,7 @@ public void endLocElement(String localName) throws SAXException { currentLoc.setLongitude(buffer); } else if (localName.equals("state")) { currentLoc.setState(buffer); - } else if (localName.equals("city")) { + } else if (localName.equals(CITY)) { currentLoc.setCity(buffer); } else if (localName.equals(PRIMARY_LOCATION)) { this.in_location = false; @@ -335,7 +343,7 @@ public void endUserElement(String localName) throws SAXException { currentUser.setLastname(buffer); } else if (localName.equals(USER)) { this.in_user = false; - dba.saveCountry(currentCountry); + mDba.saveCountry(currentCountry); userCount++; currentUser = null; } @@ -359,9 +367,11 @@ public void endElement(String namespaceURI, String localName, String qName) this.in_update = false; if (currentUpd != null && currentUpd.getId() != null) { updateCount++; - if (insert) { - dba.saveUpdate(currentUpd, false); //preserve name of any cached image + if (mInsert) { + mDba.saveUpdate(currentUpd, false); //preserve name of any cached image currentUpd = null; + } else { + Log.i(TAG, "Did not store update" + currentUpd.getId()); } } } else if (localName.equals("id")) { @@ -372,7 +382,7 @@ public void endElement(String namespaceURI, String localName, String qName) currentUpd.setText(buffer); } else if (localName.equals("time")) { try { - currentUpd.setDate(df1.parse(buffer)); + currentUpd.setDate(mDateFormat.parse(buffer)); } catch (ParseException e1) { syntaxError = true; } diff --git a/android/AkvoRSR/src/org/akvo/rsr/up/xml/UpdateListHandler.java b/android/AkvoRSR/src/org/akvo/rsr/up/xml/UpdateListHandler.java deleted file mode 100644 index 8d4e9c3b..00000000 --- a/android/AkvoRSR/src/org/akvo/rsr/up/xml/UpdateListHandler.java +++ /dev/null @@ -1,320 +0,0 @@ -/* - * Copyright (C) 2012-2013 Stichting Akvo (Akvo Foundation) - * - * This file is part of Akvo RSR. - * - * Akvo RSR is free software: you can redistribute it and modify it under the terms of - * the GNU Affero General Public License (AGPL) as published by the Free Software Foundation, - * either version 3 of the License or any later version. - * - * Akvo RSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Affero General Public License included with this program for more details. - * - * The full license text can also be seen at . - */ - -package org.akvo.rsr.up.xml; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Locale; -import java.util.TimeZone; - -import org.akvo.rsr.up.dao.RsrDbAdapter; -import org.akvo.rsr.up.domain.Update; -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; - - -/* - * Class to handle XML parsing for a project update. - * Normally requested as a list, in which case the root tags of the XML will be - * Example input for one object: - * - -W - - -Video screening improves farms productivity -http://test.akvo.org/rsr/media/db/project/363/update/2505/ProjectUpdate_2505_photo_2013-02-04_10.56.30.JPG -/rsr/project/363/update/2505/ -/api/v1/project/363/ - -E - - - -Example of location (maybe not right tag): - - - Nairobi - /api/v1/country/27/ - True - 36.819185 - /api/v1/project/1350/ - PO Box 36655-0200 - Suite 425 Parklands Road, Westlands - -1.267924 - 2069/api/v1/project_location/2069/ - - */ - - - -public class UpdateListHandler extends DefaultHandler { - - - // =========================================================== - // Fields - // =========================================================== - - private boolean in_update = false; - private boolean in_id = false; - private boolean in_title = false; - private boolean in_project_id = false; - private boolean in_user_id = false; - private boolean in_photo = false; - private boolean in_photo_credit = false; - private boolean in_photo_caption = false; - private boolean in_video = false; - private boolean in_text = false; - private boolean in_time = false; - private boolean in_uuid = false; - - private boolean in_location = false; - private boolean in_country = false; - private boolean in_state = false; - private boolean in_city = false; - private boolean in_long = false; - private boolean in_lat = false; - - private Update currentUpd; - private int updateCount; - private boolean syntaxError = false; - private boolean insert; - private boolean extra; - private int depth = 0; - private SimpleDateFormat df1; - private String buffer; - - //where to store results - private RsrDbAdapter dba; - - /* - * constructor - */ - public UpdateListHandler(RsrDbAdapter aDba, boolean insert, boolean extra) { - super(); - dba = aDba; - this.insert = insert; - this.extra = extra; - df1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.US); - df1.setTimeZone(TimeZone.getTimeZone("UTC")); - } - // =========================================================== - // Getter & Setter - // =========================================================== - - public boolean getError() { - return syntaxError; - } - - public int getCount() { - return updateCount; - } - - public Update getLastUpdate() { - return currentUpd; //only valid if insert==False - } - - // =========================================================== - // Methods - // =========================================================== - @Override - public void startDocument() throws SAXException { - dba.open(); - updateCount = 0; - depth = 0; - syntaxError = false; - } - - @Override - public void endDocument() throws SAXException { - dba.close(); - } - - /** Gets be called on opening tags like: - * - * Can provide attribute(s), when xml was like: - * */ - @Override - public void startElement(String namespaceURI, String localName, - String qName, Attributes atts) throws SAXException { - buffer = ""; - if (localName.equals("object")) { - this.in_update = true; - currentUpd = new Update(); - } else if (in_update) { - if (localName.equals("id")) { - this.in_id = true; - } else if (localName.equals("title")) { - this.in_title = true; - } else if (localName.equals("text")) { - this.in_text = true; - } else if (localName.equals("time")) { - this.in_time = true; - } else if (localName.equals("project")) { - this.in_project_id = true; - } else if (localName.equals("user")) { - this.in_user_id = true; - } else if (localName.equals("uuid")) { - this.in_uuid = true; - } else if (localName.equals("photo")) { - this.in_photo = true; - } else if (localName.equals("photo_credit")) { - this.in_photo_credit = true; - } else if (localName.equals("photo_caption")) { - this.in_photo_caption = true; - } else if (localName.equals("video")) { - this.in_video = true; - } else if (localName.equals("primary_location")) { - this.in_location = true; - } else if (localName.equals("country") && in_location) { - this.in_country = true; - } else if (localName.equals("state") && in_location) { - this.in_state = true; - } else if (localName.equals("city") && in_location) { - this.in_city = true; - } else if (localName.equals("latitude") && in_location) { - this.in_lat = true; - } else if (localName.equals("longitude") && in_location) { - this.in_long = true; } - } - - depth++; - } - - /** Gets called on closing tags like: - * */ - @Override - public void endElement(String namespaceURI, String localName, String qName) - throws SAXException { - depth--; - - if (localName.equals("object")) { //we are done - this.in_update = false; - if (currentUpd != null && currentUpd.getId() != null) { - updateCount++; - if (insert) { - dba.saveUpdate(currentUpd, false); //preserve name of any cached image - currentUpd = null; - } - } - } else if (localName.equals("id")) { - this.in_id = false; - currentUpd.setId(buffer); - } else if (localName.equals("title")) { - this.in_title = false; - currentUpd.setTitle(buffer); - } else if (localName.equals("text")) { - this.in_text = false; - currentUpd.setText(buffer); - } else if (localName.equals("time")) { - this.in_time = false; - try { - currentUpd.setDate(df1.parse(buffer)); - } catch (ParseException e1) { - syntaxError = true; - } - } else if (localName.equals("project")) { - this.in_project_id = false; - currentUpd.setProjectId(idFromUrl(buffer)); - } else if (localName.equals("user")) { - this.in_user_id = false; - currentUpd.setUserId(idFromUrl(buffer)); - } else if (localName.equals("uuid")) { - this.in_uuid = false; - currentUpd.setUuid(buffer); - } else if (localName.equals("photo")) { - this.in_photo = false; - currentUpd.setThumbnailUrl(buffer); - } else if (localName.equals("photo_credit")) { - this.in_photo_credit = false; - currentUpd.setPhotoCredit(buffer); - } else if (localName.equals("photo_caption")) { - this.in_photo_caption = false; - currentUpd.setPhotoCaption(buffer); - } else if (localName.equals("video")) { - this.in_video = false; - currentUpd.setVideoUrl(buffer); - } else if (localName.equals("primary_location")) { - this.in_location = false; - } else if (localName.equals("country") && in_location) { - this.in_country = false; - currentUpd.setCountry(buffer); - } else if (localName.equals("state") && in_location) { - this.in_state = false; - currentUpd.setState(buffer); - } else if (localName.equals("city") && in_location) { - this.in_city = false; - currentUpd.setCity(buffer); - } else if (localName.equals("latitude") && in_location) { - this.in_lat = false; - currentUpd.setLatitude(buffer); - } else if (localName.equals("longitude") && in_location) { - this.in_long = false; - currentUpd.setLongitude(buffer); - } - } - - /** Gets called on the following structure: - * characters */ - // May be called multiple times for pieces of the same tag contents! - @Override - public void characters(char ch[], int start, int length) { - if (this.in_id - || this.in_title - || this.in_uuid - || this.in_user_id - || this.in_project_id - || this.in_photo - || this.in_photo_credit - || this.in_photo_caption - || this.in_video - || this.in_text - || this.in_time - || this.in_country - || this.in_state - || this.in_city - || this.in_long - || this.in_lat - ) { //remember content - buffer += new String(ch, start, length); - } - } - - - // extract id from things like /api/v1/project/574/ - private String idFromUrl(String s) { - if (s.endsWith("/")) { - int i = s.lastIndexOf('/',s.length()-2); - if (i>=0) { - return s.substring(i+1, s.length()-1); - } else syntaxError = true; - } else syntaxError = true; - return null; - } - -} diff --git a/android/AkvoRSR/src/org/akvo/rsr/up/xml/UpdateRestListHandler.java b/android/AkvoRSR/src/org/akvo/rsr/up/xml/UpdateRestListHandler.java index 67698af7..9be29e9b 100644 --- a/android/AkvoRSR/src/org/akvo/rsr/up/xml/UpdateRestListHandler.java +++ b/android/AkvoRSR/src/org/akvo/rsr/up/xml/UpdateRestListHandler.java @@ -85,7 +85,10 @@ public class UpdateRestListHandler extends DefaultHandler { // Fields // =========================================================== - private boolean in_update = false; + private boolean in_next = false; + private boolean in_count = false; + + private boolean in_update = false; private boolean in_id = false; private boolean in_title = false; private boolean in_project_id = false; @@ -119,6 +122,8 @@ public class UpdateRestListHandler extends DefaultHandler { private String buffer; private String stored_location_id; private String primary_location_id; + private String nextUrl = ""; + private int totalCount = 0; //where to store results private RsrDbAdapter dba; @@ -141,9 +146,17 @@ public boolean getError() { return syntaxError; } - public int getCount() { - return updateCount; - } + public int getCount() { + return updateCount; + } + + public int getTotalCount() { + return totalCount; + } + + public String getNextUrl() { + return nextUrl; + } public Update getLastUpdate() { return currentUpd; //only valid if insert==False @@ -173,8 +186,12 @@ public void endDocument() throws SAXException { public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { buffer = ""; - if (depth == 1 && localName.equals("results")) { + if (depth == 1 && localName.equals("results")) { this.in_results = true; + } else if (depth == 1 && localName.equals("count")) { + this.in_count = true; + } else if (depth == 1 && localName.equals("next")) { + this.in_next = true; } else if (depth == 2 && in_results && localName.equals(LIST_ITEM)) { this.in_update = true; currentUpd = new Update(); @@ -238,8 +255,14 @@ public void endElement(String namespaceURI, String localName, String qName) throws SAXException { depth--; - if (depth == 1 && localName.equals("results")) { + if (depth == 1 && localName.equals("results")) { this.in_results = false; + } else if (depth == 1 && localName.equals("next")) { + this.in_next = false; + nextUrl = buffer.trim(); //in case there are newlines + } else if (depth == 1 && localName.equals("count")) { + this.in_count = false; + totalCount = Integer.valueOf(buffer); } else if (localName.equals(LIST_ITEM)) { if (in_location) {//we are done with this location this.in_location = false; @@ -340,7 +363,9 @@ public void characters(char ch[], int start, int length) { || this.in_state || this.in_city || this.in_long - || this.in_lat + || this.in_lat + || this.in_next + || this.in_count ) { //remember content buffer += new String(ch, start, length); }