Example usage for com.google.gson.stream JsonReader nextDouble

List of usage examples for com.google.gson.stream JsonReader nextDouble

Introduction

In this page you can find the example usage for com.google.gson.stream JsonReader nextDouble.

Prototype

public double nextDouble() throws IOException 

Source Link

Document

Returns the com.google.gson.stream.JsonToken#NUMBER double value of the next token, consuming it.

Usage

From source file:zack.yovel.clear.infrastructure.model.datapoints.ForecastIoParser.java

License:Apache License

private void doParse(JsonReader reader, WeatherReport output) throws IOException {
    reader.beginObject();/*from   w w w  .j  a v a  2 s  . c o  m*/
    while (reader.hasNext()) {
        String name = reader.nextName();
        if (name.equals("latitude")) {
            output.setLatitude(reader.nextDouble());
        } else if (name.equals("longitude")) {
            output.setLongitude(reader.nextDouble());
        } else if (name.equals("currently")) {
            output.setCurrently(parseDataPoint(reader));
        } else if (name.equals("hourly")) {
            output.setHourly(parseDataBlock(reader));
        } else if (name.equals("daily")) {
            output.setDaily(parseDataBlock(reader));
        } else if (name.equals("alerts")) {
            output.setAlerts(parseAlerts(reader));
        } else {
            reader.skipValue();
        }
    }
    reader.endObject();
}

From source file:zack.yovel.clear.infrastructure.model.datapoints.ForecastIoParser.java

License:Apache License

private void getDataPointProperty(JsonReader reader, DataPoint output) throws IOException {
    String name = reader.nextName();
    if (name.equals("time")) {
        output.setTime(reader.nextLong() * 1000); // forecast api gives time in seconds, while Java, Android and joda time work with milliseconds...
    } else if (name.equals("icon")) {
        output.setIcon(reader.nextString());
    } /*else if (name.equals("precipIntensity")) {
      output.setPrecipIntensity(reader.nextDouble());
      } else if (name.equals("precipProbability")) {
      output.setPrecipProbability(reader.nextDouble());
      } else if (name.equals("precipType")) {
      output.setPrecipType(reader.nextString());
      } else if (name.equals("precipAccumulation")) {
      output.setPrecipAccumulation(reader.nextDouble());
      }*/ else if (name.equals("temperature")) {
        output.setTemperature(reader.nextDouble());
    } else if (name.equals("temperatureMin")) {
        output.setTemperatureMin(reader.nextDouble());
    } else if (name.equals("temperatureMinTime")) {
        output.setTemperatureMinTime(reader.nextLong());
    } else if (name.equals("temperatureMax")) {
        output.setTemperatureMax(reader.nextDouble());
    } else if (name.equals("temperatureMaxTime")) {
        output.setTemperatureMaxTime(reader.nextLong());
    } else if (name.equals("apparentTemperature")) {
        output.setApparentTemperature(reader.nextDouble());
    } else if (name.equals("apparentTemperatureMin")) {
        output.setApparentTemperatureMin(reader.nextDouble());
    } else if (name.equals("apparentTemperatureMax")) {
        output.setApparentTemperatureMax(reader.nextDouble());
    } else if (name.equals("apparentTemperatureMaxTime")) {
        output.setApparentTemperatureMaxTime(reader.nextLong());
    } else if (name.equals("windSpeed")) {
        output.setWindSpeed(reader.nextDouble());
    } else if (name.equals("windBearing")) {
        output.setWindBearing(reader.nextDouble());
    } /*else if (name.equals("cloudCover")) {
      output.setCloudCover(reader.nextDouble());
      }*/ else if (name.equals("humidity")) {
        output.setHumidity(reader.nextDouble());
    } else {//from   www .j  a v a 2  s .co m
        reader.skipValue();
    }
}