FLamparski / areabase

Areabase is a project to create an Android app to bring UK census and police data into one place (also tells you how good or bad your area is)
0 stars 0 forks source link

Wrap the required ONS/NDE Discovery methods #2

Closed FLamparski closed 10 years ago

FLamparski commented 11 years ago

Finish wrapping the Discovery API (skip the unnecessary methods)

FLamparski commented 11 years ago

Well, everything I need for now should be complete. On to test...

FLamparski commented 10 years ago

Dumb XML is dumb

So -- har har -- using XPath on Android is a bloody joke. It goes into garbage collection pretty much ALL the time. I'm reimplementing this API using the Pull parser, which could take a while.

Hopefully the speed will be worth it.

In the meantime, enjoy:

while (event != XmlPullParser.END_DOCUMENT) {
            switch (event) {
            case XmlPullParser.START_TAG:
                key = xpp.getName();
                if (key.equals("Error"))
                    error = new NDE2Exception();
                if (key.equals("Area"))
                    area = new Area();
                break;
            case XmlPullParser.TEXT:
                value = xpp.getText();
                if (key.equals("AreaId"))
                    area.setAreaId(Integer.parseInt(value));
                if (key.equals("Name"))
                    area.setName(value);
                if (key.equals("HierarchyId"))
                    area.setHierarchyId(Integer.parseInt(value));
                if (key.equals("LevelTypeId"))
                    area.setLevelTypeId(Integer.parseInt(value));
                if (key.equals("message"))
                    error.setNessMessage(value);
                if (key.equals("detail"))
                    error.setNessDetail(value);
                break;
            case XmlPullParser.END_TAG:
                if (xpp.getName().equals("Area"))
                    areaSet.add(area);
                break;
            }
            event = xpp.next();
        }

I blame the ONS.

FLamparski commented 10 years ago

DONE. For now.