Example usage for com.google.gson JsonArray size

List of usage examples for com.google.gson JsonArray size

Introduction

In this page you can find the example usage for com.google.gson JsonArray size.

Prototype

public int size() 

Source Link

Document

Returns the number of elements in the array.

Usage

From source file:citysdk.tourism.client.parser.POIDeserializer.java

License:Open Source License

private void getLabels(POI poi, JsonObject jObject) {
    JsonArray jArray = jObject.getAsJsonArray(LABEL);
    for (int i = 0; i < jArray.size(); i++) {
        JsonElement e = jArray.get(i);/* w  w w.  j  av a  2  s.co m*/
        JsonObject o = e.getAsJsonObject();
        poi.addLabel(getPOITermType(o));
    }
}

From source file:citysdk.tourism.client.parser.POIDeserializer.java

License:Open Source License

private void getDescription(POI poi, JsonObject jObject) {
    JsonArray jArray = jObject.getAsJsonArray(DESCRIPTION);
    for (int i = 0; i < jArray.size(); i++) {
        JsonElement e = jArray.get(i);//from   w  w w.j a  v a 2s  .  c o m
        JsonObject o = e.getAsJsonObject();
        poi.addDescription(getPOIBaseType(o));
    }
}

From source file:citysdk.tourism.client.parser.POIDeserializer.java

License:Open Source License

private void getCategories(POI poi, JsonObject jObject) {
    JsonArray jArray = jObject.getAsJsonArray(CATEGORY);
    for (int i = 0; i < jArray.size(); i++) {
        JsonElement e = jArray.get(i);//from  ww w  .  ja va2  s .  c  o  m
        JsonObject o = e.getAsJsonObject();
        poi.addCategory(getPOITermType(o));
    }
}

From source file:citysdk.tourism.client.parser.POIDeserializer.java

License:Open Source License

private void getPoints(Location location, JsonArray array) {
    for (int i = 0; i < array.size(); i++) {
        JsonObject ob = array.get(i).getAsJsonObject();

        Geometry g = new Geometry();
        g.setPosList(ob.get(POINT_P).getAsJsonObject().get(POS_LIST).getAsString());

        Point point = new Point();
        point.setTerm(ob.get(TERM).getAsString());
        point.setPoint(g);/*ww  w .j  a  v a 2  s .  co m*/

        location.addPoint(point);
    }
}

From source file:citysdk.tourism.client.parser.POIDeserializer.java

License:Open Source License

private void getLine(Location location, JsonArray array) {
    for (int i = 0; i < array.size(); i++) {
        JsonObject ob = array.get(i).getAsJsonObject();

        Geometry g = new Geometry();
        g.setPosList(ob.get(LINE_STRING).getAsJsonObject().get(POS_LIST).getAsString());

        Line line = new Line();
        line.setTerm(ob.get(TERM).getAsString());
        line.setLineString(g);/*from w w  w . j  a v a  2  s .  c  om*/

        location.addLine(line);
    }
}

From source file:citysdk.tourism.client.parser.POIDeserializer.java

License:Open Source License

private void getSimplePolygon(Location location, JsonArray array) {
    for (int i = 0; i < array.size(); i++) {
        JsonObject ob = array.get(i).getAsJsonObject();

        Geometry g = new Geometry();
        g.setPosList(ob.get(SIMPLE_POLYGON).getAsJsonObject().get(POS_LIST).getAsString());

        Polygon polygon = new Polygon();
        polygon.setTerm(ob.get(TERM).getAsString());
        polygon.setSimplePolygon(g);//from www  .  j a v a 2  s. c  o m

        location.addPolygon(polygon);
    }
}

From source file:citysdk.tourism.client.parser.POIDeserializer.java

License:Open Source License

private void getRelationships(Location location, JsonArray array) {
    for (int i = 0; i < array.size(); i++) {
        JsonObject ob = array.get(i).getAsJsonObject();

        Relationship r = new Relationship();
        r.setTerm(ob.get(TERM).getAsString());
        r.setBase(ob.get(BASE).getAsString());
        if (ob.has(TARGET_POI))
            r.setTargetPOI(ob.get(TARGET_POI).getAsString());

        if (ob.has(TARGET_EVENT))
            r.setTargetEvent(ob.get(TARGET_EVENT).getAsString());

        location.addRelationship(r);//from w w  w.  j  av a 2  s .  c o m
    }
}

From source file:citysdk.tourism.client.parser.POIDeserializer.java

License:Open Source License

private void getTime(POI poi, JsonObject jObject) {
    JsonArray jArray = jObject.getAsJsonArray(TIME);
    for (int i = 0; i < jArray.size(); i++) {
        JsonObject ob = jArray.get(i).getAsJsonObject();
        POITermType term = getPOITermType(ob);

        if (ob.has(SCHEME))
            term.setScheme(ob.get(SCHEME).getAsString());

        poi.addTime(term);/*from w ww .  j av  a2s . c o  m*/
    }
}

From source file:citysdk.tourism.client.parser.POIDeserializer.java

License:Open Source License

private void getLinks(POI poi, JsonObject jObject) {
    JsonArray jArray = jObject.getAsJsonArray(LINK);
    for (int i = 0; i < jArray.size(); i++) {
        JsonObject ob = jArray.get(i).getAsJsonObject();
        POITermType term = getPOITermType(ob);
        poi.addLink(term);// ww  w  .  j  a  v  a 2  s  .  com
    }
}

From source file:citysdk.tourism.client.parser.POIDeserializer.java

License:Open Source License

private void deserializeListPois(ListPointOfInterest list, JsonObject jObject) {
    JsonElement jElement = jObject.get(POI);
    JsonArray jArray = jElement.getAsJsonArray();
    for (int i = 0; i < jArray.size(); i++) {
        PointOfInterest poi = new PointOfInterest();
        getSinglePOI(poi, jArray.get(i).getAsJsonObject());
        list.addPoi(poi);// ww  w. j  av a 2  s  .com
    }
}