mirror of
https://bitbucket.org/akapribot/owm-japis.git
synced 2025-04-24 14:57:11 -07:00
2.5.0.5: Fixed some bugs and added proxy option
This commit is contained in:
parent
e451156050
commit
d98354c5d7
7 changed files with 142 additions and 123 deletions
|
@ -6,7 +6,7 @@ sourceCompatibility = 1.5
|
|||
|
||||
group = 'net.aksingh'
|
||||
archivesBaseName = "owm-japis"
|
||||
version = '2.5.0.4'
|
||||
version = '2.5.0.5'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
@ -77,4 +77,4 @@ uploadArchives {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
22
gradle/wrapper/gradle-wrapper.properties
vendored
22
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,3 +1,25 @@
|
|||
#
|
||||
# Copyright (c) 2013-2015 Ashutosh Kumar Singh <me@aksingh.net>
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
#
|
||||
|
||||
#Fri Dec 19 05:07:43 IST 2014
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
|
|
|
@ -149,36 +149,36 @@ public abstract class AbstractForecast extends AbstractResponse {
|
|||
}
|
||||
|
||||
City(JSONObject jsonObj) {
|
||||
this.cityID = (jsonObj != null) ? jsonObj.optLong(this.JSON_CITY_ID, Long.MIN_VALUE) : Long.MIN_VALUE;
|
||||
this.cityName = (jsonObj != null) ? jsonObj.optString(this.JSON_CITY_NAME, null) : null;
|
||||
this.countryCode = (jsonObj != null) ? jsonObj.optString(this.JSON_CITY_COUNTRY_CODE, null) : null;
|
||||
this.population = (jsonObj != null) ? jsonObj.optLong(this.JSON_CITY_POPULATION, Long.MIN_VALUE) : Long.MIN_VALUE;
|
||||
this.cityID = (jsonObj != null) ? jsonObj.optLong(JSON_CITY_ID, Long.MIN_VALUE) : Long.MIN_VALUE;
|
||||
this.cityName = (jsonObj != null) ? jsonObj.optString(JSON_CITY_NAME, null) : null;
|
||||
this.countryCode = (jsonObj != null) ? jsonObj.optString(JSON_CITY_COUNTRY_CODE, null) : null;
|
||||
this.population = (jsonObj != null) ? jsonObj.optLong(JSON_CITY_POPULATION, Long.MIN_VALUE) : Long.MIN_VALUE;
|
||||
|
||||
JSONObject jsonObjCoord = (jsonObj != null) ? jsonObj.optJSONObject(this.JSON_CITY_COORD) : null;
|
||||
JSONObject jsonObjCoord = (jsonObj != null) ? jsonObj.optJSONObject(JSON_CITY_COORD) : null;
|
||||
this.coord = (jsonObjCoord != null) ? new Coord(jsonObjCoord) : null;
|
||||
}
|
||||
|
||||
public boolean hasCityCode() {
|
||||
return (this.cityID != Long.MIN_VALUE);
|
||||
return this.cityID != Long.MIN_VALUE;
|
||||
}
|
||||
|
||||
public boolean hasCityName() {
|
||||
return (this.cityName != null);
|
||||
return this.cityName != null;
|
||||
}
|
||||
|
||||
public boolean hasCountryCode() {
|
||||
return (this.countryCode != null);
|
||||
return this.countryCode != null;
|
||||
}
|
||||
|
||||
public boolean hasCityPopulation() {
|
||||
return (this.population != Long.MIN_VALUE);
|
||||
return this.population != Long.MIN_VALUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>true</code> if Coord instance is available, otherwise <code>false</code>.
|
||||
*/
|
||||
public boolean hasCoordInstance() {
|
||||
return (coord != null);
|
||||
return coord != null;
|
||||
}
|
||||
|
||||
public long getCityCode() {
|
||||
|
|
|
@ -36,6 +36,11 @@ import java.io.Serializable;
|
|||
* @since 2.5.0.3
|
||||
*/
|
||||
abstract class AbstractResponse implements Serializable {
|
||||
/*
|
||||
JSON Keys
|
||||
*/
|
||||
private static final String JSON_RESPONSE_CODE = "cod";
|
||||
|
||||
/*
|
||||
Instance variables
|
||||
*/
|
||||
|
@ -51,8 +56,6 @@ abstract class AbstractResponse implements Serializable {
|
|||
}
|
||||
|
||||
AbstractResponse(JSONObject jsonObj) {
|
||||
final String JSON_RESPONSE_CODE = "cod";
|
||||
|
||||
this.rawResponse = (jsonObj != null) ? jsonObj.toString() : null;
|
||||
this.responseCode = (jsonObj != null) ? jsonObj.optInt(JSON_RESPONSE_CODE, Integer.MIN_VALUE) : Integer.MIN_VALUE;
|
||||
}
|
||||
|
@ -61,21 +64,21 @@ abstract class AbstractResponse implements Serializable {
|
|||
* @return <code>true</code> if response is valid (downloaded and parsed correctly), otherwise <code>false</code>.
|
||||
*/
|
||||
public boolean isValid() {
|
||||
return (this.responseCode == 200);
|
||||
return this.responseCode == 200;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>true</code> if response code is available, otherwise <code>false</code>.
|
||||
*/
|
||||
public boolean hasResponseCode() {
|
||||
return (this.responseCode != Integer.MIN_VALUE);
|
||||
return this.responseCode != Integer.MIN_VALUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>true</code> if raw response is available, otherwise <code>false</code>.
|
||||
*/
|
||||
public boolean hasRawResponse() {
|
||||
return (this.rawResponse != null);
|
||||
return this.rawResponse != null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -77,13 +77,6 @@ public abstract class AbstractWeather extends AbstractResponse {
|
|||
|
||||
long sec = (jsonObj != null) ? jsonObj.optLong(JSON_DATE_TIME, Long.MIN_VALUE) : Long.MIN_VALUE;
|
||||
if (sec != Long.MIN_VALUE) { // converting seconds to Date object
|
||||
/*
|
||||
Bugfix: It always return "Sat Jan 17 04:10:42 CET 1970"
|
||||
Issue: #3 at http://code.aksingh.net/owm-japis/issue/3/problem-with-datetime
|
||||
Incorrect: this.dateTime = new Date(sec);
|
||||
Correct: this.dateTime = new Date(sec * 1000);
|
||||
Reason: Date requires milliseconds but previously, seconds were provided.
|
||||
*/
|
||||
this.dateTime = new Date(sec * 1000);
|
||||
} else {
|
||||
this.dateTime = null;
|
||||
|
@ -91,7 +84,7 @@ public abstract class AbstractWeather extends AbstractResponse {
|
|||
|
||||
JSONArray weatherArray = (jsonObj != null) ? jsonObj.optJSONArray(JSON_WEATHER) : new JSONArray();
|
||||
this.weatherList = (weatherArray != null) ? new ArrayList<Weather>(weatherArray.length()) : Collections.EMPTY_LIST;
|
||||
if (this.weatherList != Collections.EMPTY_LIST) {
|
||||
if (weatherArray != null && this.weatherList != Collections.EMPTY_LIST) {
|
||||
for (int i = 0; i < weatherArray.length(); i++) {
|
||||
JSONObject weatherObj = weatherArray.optJSONObject(i);
|
||||
if (weatherObj != null) {
|
||||
|
@ -106,14 +99,14 @@ public abstract class AbstractWeather extends AbstractResponse {
|
|||
* @return <code>true</code> if date/time is available, otherwise <code>false</code>.
|
||||
*/
|
||||
public boolean hasDateTime() {
|
||||
return (this.dateTime != null);
|
||||
return this.dateTime != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>true</code> if Weather instance(s) is available, otherwise <code>false</code>.
|
||||
*/
|
||||
public boolean hasWeatherInstance() {
|
||||
return (weatherCount != 0);
|
||||
return weatherCount != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -157,7 +150,7 @@ public abstract class AbstractWeather extends AbstractResponse {
|
|||
}
|
||||
|
||||
Clouds(JSONObject jsonObj) {
|
||||
this.percentOfClouds = (float) jsonObj.optDouble(this.JSON_CLOUDS_ALL, Double.NaN);
|
||||
this.percentOfClouds = (float) jsonObj.optDouble(JSON_CLOUDS_ALL, Double.NaN);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -166,7 +159,7 @@ public abstract class AbstractWeather extends AbstractResponse {
|
|||
* @return <code>true</code> if data available, otherwise <code>false</code>
|
||||
*/
|
||||
public boolean hasPercentageOfClouds() {
|
||||
return (this.percentOfClouds != Float.NaN);
|
||||
return !Float.isNaN(this.percentOfClouds);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -199,8 +192,8 @@ public abstract class AbstractWeather extends AbstractResponse {
|
|||
}
|
||||
|
||||
Coord(JSONObject jsonObj) {
|
||||
this.lat = (float) jsonObj.optDouble(this.JSON_COORD_LATITUDE, Double.NaN);
|
||||
this.lon = (float) jsonObj.optDouble(this.JSON_COORD_LONGITUDE, Double.NaN);
|
||||
this.lat = (float) jsonObj.optDouble(JSON_COORD_LATITUDE, Double.NaN);
|
||||
this.lon = (float) jsonObj.optDouble(JSON_COORD_LONGITUDE, Double.NaN);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -209,7 +202,7 @@ public abstract class AbstractWeather extends AbstractResponse {
|
|||
* @return <code>true</code> if data available, otherwise <code>false</code>
|
||||
*/
|
||||
public boolean hasLatitude() {
|
||||
return (this.lat != Float.NaN);
|
||||
return !Float.isNaN(this.lat);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -218,7 +211,7 @@ public abstract class AbstractWeather extends AbstractResponse {
|
|||
* @return <code>true</code> if data available, otherwise <code>false</code>
|
||||
*/
|
||||
public boolean hasLongitude() {
|
||||
return (this.lon != Float.NaN);
|
||||
return !Float.isNaN(this.lon);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -268,11 +261,11 @@ public abstract class AbstractWeather extends AbstractResponse {
|
|||
}
|
||||
|
||||
Main(JSONObject jsonObj) {
|
||||
this.temp = (float) jsonObj.optDouble(this.JSON_MAIN_TEMP, Double.NaN);
|
||||
this.minTemp = (float) jsonObj.optDouble(this.JSON_MAIN_TEMP_MIN, Double.NaN);
|
||||
this.maxTemp = (float) jsonObj.optDouble(this.JSON_MAIN_TEMP_MAX, Double.NaN);
|
||||
this.pressure = (float) jsonObj.optDouble(this.JSON_MAIN_PRESSURE, Double.NaN);
|
||||
this.humidity = (float) jsonObj.optDouble(this.JSON_MAIN_HUMIDITY, Double.NaN);
|
||||
this.temp = (float) jsonObj.optDouble(JSON_MAIN_TEMP, Double.NaN);
|
||||
this.minTemp = (float) jsonObj.optDouble(JSON_MAIN_TEMP_MIN, Double.NaN);
|
||||
this.maxTemp = (float) jsonObj.optDouble(JSON_MAIN_TEMP_MAX, Double.NaN);
|
||||
this.pressure = (float) jsonObj.optDouble(JSON_MAIN_PRESSURE, Double.NaN);
|
||||
this.humidity = (float) jsonObj.optDouble(JSON_MAIN_HUMIDITY, Double.NaN);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -281,7 +274,7 @@ public abstract class AbstractWeather extends AbstractResponse {
|
|||
* @return <code>true</code> if data available, otherwise <code>false</code>
|
||||
*/
|
||||
public boolean hasTemperature() {
|
||||
return (this.temp != Float.NaN);
|
||||
return !Float.isNaN(this.temp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -290,7 +283,7 @@ public abstract class AbstractWeather extends AbstractResponse {
|
|||
* @return <code>true</code> if data available, otherwise <code>false</code>
|
||||
*/
|
||||
public boolean hasMinTemperature() {
|
||||
return (this.minTemp != Float.NaN);
|
||||
return !Float.isNaN(this.minTemp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -299,7 +292,7 @@ public abstract class AbstractWeather extends AbstractResponse {
|
|||
* @return <code>true</code> if data available, otherwise <code>false</code>
|
||||
*/
|
||||
public boolean hasMaxTemperature() {
|
||||
return (this.maxTemp != Float.NaN);
|
||||
return !Float.isNaN(this.maxTemp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -308,7 +301,7 @@ public abstract class AbstractWeather extends AbstractResponse {
|
|||
* @return <code>true</code> if data available, otherwise <code>false</code>
|
||||
*/
|
||||
public boolean hasPressure() {
|
||||
return (this.pressure != Float.NaN);
|
||||
return !Float.isNaN(this.pressure);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -317,7 +310,7 @@ public abstract class AbstractWeather extends AbstractResponse {
|
|||
* @return <code>true</code> if data available, otherwise <code>false</code>
|
||||
*/
|
||||
public boolean hasHumidity() {
|
||||
return (this.humidity != Float.NaN);
|
||||
return !Float.isNaN(this.humidity);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -395,10 +388,10 @@ public abstract class AbstractWeather extends AbstractResponse {
|
|||
}
|
||||
|
||||
Weather(JSONObject jsonObj) {
|
||||
this.id = jsonObj.optInt(this.JSON_WEATHER_ID, Integer.MIN_VALUE);
|
||||
this.name = jsonObj.optString(this.JSON_WEATHER_MAIN, null);
|
||||
this.description = jsonObj.optString(this.JSON_WEATHER_DESCRIPTION, null);
|
||||
this.icon = jsonObj.optString(this.JSON_WEATHER_ICON, null);
|
||||
this.id = jsonObj.optInt(JSON_WEATHER_ID, Integer.MIN_VALUE);
|
||||
this.name = jsonObj.optString(JSON_WEATHER_MAIN, null);
|
||||
this.description = jsonObj.optString(JSON_WEATHER_DESCRIPTION, null);
|
||||
this.icon = jsonObj.optString(JSON_WEATHER_ICON, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -407,7 +400,7 @@ public abstract class AbstractWeather extends AbstractResponse {
|
|||
* @return <code>true</code> if data available, otherwise <code>false</code>.
|
||||
*/
|
||||
public boolean hasWeatherCode() {
|
||||
return (this.id != Integer.MIN_VALUE);
|
||||
return this.id != Integer.MIN_VALUE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -416,7 +409,7 @@ public abstract class AbstractWeather extends AbstractResponse {
|
|||
* @return <code>true</code> if data available, otherwise <code>false</code>.
|
||||
*/
|
||||
public boolean hasWeatherName() {
|
||||
return (this.name != null && (!this.name.equals("")));
|
||||
return this.name != null && (! "".equals(this.name));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -425,7 +418,7 @@ public abstract class AbstractWeather extends AbstractResponse {
|
|||
* @return <code>true</code> if data available, otherwise <code>false</code>.
|
||||
*/
|
||||
public boolean hasWeatherDescription() {
|
||||
return (this.description != null && (!this.description.equals("")));
|
||||
return this.description != null && (! "".equals(this.description));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -434,7 +427,7 @@ public abstract class AbstractWeather extends AbstractResponse {
|
|||
* @return <code>true</code> if data available, otherwise <code>false</code>.
|
||||
*/
|
||||
public boolean hasWeatherIconName() {
|
||||
return (this.icon != null && (!this.icon.equals("")));
|
||||
return this.icon != null && (! "".equals(this.icon));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -488,8 +481,8 @@ public abstract class AbstractWeather extends AbstractResponse {
|
|||
}
|
||||
|
||||
Wind(JSONObject jsonObj) {
|
||||
this.speed = (float) jsonObj.optDouble(this.JSON_WIND_SPEED, Double.NaN);
|
||||
this.degree = (float) jsonObj.optDouble(this.JSON_WIND_DEGREE, Double.NaN);
|
||||
this.speed = (float) jsonObj.optDouble(JSON_WIND_SPEED, Double.NaN);
|
||||
this.degree = (float) jsonObj.optDouble(JSON_WIND_DEGREE, Double.NaN);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -498,7 +491,7 @@ public abstract class AbstractWeather extends AbstractResponse {
|
|||
* @return <code>true</code> if data available, otherwise <code>false</code>.
|
||||
*/
|
||||
public boolean hasWindSpeed() {
|
||||
return (this.speed != Float.NaN);
|
||||
return !Float.isNaN(this.speed);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -507,7 +500,7 @@ public abstract class AbstractWeather extends AbstractResponse {
|
|||
* @return <code>true</code> if data available, otherwise <code>false</code>.
|
||||
*/
|
||||
public boolean hasWindDegree() {
|
||||
return (this.hasWindSpeed() && (this.degree != Float.NaN));
|
||||
return this.hasWindSpeed() && (! Float.isNaN(this.degree));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -63,9 +63,9 @@ public class DailyForecast extends AbstractForecast {
|
|||
DailyForecast(JSONObject jsonObj) {
|
||||
super(jsonObj);
|
||||
|
||||
JSONArray dataArray = (jsonObj != null) ? jsonObj.optJSONArray(this.JSON_FORECAST_LIST) : new JSONArray();
|
||||
JSONArray dataArray = (jsonObj != null) ? jsonObj.optJSONArray(JSON_FORECAST_LIST) : new JSONArray();
|
||||
this.forecastList = (dataArray != null) ? new ArrayList<Forecast>(dataArray.length()) : Collections.EMPTY_LIST;
|
||||
if (this.forecastList != Collections.EMPTY_LIST) {
|
||||
if (dataArray != null && this.forecastList != Collections.EMPTY_LIST) {
|
||||
for (int i = 0; i < dataArray.length(); i++) {
|
||||
JSONObject forecastObj = dataArray.optJSONObject(i);
|
||||
if (forecastObj != null) {
|
||||
|
@ -103,15 +103,15 @@ public class DailyForecast extends AbstractForecast {
|
|||
/*
|
||||
JSON Keys
|
||||
*/
|
||||
public final String JSON_TEMP = "temp";
|
||||
public static final String JSON_TEMP = "temp";
|
||||
|
||||
private final String JSON_FORECAST_PRESSURE = "pressure";
|
||||
private final String JSON_FORECAST_HUMIDITY = "humidity";
|
||||
private final String JSON_FORECAST_WIND_SPEED = "speed";
|
||||
private final String JSON_FORECAST_WIND_DEGREE = "deg";
|
||||
private final String JSON_FORECAST_CLOUDS = "clouds";
|
||||
private final String JSON_FORECAST_RAIN = "rain";
|
||||
private final String JSON_FORECAST_SNOW = "snow";
|
||||
private static final String JSON_FORECAST_PRESSURE = "pressure";
|
||||
private static final String JSON_FORECAST_HUMIDITY = "humidity";
|
||||
private static final String JSON_FORECAST_WIND_SPEED = "speed";
|
||||
private static final String JSON_FORECAST_WIND_DEGREE = "deg";
|
||||
private static final String JSON_FORECAST_CLOUDS = "clouds";
|
||||
private static final String JSON_FORECAST_RAIN = "rain";
|
||||
private static final String JSON_FORECAST_SNOW = "snow";
|
||||
|
||||
/*
|
||||
Instance Variables
|
||||
|
@ -146,44 +146,44 @@ public class DailyForecast extends AbstractForecast {
|
|||
Forecast(JSONObject jsonObj) {
|
||||
super(jsonObj);
|
||||
|
||||
JSONObject jsonObjTemp = (jsonObj != null) ? jsonObj.optJSONObject(this.JSON_TEMP) : null;
|
||||
JSONObject jsonObjTemp = (jsonObj != null) ? jsonObj.optJSONObject(JSON_TEMP) : null;
|
||||
this.temp = (jsonObjTemp != null) ? new Temperature(jsonObjTemp) : new Temperature();
|
||||
|
||||
this.humidity = (jsonObj != null) ? (float) jsonObj.optDouble(this.JSON_FORECAST_HUMIDITY, Double.NaN) : Float.NaN;
|
||||
this.pressure = (jsonObj != null) ? (float) jsonObj.optDouble(this.JSON_FORECAST_PRESSURE, Double.NaN) : Float.NaN;
|
||||
this.windSpeed = (jsonObj != null) ? (float) jsonObj.optDouble(this.JSON_FORECAST_WIND_SPEED, Double.NaN) : Float.NaN;
|
||||
this.windDegree = (jsonObj != null) ? (float) jsonObj.optDouble(this.JSON_FORECAST_WIND_DEGREE, Double.NaN) : Float.NaN;
|
||||
this.cloudsPercent = (jsonObj != null) ? (float) jsonObj.optDouble(this.JSON_FORECAST_CLOUDS, Double.NaN) : Float.NaN;
|
||||
this.rain = (jsonObj != null) ? (float) jsonObj.optDouble(this.JSON_FORECAST_RAIN, Double.NaN) : Float.NaN;
|
||||
this.snow = (jsonObj != null) ? (float) jsonObj.optDouble(this.JSON_FORECAST_SNOW, Double.NaN) : Float.NaN;
|
||||
this.humidity = (jsonObj != null) ? (float) jsonObj.optDouble(JSON_FORECAST_HUMIDITY, Double.NaN) : Float.NaN;
|
||||
this.pressure = (jsonObj != null) ? (float) jsonObj.optDouble(JSON_FORECAST_PRESSURE, Double.NaN) : Float.NaN;
|
||||
this.windSpeed = (jsonObj != null) ? (float) jsonObj.optDouble(JSON_FORECAST_WIND_SPEED, Double.NaN) : Float.NaN;
|
||||
this.windDegree = (jsonObj != null) ? (float) jsonObj.optDouble(JSON_FORECAST_WIND_DEGREE, Double.NaN) : Float.NaN;
|
||||
this.cloudsPercent = (jsonObj != null) ? (float) jsonObj.optDouble(JSON_FORECAST_CLOUDS, Double.NaN) : Float.NaN;
|
||||
this.rain = (jsonObj != null) ? (float) jsonObj.optDouble(JSON_FORECAST_RAIN, Double.NaN) : Float.NaN;
|
||||
this.snow = (jsonObj != null) ? (float) jsonObj.optDouble(JSON_FORECAST_SNOW, Double.NaN) : Float.NaN;
|
||||
}
|
||||
|
||||
public boolean hasHumidity() {
|
||||
return (this.humidity != Float.NaN);
|
||||
return !Float.isNaN(this.humidity);
|
||||
}
|
||||
|
||||
public boolean hasPressure() {
|
||||
return (this.pressure != Float.NaN);
|
||||
return !Float.isNaN(this.pressure);
|
||||
}
|
||||
|
||||
public boolean hasWindSpeed() {
|
||||
return (this.windSpeed != Float.NaN);
|
||||
return !Float.isNaN(this.windSpeed);
|
||||
}
|
||||
|
||||
public boolean hasWindDegree() {
|
||||
return (this.windDegree != Float.NaN);
|
||||
return !Float.isNaN(this.windDegree);
|
||||
}
|
||||
|
||||
public boolean hasPercentageOfClouds() {
|
||||
return (this.cloudsPercent != Float.NaN);
|
||||
return !Float.isNaN(this.cloudsPercent);
|
||||
}
|
||||
|
||||
public boolean hasRain() {
|
||||
return (this.rain != Float.NaN);
|
||||
return !Float.isNaN(this.rain);
|
||||
}
|
||||
|
||||
public boolean hasSnow() {
|
||||
return (this.snow != Float.NaN);
|
||||
return !Float.isNaN(this.snow);
|
||||
}
|
||||
|
||||
public float getHumidity() {
|
||||
|
@ -235,12 +235,12 @@ public class DailyForecast extends AbstractForecast {
|
|||
* </p>
|
||||
*/
|
||||
public static class Temperature implements Serializable {
|
||||
public final String JSON_TEMP_DAY = "day";
|
||||
public final String JSON_TEMP_MIN = "min";
|
||||
public final String JSON_TEMP_MAX = "max";
|
||||
public final String JSON_TEMP_NIGHT = "night";
|
||||
public final String JSON_TEMP_EVENING = "eve";
|
||||
public final String JSON_TEMP_MORNING = "morn";
|
||||
private static final String JSON_TEMP_DAY = "day";
|
||||
private static final String JSON_TEMP_MIN = "min";
|
||||
private static final String JSON_TEMP_MAX = "max";
|
||||
private static final String JSON_TEMP_NIGHT = "night";
|
||||
private static final String JSON_TEMP_EVENING = "eve";
|
||||
private static final String JSON_TEMP_MORNING = "morn";
|
||||
|
||||
private final float dayTemp;
|
||||
private final float minTemp;
|
||||
|
@ -259,36 +259,36 @@ public class DailyForecast extends AbstractForecast {
|
|||
}
|
||||
|
||||
Temperature(JSONObject jsonObj) {
|
||||
this.dayTemp = (jsonObj != null) ? (float) jsonObj.optDouble(this.JSON_TEMP_DAY, Double.NaN) : Float.NaN;
|
||||
this.minTemp = (jsonObj != null) ? (float) jsonObj.optDouble(this.JSON_TEMP_MIN, Double.NaN) : Float.NaN;
|
||||
this.maxTemp = (jsonObj != null) ? (float) jsonObj.optDouble(this.JSON_TEMP_MAX, Double.NaN) : Float.NaN;
|
||||
this.nightTemp = (jsonObj != null) ? (float) jsonObj.optDouble(this.JSON_TEMP_NIGHT, Double.NaN) : Float.NaN;
|
||||
this.eveTemp = (jsonObj != null) ? (float) jsonObj.optDouble(this.JSON_TEMP_EVENING, Double.NaN) : Float.NaN;
|
||||
this.mornTemp = (jsonObj != null) ? (float) jsonObj.optDouble(this.JSON_TEMP_MORNING, Double.NaN) : Float.NaN;
|
||||
this.dayTemp = (jsonObj != null) ? (float) jsonObj.optDouble(JSON_TEMP_DAY, Double.NaN) : Float.NaN;
|
||||
this.minTemp = (jsonObj != null) ? (float) jsonObj.optDouble(JSON_TEMP_MIN, Double.NaN) : Float.NaN;
|
||||
this.maxTemp = (jsonObj != null) ? (float) jsonObj.optDouble(JSON_TEMP_MAX, Double.NaN) : Float.NaN;
|
||||
this.nightTemp = (jsonObj != null) ? (float) jsonObj.optDouble(JSON_TEMP_NIGHT, Double.NaN) : Float.NaN;
|
||||
this.eveTemp = (jsonObj != null) ? (float) jsonObj.optDouble(JSON_TEMP_EVENING, Double.NaN) : Float.NaN;
|
||||
this.mornTemp = (jsonObj != null) ? (float) jsonObj.optDouble(JSON_TEMP_MORNING, Double.NaN) : Float.NaN;
|
||||
}
|
||||
|
||||
public boolean hasDayTemperature() {
|
||||
return (this.dayTemp != Float.NaN);
|
||||
return !Float.isNaN(this.dayTemp);
|
||||
}
|
||||
|
||||
public boolean hasMinimumTemperature() {
|
||||
return (this.minTemp != Float.NaN);
|
||||
return !Float.isNaN(this.minTemp);
|
||||
}
|
||||
|
||||
public boolean hasMaximumTemperature() {
|
||||
return (this.maxTemp != Float.NaN);
|
||||
return !Float.isNaN(this.maxTemp);
|
||||
}
|
||||
|
||||
public boolean hasNightTemperature() {
|
||||
return (this.nightTemp != Float.NaN);
|
||||
return !Float.isNaN(this.nightTemp);
|
||||
}
|
||||
|
||||
public boolean hasEveningTemperature() {
|
||||
return (this.eveTemp != Float.NaN);
|
||||
return !Float.isNaN(this.eveTemp);
|
||||
}
|
||||
|
||||
public boolean hasMorningTemperature() {
|
||||
return (this.mornTemp != Float.NaN);
|
||||
return !Float.isNaN(this.mornTemp);
|
||||
}
|
||||
|
||||
public float getDayTemperature() {
|
||||
|
|
|
@ -65,7 +65,7 @@ public class HourlyForecast extends AbstractForecast {
|
|||
|
||||
JSONArray forecastArr = (jsonObj != null) ? jsonObj.optJSONArray(this.JSON_FORECAST_LIST) : new JSONArray();
|
||||
this.forecastList = (forecastArr != null) ? new ArrayList<Forecast>(forecastArr.length()) : Collections.EMPTY_LIST;
|
||||
if (this.forecastList != Collections.EMPTY_LIST) {
|
||||
if (forecastArr != null && this.forecastList != Collections.EMPTY_LIST) {
|
||||
for (int i = 0; i < forecastArr.length(); i++) {
|
||||
JSONObject forecastObj = forecastArr.optJSONObject(i);
|
||||
if (forecastObj != null) {
|
||||
|
@ -103,8 +103,8 @@ public class HourlyForecast extends AbstractForecast {
|
|||
/*
|
||||
JSON Keys
|
||||
*/
|
||||
private final String JSON_SYS = "sys";
|
||||
private final String JSON_DT_TEXT = "dt_txt";
|
||||
private static final String JSON_SYS = "sys";
|
||||
private static final String JSON_DT_TEXT = "dt_txt";
|
||||
|
||||
/*
|
||||
Instance Variables
|
||||
|
@ -122,51 +122,51 @@ public class HourlyForecast extends AbstractForecast {
|
|||
Forecast(JSONObject jsonObj) {
|
||||
super(jsonObj);
|
||||
|
||||
this.dateTimeText = (jsonObj != null) ? jsonObj.optString(this.JSON_DT_TEXT, null) : null;
|
||||
this.dateTimeText = (jsonObj != null) ? jsonObj.optString(JSON_DT_TEXT, null) : null;
|
||||
|
||||
JSONObject jsonObjClouds = (jsonObj != null) ? jsonObj.optJSONObject(this.JSON_CLOUDS) : null;
|
||||
JSONObject jsonObjClouds = (jsonObj != null) ? jsonObj.optJSONObject(JSON_CLOUDS) : null;
|
||||
this.clouds = (jsonObjClouds != null) ? new Clouds(jsonObjClouds) : null;
|
||||
|
||||
JSONObject jsonObjMain = (jsonObj != null) ? jsonObj.optJSONObject(this.JSON_MAIN) : null;
|
||||
JSONObject jsonObjMain = (jsonObj != null) ? jsonObj.optJSONObject(JSON_MAIN) : null;
|
||||
this.main = (jsonObjMain != null) ? new Main(jsonObjMain) : null;
|
||||
|
||||
JSONObject jsonObjSys = (jsonObj != null) ? jsonObj.optJSONObject(this.JSON_SYS) : null;
|
||||
JSONObject jsonObjSys = (jsonObj != null) ? jsonObj.optJSONObject(JSON_SYS) : null;
|
||||
this.sys = (jsonObjSys != null) ? new Sys(jsonObjSys) : null;
|
||||
|
||||
JSONObject jsonObjWind = (jsonObj != null) ? jsonObj.optJSONObject(this.JSON_WIND) : null;
|
||||
JSONObject jsonObjWind = (jsonObj != null) ? jsonObj.optJSONObject(JSON_WIND) : null;
|
||||
this.wind = (jsonObjWind != null) ? new Wind(jsonObjWind) : null;
|
||||
}
|
||||
|
||||
public boolean hasDateTimeText() {
|
||||
return (this.dateTimeText != null);
|
||||
return this.dateTimeText != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>true</code> if Clouds instance is available, otherwise <code>false</code>.
|
||||
*/
|
||||
public boolean hasCloudsInstance() {
|
||||
return (clouds != null);
|
||||
return clouds != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>true</code> if Main instance is available, otherwise <code>false</code>.
|
||||
*/
|
||||
public boolean hasMainInstance() {
|
||||
return (main != null);
|
||||
return main != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>true</code> if Sys instance is available, otherwise <code>false</code>.
|
||||
*/
|
||||
public boolean hasSysInstance() {
|
||||
return (sys != null);
|
||||
return sys != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>true</code> if Wind instance is available, otherwise <code>false</code>.
|
||||
*/
|
||||
public boolean hasWindInstance() {
|
||||
return (wind != null);
|
||||
return wind != null;
|
||||
}
|
||||
|
||||
public String getDateTimeText() {
|
||||
|
@ -253,9 +253,9 @@ public class HourlyForecast extends AbstractForecast {
|
|||
* @since 2.5.0.1
|
||||
*/
|
||||
public static class Main extends AbstractForecast.Forecast.Main {
|
||||
private final String JSON_MAIN_SEA_LEVEL = "sea_level";
|
||||
private final String JSON_MAIN_GRND_LEVEL = "grnd_level";
|
||||
private final String JSON_MAIN_TMP_KF = "temp_kf";
|
||||
private static final String JSON_MAIN_SEA_LEVEL = "sea_level";
|
||||
private static final String JSON_MAIN_GRND_LEVEL = "grnd_level";
|
||||
private static final String JSON_MAIN_TMP_KF = "temp_kf";
|
||||
|
||||
private final float seaLevel;
|
||||
private final float groundLevel;
|
||||
|
@ -272,21 +272,21 @@ public class HourlyForecast extends AbstractForecast {
|
|||
Main(JSONObject jsonObj) {
|
||||
super(jsonObj);
|
||||
|
||||
this.seaLevel = (jsonObj != null) ? (float) jsonObj.optDouble(this.JSON_MAIN_SEA_LEVEL, Float.NaN) : Float.NaN;
|
||||
this.groundLevel = (jsonObj != null) ? (float) jsonObj.optDouble(this.JSON_MAIN_GRND_LEVEL, Float.NaN) : Float.NaN;
|
||||
this.tempKF = (jsonObj != null) ? (float) jsonObj.optDouble(this.JSON_MAIN_TMP_KF, Float.NaN) : Float.NaN;
|
||||
this.seaLevel = (jsonObj != null) ? (float) jsonObj.optDouble(JSON_MAIN_SEA_LEVEL, Float.NaN) : Float.NaN;
|
||||
this.groundLevel = (jsonObj != null) ? (float) jsonObj.optDouble(JSON_MAIN_GRND_LEVEL, Float.NaN) : Float.NaN;
|
||||
this.tempKF = (jsonObj != null) ? (float) jsonObj.optDouble(JSON_MAIN_TMP_KF, Float.NaN) : Float.NaN;
|
||||
}
|
||||
|
||||
public boolean hasSeaLevel() {
|
||||
return (this.seaLevel != Float.NaN);
|
||||
return !Float.isNaN(this.seaLevel);
|
||||
}
|
||||
|
||||
public boolean hasGroundLevel() {
|
||||
return (this.groundLevel != Float.NaN);
|
||||
return !Float.isNaN(this.groundLevel);
|
||||
}
|
||||
|
||||
public boolean hasTempKF() {
|
||||
return (this.tempKF != Float.NaN);
|
||||
return !Float.isNaN(this.tempKF);
|
||||
}
|
||||
|
||||
public float getSeaLevel() {
|
||||
|
@ -323,7 +323,8 @@ public class HourlyForecast extends AbstractForecast {
|
|||
* @since 2.5.0.1
|
||||
*/
|
||||
public static class Sys implements Serializable {
|
||||
private final String JSON_SYS_POD = "pod";
|
||||
private static final String JSON_SYS_POD = "pod";
|
||||
|
||||
private final String pod;
|
||||
|
||||
Sys() {
|
||||
|
@ -331,11 +332,11 @@ public class HourlyForecast extends AbstractForecast {
|
|||
}
|
||||
|
||||
Sys(JSONObject jsonObj) {
|
||||
this.pod = (jsonObj != null) ? jsonObj.optString(this.JSON_SYS_POD, null) : null;
|
||||
this.pod = (jsonObj != null) ? jsonObj.optString(JSON_SYS_POD, null) : null;
|
||||
}
|
||||
|
||||
public boolean hasPod() {
|
||||
return (this.pod != null && (!this.pod.equals("")));
|
||||
return this.pod != null && (! "".equals(this.pod));
|
||||
}
|
||||
|
||||
public String getPod() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue