diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..74c5741 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,9 @@ +Copyright (C)2013 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 shall be used for Good, not Evil. + +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. \ No newline at end of file diff --git a/README.pdf b/README.pdf new file mode 100644 index 0000000..e70f7b2 Binary files /dev/null and b/README.pdf differ diff --git a/javadoc/allclasses-frame.html b/javadoc/allclasses-frame.html new file mode 100644 index 0000000..9e6f1f3 --- /dev/null +++ b/javadoc/allclasses-frame.html @@ -0,0 +1,54 @@ + + + +
+ + +Modifier and Type | +Constant Field | +Value | +
---|---|---|
+
+protected final java.lang.String |
+JSON_CLOUDS |
+"clouds" |
+
+
+protected final java.lang.String |
+JSON_COORD |
+"coord" |
+
+
+private final java.lang.String |
+JSON_DATE_TIME |
+"dt" |
+
+
+protected final java.lang.String |
+JSON_MAIN |
+"main" |
+
+
+protected final java.lang.String |
+JSON_WEATHER |
+"weather" |
+
+
+protected final java.lang.String |
+JSON_WIND |
+"wind" |
+
Modifier and Type | +Constant Field | +Value | +
---|---|---|
+
+private final java.lang.String |
+JSON_CLOUDS_ALL |
+"all" |
+
Modifier and Type | +Constant Field | +Value | +
---|---|---|
+
+private final java.lang.String |
+JSON_COORD_LATITUDE |
+"lat" |
+
+
+private final java.lang.String |
+JSON_COORD_LONGITUDE |
+"lon" |
+
Modifier and Type | +Constant Field | +Value | +
---|---|---|
+
+private final java.lang.String |
+JSON_MAIN_HUMIDITY |
+"humidity" |
+
+
+private final java.lang.String |
+JSON_MAIN_PRESSURE |
+"pressure" |
+
+
+private final java.lang.String |
+JSON_MAIN_TEMP |
+"temp" |
+
+
+private final java.lang.String |
+JSON_MAIN_TEMP_MAX |
+"temp_max" |
+
+
+private final java.lang.String |
+JSON_MAIN_TEMP_MIN |
+"temp_min" |
+
Modifier and Type | +Constant Field | +Value | +
---|---|---|
+
+private final java.lang.String |
+JSON_WEATHER_DESCRIPTION |
+"description" |
+
+
+private final java.lang.String |
+JSON_WEATHER_ICON |
+"icon" |
+
+
+private final java.lang.String |
+JSON_WEATHER_ID |
+"id" |
+
+
+private final java.lang.String |
+JSON_WEATHER_MAIN |
+"main" |
+
Modifier and Type | +Constant Field | +Value | +
---|---|---|
+
+private final java.lang.String |
+JSON_WIND_DEGREE |
+"deg" |
+
+
+private final java.lang.String |
+JSON_WIND_SPEED |
+"speed" |
+
Modifier and Type | +Constant Field | +Value | +
---|---|---|
+
+private final java.lang.String |
+JSON_BASE |
+"base" |
+
+
+private final java.lang.String |
+JSON_CITY_ID |
+"id" |
+
+
+private final java.lang.String |
+JSON_CITY_NAME |
+"name" |
+
+
+private final java.lang.String |
+JSON_RAIN |
+"rain" |
+
+
+private final java.lang.String |
+JSON_RESPONSE_CODE |
+"cod" |
+
+
+private final java.lang.String |
+JSON_SYS |
+"sys" |
+
Modifier and Type | +Constant Field | +Value | +
---|---|---|
+
+private final java.lang.String |
+JSON_RAIN_3HOURS |
+"3h" |
+
Modifier and Type | +Constant Field | +Value | +
---|---|---|
+
+private final java.lang.String |
+JSON_SYS_COUNTRY_CODE |
+"country" |
+
+
+private final java.lang.String |
+JSON_SYS_SUNRISE |
+"sunrise" |
+
+
+private final java.lang.String |
+JSON_SYS_SUNSET |
+"sunset" |
+
Modifier and Type | +Constant Field | +Value | +
---|---|---|
+
+private final java.lang.String |
+JSON_WIND_GUST |
+"gust" |
+
Modifier and Type | +Constant Field | +Value | +
---|---|---|
+
+private final java.lang.String |
+JSON_CITY |
+"city" |
+
+
+private final java.lang.String |
+JSON_FORECAST_LIST |
+"list" |
+
+
+private final java.lang.String |
+JSON_RESPONSE_CODE |
+"cod" |
+
+
+private final java.lang.String |
+JSON_RESPONSE_FORECAST_COUNT |
+"cnt" |
+
+
+private final java.lang.String |
+JSON_RESPONSE_TIME |
+"message" |
+
Modifier and Type | +Constant Field | +Value | +
---|---|---|
+
+private final java.lang.String |
+JSON_CITY_COORD |
+"coord" |
+
+
+private final java.lang.String |
+JSON_CITY_COUNTRY_CODE |
+"country" |
+
+
+private final java.lang.String |
+JSON_CITY_ID |
+"id" |
+
+
+private final java.lang.String |
+JSON_CITY_NAME |
+"name" |
+
+
+private final java.lang.String |
+JSON_CITY_POPULATION |
+"population" |
+
Modifier and Type | +Constant Field | +Value | +
---|---|---|
+
+private final java.lang.String |
+JSON_FORECAST_CLOUDS |
+"clouds" |
+
+
+private final java.lang.String |
+JSON_FORECAST_HUMIDITY |
+"humidity" |
+
+
+private final java.lang.String |
+JSON_FORECAST_PRESSURE |
+"pressure" |
+
+
+private final java.lang.String |
+JSON_FORECAST_WIND_DEGREE |
+"deg" |
+
+
+private final java.lang.String |
+JSON_FORECAST_WIND_SPEED |
+"speed" |
+
+
+public final java.lang.String |
+JSON_TEMP |
+"temp" |
+
Modifier and Type | +Constant Field | +Value | +
---|---|---|
+
+public final java.lang.String |
+JSON_TEMP_DAY |
+"day" |
+
+
+public final java.lang.String |
+JSON_TEMP_EVENING |
+"eve" |
+
+
+public final java.lang.String |
+JSON_TEMP_MAX |
+"max" |
+
+
+public final java.lang.String |
+JSON_TEMP_MIN |
+"min" |
+
+
+public final java.lang.String |
+JSON_TEMP_MORNING |
+"morn" |
+
+
+public final java.lang.String |
+JSON_TEMP_NIGHT |
+"night" |
+
Modifier and Type | +Constant Field | +Value | +
---|---|---|
+
+private final java.lang.String |
+JSON_CITY |
+"city" |
+
+
+private final java.lang.String |
+JSON_FORECAST_LIST |
+"list" |
+
+
+private final java.lang.String |
+JSON_RESPONSE_CODE |
+"cod" |
+
+
+private final java.lang.String |
+JSON_RESPONSE_FORECAST_COUNT |
+"cnt" |
+
+
+private final java.lang.String |
+JSON_RESPONSE_TIME |
+"message" |
+
Modifier and Type | +Constant Field | +Value | +
---|---|---|
+
+private final java.lang.String |
+JSON_CITY_COORD |
+"coord" |
+
+
+private final java.lang.String |
+JSON_CITY_COUNTRY_CODE |
+"country" |
+
+
+private final java.lang.String |
+JSON_CITY_ID |
+"id" |
+
+
+private final java.lang.String |
+JSON_CITY_NAME |
+"name" |
+
+
+private final java.lang.String |
+JSON_CITY_POPULATION |
+"population" |
+
Modifier and Type | +Constant Field | +Value | +
---|---|---|
+
+private final java.lang.String |
+JSON_DATE_TIME_TEXT |
+"dt_txt" |
+
+
+private final java.lang.String |
+JSON_SYS |
+"sys" |
+
Modifier and Type | +Constant Field | +Value | +
---|---|---|
+
+private final java.lang.String |
+JSON_MAIN_GRND_LEVEL |
+"grnd_level" |
+
+
+private final java.lang.String |
+JSON_MAIN_SEA_LEVEL |
+"sea_level" |
+
+
+private final java.lang.String |
+JSON_MAIN_TMP_KF |
+"temp_kf" |
+
Modifier and Type | +Constant Field | +Value | +
---|---|---|
+
+private final java.lang.String |
+JSON_SYS_POD |
+"pod" |
+
Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:
+Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:
+Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
+Each annotation type has its own separate page with the following sections:
+Each enum has its own separate page with the following sections:
+Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.
+There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object
. The interfaces do not inherit from java.lang.Object
.
The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
+The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
+These links take you to the next or previous class, interface, package, or related page.
+These links show and hide the HTML frames. All pages are available with or without frames.
+The All Classes link shows all classes and interfaces except non-static nested types.
+Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.
+The Constant Field Values page lists the static final fields and their values.
+CurrentWeatherData
+ and ForecastWeatherData
classes.Clouds
.Coord
.Main
.Weather
.Wind
.Base
Country code of city
Country code of city
City code (ID)
City code (ID)
City code (ID)
City name
City name
City name
Population of city
Population of city
Clouds -> All
+ (percentage of all clouds)Coord -> Latitude
Coord -> Longitude
Date time text
Percentage of clouds
Humidity
Pressure
Wind degree
Wind speed
Main -> Ground level
Main -> Humidity
Main -> Pressure
Main -> Sea level
Main -> Temperature
Main -> Maximum temperature
Main -> Minimum temperature
Main -> Temperature KF
Rain -> Rain per 3 hours
Response code
Response code
Response code
Forecast count
Forecast count
Response time
Response time
Sys -> Country
Sys -> Pod
Sys -> Sunrise
Sys -> Sunset
Temp -> Day
Temp -> Evening
Temp -> Maximum
Temp -> Minimum
Temp -> Morning
Temp -> Night
Weather -> Description
Weather -> Icon
Weather -> ID
Weather -> Main (name of weather)
Wind -> Degree
Wind -> Gust
Wind -> Speed
public abstract static class AbstractWeatherData.Clouds
+extends java.lang.Object
+Clouds
.
+ Standard behaviors like the has
and the get
+ methods for information about clouds (for example, percentage of
+ clouds, etc.) are defined here.Modifier and Type | +Field and Description | +
---|---|
private java.lang.String |
+JSON_CLOUDS_ALL
+Key for JSON variable
+Clouds -> All
+ (percentage of all clouds) |
+
private float |
+percentOfClouds
+Percentage of all clouds
+ |
+
Constructor and Description | +
---|
AbstractWeatherData.Clouds()
+Non-parameterized constructor
+ |
+
AbstractWeatherData.Clouds(org.json.JSONObject jsonObj)
+Parameterized constructor
+
+ Initializes variables from values from the given JSON object.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
float |
+getPercentageOfClouds()
+Returns data for percentage of all clouds.
+ |
+
boolean |
+hasPercentageOfClouds()
+Tells if the data for percentage of all clouds is available or not.
+ |
+
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
private final java.lang.String JSON_CLOUDS_ALL+
Clouds -> All
+ (percentage of all clouds)private final float percentOfClouds+
public AbstractWeatherData.Clouds()+
Initializes variables as per following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
public AbstractWeatherData.Clouds(org.json.JSONObject jsonObj)+
jsonObj
- JSON object containing data about cloudspublic boolean hasPercentageOfClouds()+
true
if data available, otherwise false
public float getPercentageOfClouds()+
Float.NaN
, i.e., Not a Number.public abstract static class AbstractWeatherData.Coord
+extends java.lang.Object
+Coord
.
+ Standard behaviors like the has
and the get
+ methods for information about geographic coordinates (latitude
+ and longitude) are defined here.Modifier and Type | +Field and Description | +
---|---|
private java.lang.String |
+JSON_COORD_LATITUDE
+Key for JSON variable
+Coord -> Latitude |
+
private java.lang.String |
+JSON_COORD_LONGITUDE
+Key for JSON variable
+Coord -> Longitude |
+
private float |
+lat
+Latitude
+ |
+
private float |
+lon
+Longitude
+ |
+
Constructor and Description | +
---|
AbstractWeatherData.Coord()
+Non-parameterized constructor
+ |
+
AbstractWeatherData.Coord(org.json.JSONObject jsonObj)
+Parameterized constructor
+
+ Initializes variables from values from the given JSON object.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
float |
+getLatitude()
+Returns data for latitude of the city.
+ |
+
float |
+getLongitude()
+Returns data for longitude of the city.
+ |
+
boolean |
+hasLatitude()
+Tells if the data for latitude of the city is available or not.
+ |
+
boolean |
+hasLongitude()
+Tells if the data for longitude of the city is available or not.
+ |
+
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
private final java.lang.String JSON_COORD_LATITUDE+
Coord -> Latitude
private final java.lang.String JSON_COORD_LONGITUDE+
Coord -> Longitude
private final float lat+
private final float lon+
public AbstractWeatherData.Coord()+
Initializes variables as per following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
public AbstractWeatherData.Coord(org.json.JSONObject jsonObj)+
jsonObj
- JSON object containing data about coordinatespublic boolean hasLatitude()+
true
if data available, otherwise false
public boolean hasLongitude()+
true
if data available, otherwise false
public float getLatitude()+
Float.NaN
, i.e., Not a Number.public float getLongitude()+
Float.NaN
, i.e., Not a Number.public abstract static class AbstractWeatherData.Main
+extends java.lang.Object
+Main
.
+ Standard behaviors like the has
and the get
+ methods for information about main weather elements (for example,
+ temperature, pressure, humidity, etc.) are defined here.Modifier and Type | +Field and Description | +
---|---|
private float |
+humidity
+Humidity
+ |
+
private java.lang.String |
+JSON_MAIN_HUMIDITY
+Key for JSON variable
+Main -> Humidity |
+
private java.lang.String |
+JSON_MAIN_PRESSURE
+Key for JSON variable
+Main -> Pressure |
+
private java.lang.String |
+JSON_MAIN_TEMP
+Key for JSON variable
+Main -> Temperature |
+
private java.lang.String |
+JSON_MAIN_TEMP_MAX
+Key for JSON variable
+Main -> Maximum temperature |
+
private java.lang.String |
+JSON_MAIN_TEMP_MIN
+Key for JSON variable
+Main -> Minimum temperature |
+
private float |
+maxTemp
+Maximum temperature
+ |
+
private float |
+minTemp
+Minimum temperature
+ |
+
private float |
+pressure
+Pressure
+ |
+
private float |
+temp
+Temperature
+ |
+
Constructor and Description | +
---|
AbstractWeatherData.Main()
+Non-parameterized constructor
+ |
+
AbstractWeatherData.Main(org.json.JSONObject jsonObj)
+Parameterized constructor
+
+ Initializes variables from values from the given JSON object.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
float |
+getHumidity()
+Returns data for humidity of the city.
+ |
+
float |
+getMaxTemperature()
+Returns data for maximum temperature of the city.
+ |
+
float |
+getMinTemperature()
+Returns data for minimum temperature of the city.
+ |
+
float |
+getPressure()
+Returns data for pressure of the city.
+ |
+
float |
+getTemperature()
+Returns data for temperature of the city.
+ |
+
boolean |
+hasHumidity()
+Tells if the data for humidity of the city is available or not.
+ |
+
boolean |
+hasMaxTemperature()
+Tells if the data for maximum temperature of the city is available or not.
+ |
+
boolean |
+hasMinTemperature()
+Tells if the data for minimum temperature of the city is available or not.
+ |
+
boolean |
+hasPressure()
+Tells if the data for pressure of the city is available or not.
+ |
+
boolean |
+hasTemperature()
+Tells if the data for temperature of the city is available or not.
+ |
+
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
private final java.lang.String JSON_MAIN_TEMP+
Main -> Temperature
private final java.lang.String JSON_MAIN_TEMP_MIN+
Main -> Minimum temperature
private final java.lang.String JSON_MAIN_TEMP_MAX+
Main -> Maximum temperature
private final java.lang.String JSON_MAIN_PRESSURE+
Main -> Pressure
private final java.lang.String JSON_MAIN_HUMIDITY+
Main -> Humidity
private final float temp+
private final float minTemp+
private final float maxTemp+
private final float pressure+
private final float humidity+
public AbstractWeatherData.Main()+
Initializes variables as per following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
public AbstractWeatherData.Main(org.json.JSONObject jsonObj)+
jsonObj
- JSON object containing data about main weather
+ elements. For example, temperature, pressure, etc.public boolean hasTemperature()+
true
if data available, otherwise false
public boolean hasMinTemperature()+
true
if data available, otherwise false
public boolean hasMaxTemperature()+
true
if data available, otherwise false
public boolean hasPressure()+
true
if data available, otherwise false
public boolean hasHumidity()+
true
if data available, otherwise false
public float getTemperature()+
Float.NaN
, i.e., Not a Number.public float getMinTemperature()+
Float.NaN
, i.e., Not a Number.public float getMaxTemperature()+
Float.NaN
, i.e., Not a Number.public float getPressure()+
Float.NaN
, i.e., Not a Number.public float getHumidity()+
Float.NaN
, i.e., Not a Number.public abstract static class AbstractWeatherData.Weather
+extends java.lang.Object
+Weather
.
+ Standard behaviors like the has
and the get
+ methods for information about weather (for example, id, name,
+ description, icon, etc.) are defined here.Modifier and Type | +Field and Description | +
---|---|
private java.lang.String |
+description
+Weather description
+ |
+
private java.lang.String |
+icon
+Weather icon
+ |
+
private int |
+id
+Weather ID
+ |
+
private java.lang.String |
+JSON_WEATHER_DESCRIPTION
+Key for JSON variable
+Weather -> Description |
+
private java.lang.String |
+JSON_WEATHER_ICON
+Key for JSON variable in array
+Weather -> Icon |
+
private java.lang.String |
+JSON_WEATHER_ID
+Key for JSON variable in array
+Weather -> ID |
+
private java.lang.String |
+JSON_WEATHER_MAIN
+Key for JSON variable in array
+Weather -> Main (name of weather) |
+
private java.lang.String |
+name
+Weather name
+ |
+
Constructor and Description | +
---|
AbstractWeatherData.Weather()
+Non-parameterized constructor
+ |
+
AbstractWeatherData.Weather(org.json.JSONObject jsonObj)
+Parameterized constructor
+
+ Initializes variables from values from the given JSON object.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
int |
+getWeatherCode()
+Returns data for code for weather of the city.
+ |
+
java.lang.String |
+getWeatherDescription()
+Returns data for description for weather of the city.
+ |
+
java.lang.String |
+getWeatherIconName()
+Returns data for name of icon for weather of the city.
+ |
+
java.lang.String |
+getWeatherName()
+Returns data for name for weather of the city.
+ |
+
boolean |
+hasWeatherCode()
+Tells if the data for weather's code is available or not.
+ |
+
boolean |
+hasWeatherDescription()
+Tells if the data for weather's description is available or not.
+ |
+
boolean |
+hasWeatherIconName()
+Tells if the data for name of weather's icon is available or not.
+ |
+
boolean |
+hasWeatherName()
+Tells if the data for weather's name is available or not.
+ |
+
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
private final java.lang.String JSON_WEATHER_ID+
Weather -> ID
private final java.lang.String JSON_WEATHER_MAIN+
Weather -> Main (name of weather)
private final java.lang.String JSON_WEATHER_DESCRIPTION+
Weather -> Description
private final java.lang.String JSON_WEATHER_ICON+
Weather -> Icon
private final int id+
private final java.lang.String name+
private final java.lang.String description+
private final java.lang.String icon+
public AbstractWeatherData.Weather()+
Initializes variables as per following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
public AbstractWeatherData.Weather(org.json.JSONObject jsonObj)+
jsonObj
- JSON object containing data about weather id, name, etc.public boolean hasWeatherCode()+
true
if data available, otherwise false
public boolean hasWeatherName()+
true
if data available, otherwise false
public boolean hasWeatherDescription()+
true
if data available, otherwise false
public boolean hasWeatherIconName()+
true
if data available, otherwise false
public int getWeatherCode()+
Integer.MIN_VALUE
public java.lang.String getWeatherName()+
null
public java.lang.String getWeatherDescription()+
null
public java.lang.String getWeatherIconName()+
null
public abstract static class AbstractWeatherData.Wind
+extends java.lang.Object
+Wind
.
+ Standard behaviors like the has
and the get
+ methods for information about wind (for example, speed, degree,
+ etc.) are defined here.Modifier and Type | +Field and Description | +
---|---|
private float |
+degree
+Wind degree (direction of wind)
+ |
+
private java.lang.String |
+JSON_WIND_DEGREE
+Key for JSON variable
+Wind -> Degree |
+
private java.lang.String |
+JSON_WIND_SPEED
+Key for JSON variable
+Wind -> Speed |
+
private float |
+speed
+Wind speed
+ |
+
Constructor and Description | +
---|
AbstractWeatherData.Wind()
+Non-parameterized constructor
+ |
+
AbstractWeatherData.Wind(org.json.JSONObject jsonObj)
+Parameterized constructor
+
+ Initializes variables from values from the given JSON object.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
float |
+getWindDegree()
+Returns data for degree of wind in the city.
+ |
+
float |
+getWindSpeed()
+Returns data for speed of wind in the city.
+ |
+
boolean |
+hasWindDegree()
+Tells if the data for degree (degree gives direction) of wind
+ in the city is available or not.
+ |
+
boolean |
+hasWindSpeed()
+Tells if the data for speed of wind in the city is available or not.
+ |
+
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
private final java.lang.String JSON_WIND_SPEED+
Wind -> Speed
private final java.lang.String JSON_WIND_DEGREE+
Wind -> Degree
private final float speed+
private final float degree+
public AbstractWeatherData.Wind()+
Initializes variables as per following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
public AbstractWeatherData.Wind(org.json.JSONObject jsonObj)+
jsonObj
- JSON object containing data about windpublic boolean hasWindSpeed()+
true
if data available, otherwise false
public boolean hasWindDegree()+
true
if data available, otherwise false
public float getWindSpeed()+
Float.NaN
, i.e., Not a Number.public float getWindDegree()+
Float.NaN
, i.e., Not a Number.public abstract class AbstractWeatherData
+extends java.lang.Object
+CurrentWeatherData
+ and ForecastWeatherData
classes.
+ Standard behaviors like the has
and the get
+ methods for information about weather or forecast (for example,
+ temperature, pressure, weather, clouds, wind, etc.) are defined here.Modifier and Type | +Class and Description | +
---|---|
static class |
+AbstractWeatherData.Clouds
+This class provides default implementations for
+Clouds . |
+
static class |
+AbstractWeatherData.Coord
+This class provides default implementations for
+Coord . |
+
static class |
+AbstractWeatherData.Main
+This class provides default implementations for
+Main . |
+
static class |
+AbstractWeatherData.Weather
+This class provides default implementations for
+Weather . |
+
static class |
+AbstractWeatherData.Wind
+This class provides default implementations for
+Wind . |
+
Modifier and Type | +Field and Description | +
---|---|
private java.util.Date |
+dateTime
+Date and time of the weather.
+ |
+
protected java.lang.String |
+JSON_CLOUDS
+Key for JSON object - Clouds
+ |
+
protected java.lang.String |
+JSON_COORD
+Key for JSON object - Coordinates (Geographic coordinates)
+ |
+
private java.lang.String |
+JSON_DATE_TIME
+Key for JSON variable Date-Time (date & time of the weather)
+ |
+
protected java.lang.String |
+JSON_MAIN
+Key for JSON object - Main (Temperature, pressure, etc.)
+ |
+
protected java.lang.String |
+JSON_WEATHER
+Key for JSON array - Weather (Weather name, description, etc.)
+ |
+
protected java.lang.String |
+JSON_WIND
+Key for JSON object - Wind
+ |
+
Constructor and Description | +
---|
AbstractWeatherData()
+Non-parameterized constructor
+ |
+
AbstractWeatherData(org.json.JSONObject jsonObj)
+Parameterized constructor
+
+ Initializes variables from values from the given JSON object.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
java.util.Date |
+getDateTime()
+Returns data for date and time of this weather.
+ |
+
boolean |
+hasDateTime()
+Tells if the data for date and time of this weather is available or not.
+ |
+
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
protected final java.lang.String JSON_CLOUDS+
protected final java.lang.String JSON_COORD+
protected final java.lang.String JSON_MAIN+
protected final java.lang.String JSON_WEATHER+
protected final java.lang.String JSON_WIND+
private final java.lang.String JSON_DATE_TIME+
private final java.util.Date dateTime+
public AbstractWeatherData()+
Initializes variables as per following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
public AbstractWeatherData(org.json.JSONObject jsonObj)+
jsonObj
- JSON object containing weather datapublic boolean hasDateTime()+
true
if data available, otherwise false
public java.util.Date getDateTime()+
Date
) if available,
+ otherwise null
public static class CurrentWeatherData.Clouds +extends AbstractWeatherData.Clouds+
has
and get
methods
+ to access the information.
+
+ has
methods can be used to check
+ if the data exists, i.e., if the data was available (successfully
+ downloaded) and was parsed correctly.
+
+
get
methods can be used to access the data, if the data
+ exists, otherwise get
methods will give value as per
+ following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
Constructor and Description | +
---|
CurrentWeatherData.Clouds()
+Non-parameterized constructor
+ |
+
CurrentWeatherData.Clouds(org.json.JSONObject jsonObj)
+Parameterized constructor
+
+ Initializes variables from values from the given JSON object.
+ |
+
getPercentageOfClouds, hasPercentageOfClouds
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public CurrentWeatherData.Clouds()+
Initializes variables as per following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
public CurrentWeatherData.Clouds(org.json.JSONObject jsonObj)+
jsonObj
- JSON object containing data about cloudspublic static class CurrentWeatherData.Coord +extends AbstractWeatherData.Coord+
has
and get
methods
+ to access the information.
+
+ has
methods can be used to check
+ if the data exists, i.e., if the data was available (successfully
+ downloaded) and was parsed correctly.
+
+
get
methods can be used to access the data, if the data
+ exists, otherwise get
methods will give value as per
+ following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
Constructor and Description | +
---|
CurrentWeatherData.Coord()
+Non-parameterized constructor
+ |
+
CurrentWeatherData.Coord(org.json.JSONObject jsonObj)
+Parameterized constructor
+
+ Initializes variables from values from the given JSON object.
+ |
+
getLatitude, getLongitude, hasLatitude, hasLongitude
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public CurrentWeatherData.Coord()+
Initializes variables as per following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
public CurrentWeatherData.Coord(org.json.JSONObject jsonObj)+
jsonObj
- JSON object containing data about coordinatespublic static class CurrentWeatherData.Main +extends AbstractWeatherData.Main+
has
and get
methods
+ to access the information.
+
+ has
methods can be used to check
+ if the data exists, i.e., if the data was available (successfully
+ downloaded) and was parsed correctly.
+
+
get
methods can be used to access the data, if the data
+ exists, otherwise get
methods will give value as per
+ following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
Constructor and Description | +
---|
CurrentWeatherData.Main()
+Non-parameterized constructor
+ |
+
CurrentWeatherData.Main(org.json.JSONObject jsonObj)
+Parameterized constructor
+
+ Initializes variables from values from the given JSON object.
+ |
+
getHumidity, getMaxTemperature, getMinTemperature, getPressure, getTemperature, hasHumidity, hasMaxTemperature, hasMinTemperature, hasPressure, hasTemperature
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public CurrentWeatherData.Main()+
Initializes variables as per following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
public CurrentWeatherData.Main(org.json.JSONObject jsonObj)+
jsonObj
- JSON object containing data about main
+ weather elements (temperature, pressure, etc.)public static class CurrentWeatherData.Rain
+extends java.lang.Object
+has
and get
methods
+ to access the information.
+
+ has
methods can be used to check
+ if the data exists, i.e., if the data was available (successfully
+ downloaded) and was parsed correctly.
+
+
get
methods can be used to access the data, if the data
+ exists, otherwise get
methods will give value as per
+ following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
Modifier and Type | +Field and Description | +
---|---|
private java.lang.String |
+JSON_RAIN_3HOURS
+Key for JSON variable
+Rain -> Rain per 3 hours |
+
private float |
+rain3h
+Rain per 3 hours
+ |
+
Constructor and Description | +
---|
CurrentWeatherData.Rain()
+Non-parameterized constructor
+ |
+
CurrentWeatherData.Rain(org.json.JSONObject jsonObj)
+Parameterized constructor
+
+ Initializes variables from values from the given JSON object.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
float |
+getRain3Hours() |
+
boolean |
+hasRain3Hours() |
+
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
private final java.lang.String JSON_RAIN_3HOURS+
Rain -> Rain per 3 hours
private final float rain3h+
public CurrentWeatherData.Rain()+
Initializes variables as per following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
public CurrentWeatherData.Rain(org.json.JSONObject jsonObj)+
jsonObj
- JSON object containing data about rainpublic static class CurrentWeatherData.Sys
+extends java.lang.Object
+has
and get
methods
+ to access the information.
+
+ has
methods can be used to check
+ if the data exists, i.e., if the data was available (successfully
+ downloaded) and was parsed correctly.
+
+
get
methods can be used to access the data, if the data
+ exists, otherwise get
methods will give value as per
+ following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
Modifier and Type | +Field and Description | +
---|---|
private java.lang.String |
+countryCode
+Country code for the city
+ |
+
private java.lang.String |
+JSON_SYS_COUNTRY_CODE
+Key for JSON variable
+Sys -> Country |
+
private java.lang.String |
+JSON_SYS_SUNRISE
+Key for JSON variable
+Sys -> Sunrise |
+
private java.lang.String |
+JSON_SYS_SUNSET
+Key for JSON variable
+Sys -> Sunset |
+
private java.util.Date |
+sunrise
+Sunrise time
+ |
+
private java.util.Date |
+sunset
+Sunset time
+ |
+
Constructor and Description | +
---|
CurrentWeatherData.Sys()
+Non-parameterized constructor
+ |
+
CurrentWeatherData.Sys(org.json.JSONObject jsonObj)
+Parameterized constructor
+
+ Initializes variables from values from the given JSON object.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
java.lang.String |
+getCountryCode() |
+
java.util.Date |
+getSunriseTime() |
+
java.util.Date |
+getSunsetTime() |
+
boolean |
+hasCountryCode() |
+
boolean |
+hasSunriseTime() |
+
boolean |
+hasSunsetTime() |
+
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
private final java.lang.String JSON_SYS_COUNTRY_CODE+
Sys -> Country
private final java.lang.String JSON_SYS_SUNRISE+
Sys -> Sunrise
private final java.lang.String JSON_SYS_SUNSET+
Sys -> Sunset
private final java.lang.String countryCode+
private final java.util.Date sunrise+
private final java.util.Date sunset+
public CurrentWeatherData.Sys()+
Initializes variables as per following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
public CurrentWeatherData.Sys(org.json.JSONObject jsonObj)+
jsonObj
- JSON object containing data about country, sunrise,
+ and sunset.public boolean hasCountryCode()+
public boolean hasSunriseTime()+
public boolean hasSunsetTime()+
public java.lang.String getCountryCode()+
public java.util.Date getSunriseTime()+
public java.util.Date getSunsetTime()+
public static class CurrentWeatherData.Weather +extends AbstractWeatherData.Weather+
has
and get
methods
+ to access the information.
+
+ has
methods can be used to check
+ if the data exists, i.e., if the data was available (successfully
+ downloaded) and was parsed correctly.
+
+
get
methods can be used to access the data, if the data
+ exists, otherwise get
methods will give value as per
+ following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
Constructor and Description | +
---|
CurrentWeatherData.Weather()
+Non-parameterized constructor
+ |
+
CurrentWeatherData.Weather(org.json.JSONObject jsonObj)
+Parameterized constructor
+
+ Initializes variables from values from the given JSON object.
+ |
+
getWeatherCode, getWeatherDescription, getWeatherIconName, getWeatherName, hasWeatherCode, hasWeatherDescription, hasWeatherIconName, hasWeatherName
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public CurrentWeatherData.Weather()+
Initializes variables as per following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
public CurrentWeatherData.Weather(org.json.JSONObject jsonObj)+
jsonObj
- JSON object containing data about weather id, name, etc.public static class CurrentWeatherData.Wind +extends AbstractWeatherData.Wind+
has
and get
methods
+ to access the information.
+
+ has
methods can be used to check
+ if the data exists, i.e., if the data was available (successfully
+ downloaded) and was parsed correctly.
+
+
get
methods can be used to access the data, if the data
+ exists, otherwise get
methods will give value as per
+ following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
Modifier and Type | +Field and Description | +
---|---|
private float |
+gust
+Wind gust
+ |
+
private java.lang.String |
+JSON_WIND_GUST
+Key for JSON variable
+Wind -> Gust |
+
Constructor and Description | +
---|
CurrentWeatherData.Wind()
+Non-parameterized constructor
+ |
+
CurrentWeatherData.Wind(org.json.JSONObject jsonObj)
+Parameterized constructor
+
+ Initializes variables from values from the given JSON object.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
float |
+getWindGust() |
+
boolean |
+hasWindGust() |
+
getWindDegree, getWindSpeed, hasWindDegree, hasWindSpeed
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
private final java.lang.String JSON_WIND_GUST+
Wind -> Gust
private final float gust+
public CurrentWeatherData.Wind()+
Initializes variables as per following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
public CurrentWeatherData.Wind(org.json.JSONObject jsonObj)+
jsonObj
- JSON object containing data about windpublic class CurrentWeatherData +extends AbstractWeatherData+
has
and get
methods
+ to access the information.
+
+ has
methods can be used to check
+ if the data exists, i.e., if the data was available (successfully
+ downloaded) and was parsed correctly.
+
+
get
methods can be used to access the data, if the data
+ exists, otherwise get
methods will give value as per
+ following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
Modifier and Type | +Class and Description | +
---|---|
static class |
+CurrentWeatherData.Clouds
+Parses data about clouds (from the JSON data) and provides methods
+ to get/access the information.
+ |
+
static class |
+CurrentWeatherData.Coord
+Parses data about geographic coordinates (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
static class |
+CurrentWeatherData.Main
+Parses data about main weather elements (from the JSON data) and
+ provides methods to get/access the information.
+ |
+
static class |
+CurrentWeatherData.Rain
+Parses data about rain (from the JSON data) and provides methods
+ to get/access the information.
+ |
+
static class |
+CurrentWeatherData.Sys
+Parses data about country, sunrise, and sunset (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
static class |
+CurrentWeatherData.Weather
+Parses data about weather code, name, etc.
+ |
+
static class |
+CurrentWeatherData.Wind
+Parses data about winds (from the JSON data) and provides methods
+ to get/access the information.
+ |
+
Modifier and Type | +Field and Description | +
---|---|
private java.lang.String |
+base
+Base
+ |
+
private long |
+cityID
+City code (ID)
+ |
+
private java.lang.String |
+cityName
+City name
+ |
+
private CurrentWeatherData.Clouds |
+clouds |
+
private CurrentWeatherData.Coord |
+coord |
+
private java.lang.String |
+JSON_BASE
+Key for JSON variable
+Base |
+
private java.lang.String |
+JSON_CITY_ID
+Key for JSON variable
+City code (ID) |
+
private java.lang.String |
+JSON_CITY_NAME
+Key for JSON variable
+City name |
+
private java.lang.String |
+JSON_RAIN
+Key for JSON object - Rain
+ |
+
private java.lang.String |
+JSON_RESPONSE_CODE
+Key for JSON variable
+Response code |
+
private java.lang.String |
+JSON_SYS
+Key for JSON object - Sys
+ |
+
private CurrentWeatherData.Main |
+main |
+
private CurrentWeatherData.Rain |
+rain |
+
private int |
+responseCode
+Response code
+ |
+
private CurrentWeatherData.Sys |
+sys |
+
private java.util.List<CurrentWeatherData.Weather> |
+weatherList
+List of weather information (code, name, etc.)
+ |
+
private int |
+weatherListCount
+Count (number) of elements in list of weather information
+ |
+
private CurrentWeatherData.Wind |
+wind |
+
JSON_CLOUDS, JSON_COORD, JSON_MAIN, JSON_WEATHER, JSON_WIND
Constructor and Description | +
---|
CurrentWeatherData(org.json.JSONObject jsonObj)
+Parameterized constructor
+
+ Initializes variables from values from the given JSON object.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
java.lang.String |
+getBaseStation() |
+
long |
+getCityCode() |
+
java.lang.String |
+getCityName() |
+
CurrentWeatherData.Clouds |
+getClouds_Object() |
+
CurrentWeatherData.Coord |
+getCoordinates_Object() |
+
CurrentWeatherData.Main |
+getMainData_Object() |
+
CurrentWeatherData.Rain |
+getRain_Object() |
+
int |
+getResponseCode() |
+
CurrentWeatherData.Sys |
+getSysData_Object() |
+
int |
+getWeather_List_Count() |
+
java.util.List<CurrentWeatherData.Weather> |
+getWeather_List() |
+
CurrentWeatherData.Wind |
+getWind_Object() |
+
boolean |
+hasBaseStation() |
+
boolean |
+hasCityCode() |
+
boolean |
+hasCityName() |
+
boolean |
+hasResponseCode() |
+
boolean |
+hasWeather_List() |
+
getDateTime, hasDateTime
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
private final java.lang.String JSON_RAIN+
private final java.lang.String JSON_SYS+
private final java.lang.String JSON_BASE+
Base
private final java.lang.String JSON_CITY_ID+
City code (ID)
private final java.lang.String JSON_CITY_NAME+
City name
private final java.lang.String JSON_RESPONSE_CODE+
Response code
private final java.lang.String base+
private final long cityID+
private final java.lang.String cityName+
private final int responseCode+
private final CurrentWeatherData.Clouds clouds+
private final CurrentWeatherData.Coord coord+
private final CurrentWeatherData.Main main+
private final CurrentWeatherData.Rain rain+
private final CurrentWeatherData.Sys sys+
private final CurrentWeatherData.Wind wind+
private final java.util.List<CurrentWeatherData.Weather> weatherList+
private final int weatherListCount+
public CurrentWeatherData(org.json.JSONObject jsonObj)+
jsonObj
- JSON object containing current weather datapublic boolean hasBaseStation()+
public boolean hasCityCode()+
public boolean hasCityName()+
public boolean hasResponseCode()+
public java.lang.String getBaseStation()+
public long getCityCode()+
public java.lang.String getCityName()+
public int getResponseCode()+
public CurrentWeatherData.Clouds getClouds_Object()+
public CurrentWeatherData.Coord getCoordinates_Object()+
public CurrentWeatherData.Main getMainData_Object()+
public CurrentWeatherData.Rain getRain_Object()+
public CurrentWeatherData.Sys getSysData_Object()+
public CurrentWeatherData.Wind getWind_Object()+
public boolean hasWeather_List()+
public int getWeather_List_Count()+
public java.util.List<CurrentWeatherData.Weather> getWeather_List()+
public static class DailyForecastData.City.Coord +extends AbstractWeatherData.Coord+
has
and get
methods
+ to access the information.
+
+ has
methods can be used to check
+ if the data exists, i.e., if the data was available (successfully
+ downloaded) and was parsed correctly.
+
+
get
methods can be used to access the data, if the data
+ exists, otherwise get
methods will give value as per
+ following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
Constructor and Description | +
---|
DailyForecastData.City.Coord()
+Non-parameterized constructor
+ |
+
DailyForecastData.City.Coord(org.json.JSONObject jsonObj)
+Parameterized constructor
+
+ Initializes variables from values from the given JSON object.
+ |
+
getLatitude, getLongitude, hasLatitude, hasLongitude
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public DailyForecastData.City.Coord()+
Initializes variables as per following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
public DailyForecastData.City.Coord(org.json.JSONObject jsonObj)+
jsonObj
- JSON object containing data about cloudspublic static class DailyForecastData.City
+extends java.lang.Object
+has
and get
methods
+ to access the information.
+
+ has
methods can be used to check
+ if the data exists, i.e., if the data was available (successfully
+ downloaded) and was parsed correctly.
+
+
get
methods can be used to access the data, if the data
+ exists, otherwise get
methods will give value as per
+ following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
Modifier and Type | +Class and Description | +
---|---|
static class |
+DailyForecastData.City.Coord
+Parses data about geographic coordinates (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
Modifier and Type | +Field and Description | +
---|---|
private long |
+cityID
+City code (ID)
+ |
+
private java.lang.String |
+cityName
+City name
+ |
+
private DailyForecastData.City.Coord |
+coord |
+
private java.lang.String |
+countryCode
+Country code of city
+ |
+
private java.lang.String |
+JSON_CITY_COORD
+Key for JSON object - Coordinates
+ |
+
private java.lang.String |
+JSON_CITY_COUNTRY_CODE
+Key for JSON variable
+Country code of city |
+
private java.lang.String |
+JSON_CITY_ID
+Key for JSON variable
+City code (ID) |
+
private java.lang.String |
+JSON_CITY_NAME
+Key for JSON variable
+City name |
+
private java.lang.String |
+JSON_CITY_POPULATION
+Key for JSON variable
+Population of city |
+
private long |
+population
+Population of city
+ |
+
Constructor and Description | +
---|
DailyForecastData.City()
+Non-parameterized constructor
+ |
+
DailyForecastData.City(org.json.JSONObject jsonObj)
+Parameterized constructor
+
+ Initializes variables from values from the given JSON object.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
long |
+getCityCode() |
+
java.lang.String |
+getCityName() |
+
long |
+getCityPopulation() |
+
DailyForecastData.City.Coord |
+getCoordinates_Object() |
+
java.lang.String |
+getCountryCode() |
+
boolean |
+hasCityCode() |
+
boolean |
+hasCityName() |
+
boolean |
+hasCityPopulation() |
+
boolean |
+hasCountryCode() |
+
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
private final java.lang.String JSON_CITY_COORD+
private final java.lang.String JSON_CITY_ID+
City code (ID)
private final java.lang.String JSON_CITY_NAME+
City name
private final java.lang.String JSON_CITY_COUNTRY_CODE+
Country code of city
private final java.lang.String JSON_CITY_POPULATION+
Population of city
private final long cityID+
private final java.lang.String cityName+
private final java.lang.String countryCode+
private final long population+
private final DailyForecastData.City.Coord coord+
public DailyForecastData.City()+
Initializes variables as per following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
public DailyForecastData.City(org.json.JSONObject jsonObj)+
jsonObj
- JSON object containing data about citypublic boolean hasCityCode()+
public boolean hasCityName()+
public boolean hasCountryCode()+
public boolean hasCityPopulation()+
public long getCityCode()+
public java.lang.String getCityName()+
public java.lang.String getCountryCode()+
public long getCityPopulation()+
public DailyForecastData.City.Coord getCoordinates_Object()+
public static class DailyForecastData.Forecast.Temperature
+extends java.lang.Object
+has
and get
methods
+ to access the information.
+
+ has
methods can be used to check
+ if the data exists, i.e., if the data was available (successfully
+ downloaded) and was parsed correctly.
+
+
get
methods can be used to access the data, if the data
+ exists, otherwise get
methods will give value as per
+ following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
Modifier and Type | +Field and Description | +
---|---|
private float |
+dayTemp
+Day temperature
+ |
+
private float |
+eveTemp
+Evening temperature
+ |
+
java.lang.String |
+JSON_TEMP_DAY
+Key for JSON variable
+Temp -> Day |
+
java.lang.String |
+JSON_TEMP_EVENING
+Key for JSON variable
+Temp -> Evening |
+
java.lang.String |
+JSON_TEMP_MAX
+Key for JSON variable
+Temp -> Maximum |
+
java.lang.String |
+JSON_TEMP_MIN
+Key for JSON variable
+Temp -> Minimum |
+
java.lang.String |
+JSON_TEMP_MORNING
+Key for JSON variable
+Temp -> Morning |
+
java.lang.String |
+JSON_TEMP_NIGHT
+Key for JSON variable
+Temp -> Night |
+
private float |
+maxTemp
+Maximum temperature
+ |
+
private float |
+minTemp
+Minimum temperature
+ |
+
private float |
+mornTemp
+Morning temperature
+ |
+
private float |
+nightTemp
+Night temperature
+ |
+
Constructor and Description | +
---|
DailyForecastData.Forecast.Temperature()
+Non-parameterized constructor
+ |
+
DailyForecastData.Forecast.Temperature(org.json.JSONObject jsonObj)
+Parameterized constructor
+
+ Initializes variables from values from the given JSON object.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
float |
+getDayTemperature() |
+
float |
+getEveningTemperature() |
+
float |
+getMaximumTemperature() |
+
float |
+getMinimumTemperature() |
+
float |
+getMorningTemperature() |
+
float |
+getNightTemperature() |
+
boolean |
+hasDayTemperature() |
+
boolean |
+hasEveningTemperature() |
+
boolean |
+hasMaximumTemperature() |
+
boolean |
+hasMinimumTemperature() |
+
boolean |
+hasMorningTemperature() |
+
boolean |
+hasNightTemperature() |
+
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public final java.lang.String JSON_TEMP_DAY+
Temp -> Day
public final java.lang.String JSON_TEMP_MIN+
Temp -> Minimum
public final java.lang.String JSON_TEMP_MAX+
Temp -> Maximum
public final java.lang.String JSON_TEMP_NIGHT+
Temp -> Night
public final java.lang.String JSON_TEMP_EVENING+
Temp -> Evening
public final java.lang.String JSON_TEMP_MORNING+
Temp -> Morning
private final float dayTemp+
private final float minTemp+
private final float maxTemp+
private final float nightTemp+
private final float eveTemp+
private final float mornTemp+
public DailyForecastData.Forecast.Temperature()+
Initializes variables as per following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
public DailyForecastData.Forecast.Temperature(org.json.JSONObject jsonObj)+
jsonObj
- JSON object containing data about temperaturepublic boolean hasDayTemperature()+
public boolean hasMinimumTemperature()+
public boolean hasMaximumTemperature()+
public boolean hasNightTemperature()+
public boolean hasEveningTemperature()+
public boolean hasMorningTemperature()+
public float getDayTemperature()+
public float getMinimumTemperature()+
public float getMaximumTemperature()+
public float getNightTemperature()+
public float getEveningTemperature()+
public float getMorningTemperature()+
public static class DailyForecastData.Forecast.Weather +extends AbstractWeatherData.Weather+
has
and get
methods
+ to access the information.
+
+ has
methods can be used to check
+ if the data exists, i.e., if the data was available (successfully
+ downloaded) and was parsed correctly.
+
+
get
methods can be used to access the data, if the data
+ exists, otherwise get
methods will give value as per
+ following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
Constructor and Description | +
---|
DailyForecastData.Forecast.Weather()
+Non-parameterized constructor
+ |
+
DailyForecastData.Forecast.Weather(org.json.JSONObject jsonObj)
+Parameterized constructor
+
+ Initializes variables from values from the given JSON object.
+ |
+
getWeatherCode, getWeatherDescription, getWeatherIconName, getWeatherName, hasWeatherCode, hasWeatherDescription, hasWeatherIconName, hasWeatherName
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public DailyForecastData.Forecast.Weather()+
Initializes variables as per following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
public DailyForecastData.Forecast.Weather(org.json.JSONObject jsonObj)+
jsonObj
- JSON object containing data about weatherpublic static class DailyForecastData.Forecast +extends AbstractWeatherData+
has
and get
methods
+ to access the information.
+
+ has
methods can be used to check
+ if the data exists, i.e., if the data was available (successfully
+ downloaded) and was parsed correctly.
+
+
get
methods can be used to access the data, if the data
+ exists, otherwise get
methods will give value as per
+ following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
Modifier and Type | +Class and Description | +
---|---|
static class |
+DailyForecastData.Forecast.Temperature
+Parses data about temperature (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
static class |
+DailyForecastData.Forecast.Weather
+Parses data about weather (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
AbstractWeatherData.Clouds, AbstractWeatherData.Coord, AbstractWeatherData.Main, AbstractWeatherData.Wind
Modifier and Type | +Field and Description | +
---|---|
private float |
+cloudsPercent
+Percentage of clouds
+ |
+
private float |
+humidity
+Humidity
+ |
+
private java.lang.String |
+JSON_FORECAST_CLOUDS
+Key for JSON variable
+Percentage of clouds |
+
private java.lang.String |
+JSON_FORECAST_HUMIDITY
+Key for JSON variable
+Humidity |
+
private java.lang.String |
+JSON_FORECAST_PRESSURE
+Key for JSON variable
+Pressure |
+
private java.lang.String |
+JSON_FORECAST_WIND_DEGREE
+Key for JSON variable
+Wind degree |
+
private java.lang.String |
+JSON_FORECAST_WIND_SPEED
+Key for JSON variable
+Wind speed |
+
java.lang.String |
+JSON_TEMP
+Key for JSON object - Temperature
+ |
+
private float |
+pressure
+Pressure
+ |
+
private DailyForecastData.Forecast.Temperature |
+temp |
+
private java.util.List<DailyForecastData.Forecast.Weather> |
+weatherList
+List of weather information (code, name, etc.)
+ |
+
private int |
+weatherListCount
+Count (number) of elements in list of weather information
+ |
+
private float |
+windDegree
+Wind degree
+ |
+
private float |
+windSpeed
+Wind speed
+ |
+
JSON_CLOUDS, JSON_COORD, JSON_MAIN, JSON_WEATHER, JSON_WIND
Constructor and Description | +
---|
DailyForecastData.Forecast()
+Non-parameterized constructor
+ |
+
DailyForecastData.Forecast(org.json.JSONObject jsonObj)
+Parameterized constructor
+
+ Initializes variables from values from the given JSON object.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
float |
+getHumidity() |
+
float |
+getPercentageOfClouds() |
+
float |
+getPressure() |
+
DailyForecastData.Forecast.Temperature |
+getTemperature_Object() |
+
int |
+getWeather_List_Count() |
+
java.util.List<DailyForecastData.Forecast.Weather> |
+getWeather_List() |
+
float |
+getWindDegree() |
+
float |
+getWindSpeed() |
+
boolean |
+hasHumidity() |
+
boolean |
+hasPercentageOfClouds() |
+
boolean |
+hasPressure() |
+
boolean |
+hasWeather_List() |
+
boolean |
+hasWindDegree() |
+
boolean |
+hasWindSpeed() |
+
getDateTime, hasDateTime
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public final java.lang.String JSON_TEMP+
private final java.lang.String JSON_FORECAST_PRESSURE+
Pressure
private final java.lang.String JSON_FORECAST_HUMIDITY+
Humidity
private final java.lang.String JSON_FORECAST_WIND_SPEED+
Wind speed
private final java.lang.String JSON_FORECAST_WIND_DEGREE+
Wind degree
private final java.lang.String JSON_FORECAST_CLOUDS+
Percentage of clouds
private final float pressure+
private final float humidity+
private final float windSpeed+
private final float windDegree+
private final float cloudsPercent+
private final DailyForecastData.Forecast.Temperature temp+
private final java.util.List<DailyForecastData.Forecast.Weather> weatherList+
private final int weatherListCount+
public DailyForecastData.Forecast()+
Initializes variables as per following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
public DailyForecastData.Forecast(org.json.JSONObject jsonObj)+
jsonObj
- JSON object containing data about forecastspublic boolean hasHumidity()+
public boolean hasPressure()+
public boolean hasWindSpeed()+
public boolean hasWindDegree()+
public boolean hasPercentageOfClouds()+
public float getHumidity()+
public float getPressure()+
public float getWindSpeed()+
public float getWindDegree()+
public float getPercentageOfClouds()+
public DailyForecastData.Forecast.Temperature getTemperature_Object()+
public boolean hasWeather_List()+
public int getWeather_List_Count()+
public java.util.List<DailyForecastData.Forecast.Weather> getWeather_List()+
public class DailyForecastData
+extends java.lang.Object
+has
and get
methods
+ to access the information.
+
+ has
methods can be used to check
+ if the data exists, i.e., if the data was available (successfully
+ downloaded) and was parsed correctly.
+
+
get
methods can be used to access the data, if the data
+ exists, otherwise get
methods will give value as per
+ following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Objects: Data initialized with default/non-parameterized constructor
+ Others: null
Modifier and Type | +Class and Description | +
---|---|
static class |
+DailyForecastData.City
+Parses data about city (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
static class |
+DailyForecastData.Forecast
+Parses data about forecasts (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
Modifier and Type | +Field and Description | +
---|---|
private DailyForecastData.City |
+city |
+
private java.util.List<DailyForecastData.Forecast> |
+forecastList
+List of forecast information
+ |
+
private int |
+forecastListCount
+Count (number) of elements in list of forecast information
+ |
+
private java.lang.String |
+JSON_CITY
+Key for JSON object - City
+ |
+
private java.lang.String |
+JSON_FORECAST_LIST
+Key for JSON object - List of forecasts
+ |
+
private java.lang.String |
+JSON_RESPONSE_CODE
+Key for JSON variable
+Response code |
+
private java.lang.String |
+JSON_RESPONSE_FORECAST_COUNT
+Key for JSON variable
+Forecast count |
+
private java.lang.String |
+JSON_RESPONSE_TIME
+Key for JSON variable
+Response time |
+
private java.lang.String |
+responseCode
+Response code
+ |
+
private int |
+responseForecastCount
+Forecast count
+ |
+
private float |
+responseTime
+Response time
+ |
+
Constructor and Description | +
---|
DailyForecastData(org.json.JSONObject jsonObj)
+Parameterized constructor
+
+ Initializes variables from values from the given JSON object.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
DailyForecastData.City |
+getCity_Object() |
+
int |
+getForecast_List_Count() |
+
java.util.List<DailyForecastData.Forecast> |
+getForecast_List() |
+
java.lang.String |
+getResponseCode() |
+
int |
+getResponseForecastCount() |
+
float |
+getResponseTime() |
+
boolean |
+hasForecast_List() |
+
boolean |
+hasResponseCode() |
+
boolean |
+hasResponseForecastCount() |
+
boolean |
+hasResponseTime() |
+
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
private final java.lang.String JSON_CITY+
private final java.lang.String JSON_FORECAST_LIST+
private final java.lang.String JSON_RESPONSE_CODE+
Response code
private final java.lang.String JSON_RESPONSE_TIME+
Response time
private final java.lang.String JSON_RESPONSE_FORECAST_COUNT+
Forecast count
private final java.lang.String responseCode+
private final float responseTime+
private final int responseForecastCount+
private final DailyForecastData.City city+
private final java.util.List<DailyForecastData.Forecast> forecastList+
private final int forecastListCount+
public DailyForecastData(org.json.JSONObject jsonObj)+
jsonObj
- JSON object containing data about daily forecastspublic boolean hasResponseCode()+
public boolean hasResponseTime()+
public boolean hasResponseForecastCount()+
public java.lang.String getResponseCode()+
public float getResponseTime()+
public int getResponseForecastCount()+
public DailyForecastData.City getCity_Object()+
public boolean hasForecast_List()+
public int getForecast_List_Count()+
public java.util.List<DailyForecastData.Forecast> getForecast_List()+
public static class ForecastWeatherData.City.Coord +extends AbstractWeatherData.Coord+
has
and get
methods
+ to access the information.
+
+ has
methods can be used to check
+ if the data exists, i.e., if the data was available (successfully
+ downloaded) and was parsed correctly.
+
+
get
methods can be used to access the data, if the data
+ exists, otherwise get
methods will give value as per
+ following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
Constructor and Description | +
---|
ForecastWeatherData.City.Coord()
+Non-parameterized constructor
+ |
+
ForecastWeatherData.City.Coord(org.json.JSONObject jsonObj)
+Parameterized constructor
+
+ Initializes variables from values from the given JSON object.
+ |
+
getLatitude, getLongitude, hasLatitude, hasLongitude
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public ForecastWeatherData.City.Coord()+
Initializes variables as per following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
public ForecastWeatherData.City.Coord(org.json.JSONObject jsonObj)+
jsonObj
- JSON object containing data about cloudspublic static class ForecastWeatherData.City
+extends java.lang.Object
+has
and get
methods
+ to access the information.
+
+ has
methods can be used to check
+ if the data exists, i.e., if the data was available (successfully
+ downloaded) and was parsed correctly.
+
+
get
methods can be used to access the data, if the data
+ exists, otherwise get
methods will give value as per
+ following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
Modifier and Type | +Class and Description | +
---|---|
static class |
+ForecastWeatherData.City.Coord
+Parses data about geographic coordinates (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
Modifier and Type | +Field and Description | +
---|---|
private long |
+cityID
+City code (ID)
+ |
+
private java.lang.String |
+cityName
+City name
+ |
+
private ForecastWeatherData.City.Coord |
+coord |
+
private java.lang.String |
+countryCode
+Country code of city
+ |
+
private java.lang.String |
+JSON_CITY_COORD
+Key for JSON object - Coordinates
+ |
+
private java.lang.String |
+JSON_CITY_COUNTRY_CODE
+Key for JSON variable
+Country code of city |
+
private java.lang.String |
+JSON_CITY_ID
+Key for JSON variable
+City code (ID) |
+
private java.lang.String |
+JSON_CITY_NAME
+Key for JSON variable
+City name |
+
private java.lang.String |
+JSON_CITY_POPULATION
+Key for JSON variable
+Population of city |
+
private long |
+population
+Population of city
+ |
+
Constructor and Description | +
---|
ForecastWeatherData.City()
+Non-parameterized constructor
+ |
+
ForecastWeatherData.City(org.json.JSONObject jsonObj)
+Parameterized constructor
+
+ Initializes variables from values from the given JSON object.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
long |
+getCityCode() |
+
java.lang.String |
+getCityName() |
+
long |
+getCityPopulation() |
+
ForecastWeatherData.City.Coord |
+getCoordinates_Object() |
+
java.lang.String |
+getCountryCode() |
+
boolean |
+hasCityCode() |
+
boolean |
+hasCityName() |
+
boolean |
+hasCityPopulation() |
+
boolean |
+hasCountryCode() |
+
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
private final java.lang.String JSON_CITY_COORD+
private final java.lang.String JSON_CITY_ID+
City code (ID)
private final java.lang.String JSON_CITY_NAME+
City name
private final java.lang.String JSON_CITY_COUNTRY_CODE+
Country code of city
private final java.lang.String JSON_CITY_POPULATION+
Population of city
private final long cityID+
private final java.lang.String cityName+
private final java.lang.String countryCode+
private final long population+
private final ForecastWeatherData.City.Coord coord+
public ForecastWeatherData.City()+
Initializes variables as per following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
public ForecastWeatherData.City(org.json.JSONObject jsonObj)+
jsonObj
- JSON object containing data about citypublic boolean hasCityCode()+
public boolean hasCityName()+
public boolean hasCountryCode()+
public boolean hasCityPopulation()+
public long getCityCode()+
public java.lang.String getCityName()+
public java.lang.String getCountryCode()+
public long getCityPopulation()+
public ForecastWeatherData.City.Coord getCoordinates_Object()+
public static class ForecastWeatherData.Forecast.Clouds +extends AbstractWeatherData.Clouds+
has
and get
methods
+ to access the information.
+
+ has
methods can be used to check
+ if the data exists, i.e., if the data was available (successfully
+ downloaded) and was parsed correctly.
+
+
get
methods can be used to access the data, if the data
+ exists, otherwise get
methods will give value as per
+ following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
Constructor and Description | +
---|
ForecastWeatherData.Forecast.Clouds()
+Non-parameterized constructor
+ |
+
ForecastWeatherData.Forecast.Clouds(org.json.JSONObject jsonObj)
+Parameterized constructor
+
+ Initializes variables from values from the given JSON object.
+ |
+
getPercentageOfClouds, hasPercentageOfClouds
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public ForecastWeatherData.Forecast.Clouds()+
Initializes variables as per following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
public ForecastWeatherData.Forecast.Clouds(org.json.JSONObject jsonObj)+
jsonObj
- JSON object containing data about cloudspublic static class ForecastWeatherData.Forecast.Main +extends AbstractWeatherData.Main+
has
and get
methods
+ to access the information.
+
+ has
methods can be used to check
+ if the data exists, i.e., if the data was available (successfully
+ downloaded) and was parsed correctly.
+
+
get
methods can be used to access the data, if the data
+ exists, otherwise get
methods will give value as per
+ following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
Modifier and Type | +Field and Description | +
---|---|
private float |
+groundLevel
+Ground level
+ |
+
private java.lang.String |
+JSON_MAIN_GRND_LEVEL
+Key for JSON variable
+Main -> Ground level |
+
private java.lang.String |
+JSON_MAIN_SEA_LEVEL
+Key for JSON variable
+Main -> Sea level |
+
private java.lang.String |
+JSON_MAIN_TMP_KF
+Key for JSON variable
+Main -> Temperature KF |
+
private float |
+seaLevel
+Sea level
+ |
+
private float |
+tempKF
+Temperature KF
+ |
+
Constructor and Description | +
---|
ForecastWeatherData.Forecast.Main()
+Non-parameterized constructor
+ |
+
ForecastWeatherData.Forecast.Main(org.json.JSONObject jsonObj)
+Parameterized constructor
+
+ Initializes variables from values from the given JSON object.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
float |
+getGroundLevel() |
+
float |
+getSeaLevel() |
+
float |
+getTempKF() |
+
boolean |
+hasGroundLevel() |
+
boolean |
+hasSeaLevel() |
+
boolean |
+hasTempKF() |
+
getHumidity, getMaxTemperature, getMinTemperature, getPressure, getTemperature, hasHumidity, hasMaxTemperature, hasMinTemperature, hasPressure, hasTemperature
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
private final java.lang.String JSON_MAIN_SEA_LEVEL+
Main -> Sea level
private final java.lang.String JSON_MAIN_GRND_LEVEL+
Main -> Ground level
private final java.lang.String JSON_MAIN_TMP_KF+
Main -> Temperature KF
private final float seaLevel+
private final float groundLevel+
private final float tempKF+
public ForecastWeatherData.Forecast.Main()+
Initializes variables as per following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
public ForecastWeatherData.Forecast.Main(org.json.JSONObject jsonObj)+
jsonObj
- JSON object containing data about main
+ weather elementspublic boolean hasSeaLevel()+
public boolean hasGroundLevel()+
public boolean hasTempKF()+
public float getSeaLevel()+
public float getGroundLevel()+
public float getTempKF()+
public static class ForecastWeatherData.Forecast.Sys
+extends java.lang.Object
+has
and get
methods
+ to access the information.
+
+ has
methods can be used to check
+ if the data exists, i.e., if the data was available (successfully
+ downloaded) and was parsed correctly.
+
+
get
methods can be used to access the data, if the data
+ exists, otherwise get
methods will give value as per
+ following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
Modifier and Type | +Field and Description | +
---|---|
private java.lang.String |
+JSON_SYS_POD
+Key for JSON variable
+Sys -> Pod |
+
private java.lang.String |
+pod
+Pod
+ |
+
Constructor and Description | +
---|
ForecastWeatherData.Forecast.Sys()
+Non-parameterized constructor
+ |
+
ForecastWeatherData.Forecast.Sys(org.json.JSONObject jsonObj)
+Parameterized constructor
+
+ Initializes variables from values from the given JSON object.
+ |
+
private final java.lang.String JSON_SYS_POD+
Sys -> Pod
private final java.lang.String pod+
public ForecastWeatherData.Forecast.Sys()+
Initializes variables as per following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
public ForecastWeatherData.Forecast.Sys(org.json.JSONObject jsonObj)+
jsonObj
- JSON object containing data about sys.
+ For example, pod, etc.public static class ForecastWeatherData.Forecast.Weather +extends AbstractWeatherData.Weather+
has
and get
methods
+ to access the information.
+
+ has
methods can be used to check
+ if the data exists, i.e., if the data was available (successfully
+ downloaded) and was parsed correctly.
+
+
get
methods can be used to access the data, if the data
+ exists, otherwise get
methods will give value as per
+ following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
Constructor and Description | +
---|
ForecastWeatherData.Forecast.Weather()
+Non-parameterized constructor
+ |
+
ForecastWeatherData.Forecast.Weather(org.json.JSONObject jsonObj)
+Parameterized constructor
+
+ Initializes variables from values from the given JSON object.
+ |
+
getWeatherCode, getWeatherDescription, getWeatherIconName, getWeatherName, hasWeatherCode, hasWeatherDescription, hasWeatherIconName, hasWeatherName
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public ForecastWeatherData.Forecast.Weather()+
Initializes variables as per following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
public ForecastWeatherData.Forecast.Weather(org.json.JSONObject jsonObj)+
jsonObj
- JSON object containing data about weather
+ code, name, etc.public static class ForecastWeatherData.Forecast.Wind +extends AbstractWeatherData.Wind+
has
and get
methods
+ to access the information.
+
+ has
methods can be used to check
+ if the data exists, i.e., if the data was available (successfully
+ downloaded) and was parsed correctly.
+
+
get
methods can be used to access the data, if the data
+ exists, otherwise get
methods will give value as per
+ following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
Constructor and Description | +
---|
ForecastWeatherData.Forecast.Wind()
+Non-parameterized constructor
+ |
+
ForecastWeatherData.Forecast.Wind(org.json.JSONObject jsonObj)
+Parameterized constructor
+
+ Initializes variables from values from the given JSON object.
+ |
+
getWindDegree, getWindSpeed, hasWindDegree, hasWindSpeed
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public ForecastWeatherData.Forecast.Wind()+
Initializes variables as per following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
public ForecastWeatherData.Forecast.Wind(org.json.JSONObject jsonObj)+
jsonObj
- JSON object containing data about windpublic static class ForecastWeatherData.Forecast +extends AbstractWeatherData+
has
and get
methods
+ to access the information.
+
+ has
methods can be used to check
+ if the data exists, i.e., if the data was available (successfully
+ downloaded) and was parsed correctly.
+
+
get
methods can be used to access the data, if the data
+ exists, otherwise get
methods will give value as per
+ following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
Modifier and Type | +Class and Description | +
---|---|
static class |
+ForecastWeatherData.Forecast.Clouds
+Parses data about clouds (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
static class |
+ForecastWeatherData.Forecast.Main
+Parses data about main weather elements (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
static class |
+ForecastWeatherData.Forecast.Sys
+Parses data about main weather elements (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
static class |
+ForecastWeatherData.Forecast.Weather
+Parses data about weather (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
static class |
+ForecastWeatherData.Forecast.Wind
+Parses data about wind (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
AbstractWeatherData.Coord
Modifier and Type | +Field and Description | +
---|---|
private ForecastWeatherData.Forecast.Clouds |
+clouds |
+
private java.lang.String |
+dateTimeText
+Date time text
+ |
+
private java.lang.String |
+JSON_DATE_TIME_TEXT
+Key for JSON variable
+Date time text |
+
private java.lang.String |
+JSON_SYS
+Key for JSON object - Sys (pod, etc.)
+ |
+
private ForecastWeatherData.Forecast.Main |
+main |
+
private ForecastWeatherData.Forecast.Sys |
+sys |
+
private java.util.List<ForecastWeatherData.Forecast.Weather> |
+weatherList
+List of weather information (code, name, etc.)
+ |
+
private int |
+weatherListCount
+Count (number) of elements in list of weather information
+ |
+
private ForecastWeatherData.Forecast.Wind |
+wind |
+
JSON_CLOUDS, JSON_COORD, JSON_MAIN, JSON_WEATHER, JSON_WIND
Constructor and Description | +
---|
ForecastWeatherData.Forecast()
+Non-parameterized constructor
+ |
+
ForecastWeatherData.Forecast(org.json.JSONObject jsonObj)
+Parameterized constructor
+
+ Initializes variables from values from the given JSON object.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
ForecastWeatherData.Forecast.Clouds |
+getClouds_Object() |
+
java.lang.String |
+getDateTimeText() |
+
ForecastWeatherData.Forecast.Main |
+getMainData_Object() |
+
ForecastWeatherData.Forecast.Sys |
+getSysData_Object() |
+
int |
+getWeather_List_Count() |
+
java.util.List<ForecastWeatherData.Forecast.Weather> |
+getWeather_List() |
+
ForecastWeatherData.Forecast.Wind |
+getWind_Object() |
+
boolean |
+hasDateTimeText() |
+
boolean |
+hasWeather_List() |
+
getDateTime, hasDateTime
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
private final java.lang.String JSON_SYS+
private final java.lang.String JSON_DATE_TIME_TEXT+
Date time text
private final java.lang.String dateTimeText+
private final ForecastWeatherData.Forecast.Clouds clouds+
private final ForecastWeatherData.Forecast.Main main+
private final ForecastWeatherData.Forecast.Sys sys+
private final ForecastWeatherData.Forecast.Wind wind+
private final java.util.List<ForecastWeatherData.Forecast.Weather> weatherList+
private final int weatherListCount+
public ForecastWeatherData.Forecast()+
Initializes variables as per following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Others: null
public ForecastWeatherData.Forecast(org.json.JSONObject jsonObj)+
jsonObj
- JSON object containing data about forecastspublic boolean hasDateTimeText()+
public java.lang.String getDateTimeText()+
public ForecastWeatherData.Forecast.Clouds getClouds_Object()+
public ForecastWeatherData.Forecast.Main getMainData_Object()+
public ForecastWeatherData.Forecast.Sys getSysData_Object()+
public ForecastWeatherData.Forecast.Wind getWind_Object()+
public boolean hasWeather_List()+
public int getWeather_List_Count()+
public java.util.List<ForecastWeatherData.Forecast.Weather> getWeather_List()+
public class ForecastWeatherData
+extends java.lang.Object
+has
and get
methods
+ to access the information.
+
+ has
methods can be used to check
+ if the data exists, i.e., if the data was available (successfully
+ downloaded) and was parsed correctly.
+
+
get
methods can be used to access the data, if the data
+ exists, otherwise get
methods will give value as per
+ following basis:
+ Boolean: false
+ Integral: Minimum value (MIN_VALUE)
+ Floating point: Not a number (NaN)
+ Objects: Data initialized with default/non-parameterized constructor
+ Others: null
Modifier and Type | +Class and Description | +
---|---|
static class |
+ForecastWeatherData.City
+Parses data about city (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
static class |
+ForecastWeatherData.Forecast
+Parses data about forecasts (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
Modifier and Type | +Field and Description | +
---|---|
private ForecastWeatherData.City |
+city |
+
private java.util.List<ForecastWeatherData.Forecast> |
+forecastList
+List of forecast information
+ |
+
private int |
+forecastListCount
+Count (number) of elements in list of forecast information
+ |
+
private java.lang.String |
+JSON_CITY
+Key for JSON object - City
+ |
+
private java.lang.String |
+JSON_FORECAST_LIST
+Key for JSON object - List of forecasts
+ |
+
private java.lang.String |
+JSON_RESPONSE_CODE
+Key for JSON variable
+Response code |
+
private java.lang.String |
+JSON_RESPONSE_FORECAST_COUNT
+Key for JSON variable
+Forecast count |
+
private java.lang.String |
+JSON_RESPONSE_TIME
+Key for JSON variable
+Response time |
+
private java.lang.String |
+responseCode
+Response code
+ |
+
private int |
+responseForecastCount
+Forecast count
+ |
+
private float |
+responseTime
+Response time
+ |
+
Constructor and Description | +
---|
ForecastWeatherData(org.json.JSONObject jsonObj)
+Parameterized constructor
+
+ Initializes variables from values from the given JSON object.
+ |
+
Modifier and Type | +Method and Description | +
---|---|
ForecastWeatherData.City |
+getCity_Object() |
+
int |
+getForecast_List_Count() |
+
java.util.List<ForecastWeatherData.Forecast> |
+getForecast_List() |
+
java.lang.String |
+getResponseCode() |
+
int |
+getResponseForecastCount() |
+
float |
+getResponseTime() |
+
boolean |
+hasForecast_List() |
+
boolean |
+hasResponseCode() |
+
boolean |
+hasResponseForecastCount() |
+
boolean |
+hasResponseTime() |
+
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
private final java.lang.String JSON_CITY+
private final java.lang.String JSON_FORECAST_LIST+
private final java.lang.String JSON_RESPONSE_CODE+
Response code
private final java.lang.String JSON_RESPONSE_TIME+
Response time
private final java.lang.String JSON_RESPONSE_FORECAST_COUNT+
Forecast count
private final java.lang.String responseCode+
private final float responseTime+
private final int responseForecastCount+
private final ForecastWeatherData.City city+
private final java.util.List<ForecastWeatherData.Forecast> forecastList+
private final int forecastListCount+
public ForecastWeatherData(org.json.JSONObject jsonObj)+
jsonObj
- JSON object containing data about cloudspublic boolean hasResponseCode()+
public boolean hasResponseTime()+
public boolean hasResponseForecastCount()+
public java.lang.String getResponseCode()+
public float getResponseTime()+
public int getResponseForecastCount()+
public ForecastWeatherData.City getCity_Object()+
public boolean hasForecast_List()+
public int getForecast_List_Count()+
public java.util.List<ForecastWeatherData.Forecast> getForecast_List()+
public static class OpenWeatherMap.OWM_Response
+extends java.lang.Object
+Modifier and Type | +Field and Description | +
---|---|
private java.lang.String |
+OWM_APPID_VALUE |
+
private java.lang.String |
+OWM_MODE_VALUE |
+
private java.lang.String |
+OWM_UNITS_VALUE |
+
Constructor and Description | +
---|
OpenWeatherMap.OWM_Response(OpenWeatherMap.OWM_URL unit,
+ java.lang.String apiKey) |
+
OpenWeatherMap.OWM_Response(java.lang.String apiKey) |
+
Modifier and Type | +Method and Description | +
---|---|
java.lang.String |
+currentWeatherByCityCode(long cityCode) |
+
java.lang.String |
+currentWeatherByCityName(java.lang.String cityName) |
+
java.lang.String |
+currentWeatherByCityName(java.lang.String cityName,
+ java.lang.String countryCode) |
+
java.lang.String |
+currentWeatherByCoordinates(float latitude,
+ float longitude) |
+
java.lang.String |
+dailyForecastByCityCode(long cityCode,
+ byte count) |
+
java.lang.String |
+dailyForecastByCityName(java.lang.String cityName,
+ byte count) |
+
java.lang.String |
+dailyForecastByCityName(java.lang.String cityName,
+ java.lang.String countryCode,
+ byte count) |
+
java.lang.String |
+dailyForecastByCoordinates(float latitude,
+ float longitude,
+ byte count) |
+
java.lang.String |
+forecastWeatherByCityCode(long cityCode) |
+
java.lang.String |
+forecastWeatherByCityName(java.lang.String cityName) |
+
java.lang.String |
+forecastWeatherByCityName(java.lang.String cityName,
+ java.lang.String countryCode) |
+
java.lang.String |
+forecastWeatherByCoordinates(float latitude,
+ float longitude) |
+
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
private final java.lang.String OWM_MODE_VALUE+
private final java.lang.String OWM_UNITS_VALUE+
private final java.lang.String OWM_APPID_VALUE+
public OpenWeatherMap.OWM_Response(java.lang.String apiKey)+
public OpenWeatherMap.OWM_Response(OpenWeatherMap.OWM_URL unit, + java.lang.String apiKey)+
public java.lang.String currentWeatherByCityName(java.lang.String cityName) + throws java.net.MalformedURLException, + java.io.IOException+
java.net.MalformedURLException
java.io.IOException
public java.lang.String currentWeatherByCityName(java.lang.String cityName, + java.lang.String countryCode) + throws java.net.MalformedURLException, + java.io.IOException+
java.net.MalformedURLException
java.io.IOException
public java.lang.String currentWeatherByCityCode(long cityCode) + throws java.net.MalformedURLException, + java.io.IOException+
java.net.MalformedURLException
java.io.IOException
public java.lang.String currentWeatherByCoordinates(float latitude, + float longitude) + throws java.net.MalformedURLException, + java.io.IOException+
java.net.MalformedURLException
java.io.IOException
public java.lang.String forecastWeatherByCityName(java.lang.String cityName) + throws java.net.MalformedURLException, + java.io.IOException+
java.net.MalformedURLException
java.io.IOException
public java.lang.String forecastWeatherByCityName(java.lang.String cityName, + java.lang.String countryCode) + throws java.net.MalformedURLException, + java.io.IOException+
java.net.MalformedURLException
java.io.IOException
public java.lang.String forecastWeatherByCityCode(long cityCode) + throws java.net.MalformedURLException, + java.io.IOException+
java.net.MalformedURLException
java.io.IOException
public java.lang.String forecastWeatherByCoordinates(float latitude, + float longitude) + throws java.net.MalformedURLException, + java.io.IOException+
java.net.MalformedURLException
java.io.IOException
public java.lang.String dailyForecastByCityName(java.lang.String cityName, + byte count) + throws java.net.MalformedURLException, + java.io.IOException+
java.net.MalformedURLException
java.io.IOException
public java.lang.String dailyForecastByCityName(java.lang.String cityName, + java.lang.String countryCode, + byte count) + throws java.net.MalformedURLException, + java.io.IOException+
java.net.MalformedURLException
java.io.IOException
public java.lang.String dailyForecastByCityCode(long cityCode, + byte count) + throws java.net.MalformedURLException, + java.io.IOException+
java.net.MalformedURLException
java.io.IOException
public java.lang.String dailyForecastByCoordinates(float latitude, + float longitude, + byte count) + throws java.net.MalformedURLException, + java.io.IOException+
java.net.MalformedURLException
java.io.IOException
public static enum OpenWeatherMap.OWM_URL +extends java.lang.Enum<OpenWeatherMap.OWM_URL>+
Enum Constant and Description | +
---|
BASE_URL |
+
PARAMETER_APPID |
+
PARAMETER_CITY_ID |
+
PARAMETER_CITY_NAME |
+
PARAMETER_COUNT |
+
PARAMETER_CURRENT_WEATHER |
+
PARAMETER_DAILY_FORECAST |
+
PARAMETER_FORECAST_WEATHER |
+
PARAMETER_LATITUDE |
+
PARAMETER_LONGITUDE |
+
PARAMETER_MODE |
+
PARAMETER_MODE_VALUE_JSON |
+
PARAMETER_SEARCH_CITY |
+
PARAMETER_UNITS |
+
PARAMETER_UNITS_VALUE_IMPERIAL |
+
PARAMETER_UNITS_VALUE_METRIC |
+
Modifier and Type | +Field and Description | +
---|---|
private java.lang.String |
+value |
+
Modifier and Type | +Method and Description | +
---|---|
java.lang.String |
+getParameter()
+Returns the parameter.
+ |
+
static OpenWeatherMap.OWM_URL |
+valueOf(java.lang.String name)
+Returns the enum constant of this type with the specified name.
+ |
+
static OpenWeatherMap.OWM_URL[] |
+values()
+Returns an array containing the constants of this enum type, in
+the order they are declared.
+ |
+
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
getClass, notify, notifyAll, wait, wait, wait
public static final OpenWeatherMap.OWM_URL BASE_URL+
public static final OpenWeatherMap.OWM_URL PARAMETER_CURRENT_WEATHER+
public static final OpenWeatherMap.OWM_URL PARAMETER_FORECAST_WEATHER+
public static final OpenWeatherMap.OWM_URL PARAMETER_DAILY_FORECAST+
public static final OpenWeatherMap.OWM_URL PARAMETER_SEARCH_CITY+
public static final OpenWeatherMap.OWM_URL PARAMETER_COUNT+
public static final OpenWeatherMap.OWM_URL PARAMETER_CITY_NAME+
public static final OpenWeatherMap.OWM_URL PARAMETER_CITY_ID+
public static final OpenWeatherMap.OWM_URL PARAMETER_LATITUDE+
public static final OpenWeatherMap.OWM_URL PARAMETER_LONGITUDE+
public static final OpenWeatherMap.OWM_URL PARAMETER_MODE+
public static final OpenWeatherMap.OWM_URL PARAMETER_UNITS+
public static final OpenWeatherMap.OWM_URL PARAMETER_APPID+
public static final OpenWeatherMap.OWM_URL PARAMETER_MODE_VALUE_JSON+
public static final OpenWeatherMap.OWM_URL PARAMETER_UNITS_VALUE_IMPERIAL+
public static final OpenWeatherMap.OWM_URL PARAMETER_UNITS_VALUE_METRIC+
public static OpenWeatherMap.OWM_URL[] values()+
+for (OpenWeatherMap.OWM_URL c : OpenWeatherMap.OWM_URL.values()) + System.out.println(c); +
public static OpenWeatherMap.OWM_URL valueOf(java.lang.String name)+
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant
+with the specified namejava.lang.NullPointerException
- if the argument is nullpublic java.lang.String getParameter()+
public class OpenWeatherMap
+extends java.lang.Object
+Modifier and Type | +Class and Description | +
---|---|
static class |
+OpenWeatherMap.OWM_Response |
+
static class |
+OpenWeatherMap.OWM_URL |
+
Modifier and Type | +Field and Description | +
---|---|
private OpenWeatherMap.OWM_Response |
+owmResponse
+Declaring this class
+ |
+
Constructor and Description | +
---|
OpenWeatherMap(OpenWeatherMap.OWM_URL unit,
+ java.lang.String apiKey) |
+
OpenWeatherMap(java.lang.String apiKey) |
+
Modifier and Type | +Method and Description | +
---|---|
CurrentWeatherData |
+currentWeatherByCityCode(long cityCode) |
+
CurrentWeatherData |
+currentWeatherByCityName(java.lang.String cityName) |
+
CurrentWeatherData |
+currentWeatherByCityName(java.lang.String cityName,
+ java.lang.String countryCode) |
+
CurrentWeatherData |
+currentWeatherByCoordinates(float latitude,
+ float longitude) |
+
CurrentWeatherData |
+currentWeatherFromResponse(java.lang.String jsonResponse) |
+
DailyForecastData |
+dailyForecastByCityCode(long cityCode,
+ byte count) |
+
DailyForecastData |
+dailyForecastByCityName(java.lang.String cityName,
+ byte count) |
+
DailyForecastData |
+dailyForecastByCityName(java.lang.String cityName,
+ java.lang.String countryCode,
+ byte count) |
+
DailyForecastData |
+dailyForecastByCoordinates(float latitude,
+ float longitude,
+ byte count) |
+
DailyForecastData |
+dailyForecastFromResponse(java.lang.String jsonResponse) |
+
ForecastWeatherData |
+forecastWeatherByCityCode(long cityCode) |
+
ForecastWeatherData |
+forecastWeatherByCityName(java.lang.String cityName) |
+
ForecastWeatherData |
+forecastWeatherByCityName(java.lang.String cityName,
+ java.lang.String countryCode) |
+
ForecastWeatherData |
+forecastWeatherByCoordinates(float latitude,
+ float longitude) |
+
ForecastWeatherData |
+forecastWeatherFromResponse(java.lang.String jsonResponse) |
+
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
private final OpenWeatherMap.OWM_Response owmResponse+
public OpenWeatherMap(java.lang.String apiKey)+
public OpenWeatherMap(OpenWeatherMap.OWM_URL unit, + java.lang.String apiKey)+
public CurrentWeatherData currentWeatherByCityName(java.lang.String cityName) + throws java.net.MalformedURLException, + java.io.IOException, + org.json.JSONException+
java.net.MalformedURLException
java.io.IOException
org.json.JSONException
public CurrentWeatherData currentWeatherByCityName(java.lang.String cityName, + java.lang.String countryCode) + throws java.net.MalformedURLException, + java.io.IOException, + org.json.JSONException+
java.net.MalformedURLException
java.io.IOException
org.json.JSONException
public CurrentWeatherData currentWeatherByCityCode(long cityCode) + throws java.net.MalformedURLException, + java.io.IOException, + org.json.JSONException+
java.net.MalformedURLException
java.io.IOException
org.json.JSONException
public CurrentWeatherData currentWeatherByCoordinates(float latitude, + float longitude) + throws java.net.MalformedURLException, + java.io.IOException, + org.json.JSONException+
java.net.MalformedURLException
java.io.IOException
org.json.JSONException
public CurrentWeatherData currentWeatherFromResponse(java.lang.String jsonResponse) + throws java.net.MalformedURLException, + java.io.IOException, + org.json.JSONException+
java.net.MalformedURLException
java.io.IOException
org.json.JSONException
public ForecastWeatherData forecastWeatherByCityName(java.lang.String cityName) + throws java.net.MalformedURLException, + java.io.IOException, + org.json.JSONException+
java.net.MalformedURLException
java.io.IOException
org.json.JSONException
public ForecastWeatherData forecastWeatherByCityName(java.lang.String cityName, + java.lang.String countryCode) + throws java.net.MalformedURLException, + java.io.IOException, + org.json.JSONException+
java.net.MalformedURLException
java.io.IOException
org.json.JSONException
public ForecastWeatherData forecastWeatherByCityCode(long cityCode) + throws java.net.MalformedURLException, + java.io.IOException, + org.json.JSONException+
java.net.MalformedURLException
java.io.IOException
org.json.JSONException
public ForecastWeatherData forecastWeatherByCoordinates(float latitude, + float longitude) + throws java.net.MalformedURLException, + java.io.IOException, + org.json.JSONException+
java.net.MalformedURLException
java.io.IOException
org.json.JSONException
public ForecastWeatherData forecastWeatherFromResponse(java.lang.String jsonResponse) + throws java.net.MalformedURLException, + java.io.IOException, + org.json.JSONException+
java.net.MalformedURLException
java.io.IOException
org.json.JSONException
public DailyForecastData dailyForecastByCityName(java.lang.String cityName, + byte count) + throws java.net.MalformedURLException, + java.io.IOException, + org.json.JSONException+
java.net.MalformedURLException
java.io.IOException
org.json.JSONException
public DailyForecastData dailyForecastByCityName(java.lang.String cityName, + java.lang.String countryCode, + byte count) + throws java.net.MalformedURLException, + java.io.IOException, + org.json.JSONException+
java.net.MalformedURLException
java.io.IOException
org.json.JSONException
public DailyForecastData dailyForecastByCityCode(long cityCode, + byte count) + throws java.net.MalformedURLException, + java.io.IOException, + org.json.JSONException+
java.net.MalformedURLException
java.io.IOException
org.json.JSONException
public DailyForecastData dailyForecastByCoordinates(float latitude, + float longitude, + byte count) + throws java.net.MalformedURLException, + java.io.IOException, + org.json.JSONException+
java.net.MalformedURLException
java.io.IOException
org.json.JSONException
public DailyForecastData dailyForecastFromResponse(java.lang.String jsonResponse) + throws java.net.MalformedURLException, + java.io.IOException, + org.json.JSONException+
java.net.MalformedURLException
java.io.IOException
org.json.JSONException
public static class Tools.Convertor
+extends java.lang.Object
+Constructor and Description | +
---|
Tools.Convertor() |
+
Modifier and Type | +Method and Description | +
---|---|
java.lang.String |
+convertDegree2Direction(float degree)
+Converts degree to direction.
+ |
+
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public java.lang.String convertDegree2Direction(float degree) + throws java.lang.IllegalArgumentException+
java.lang.IllegalArgumentException
- Degree should be between 0 and 360.public static class Tools.Downloader
+extends java.lang.Object
+Constructor and Description | +
---|
Tools.Downloader() |
+
Modifier and Type | +Method and Description | +
---|---|
static java.lang.String |
+downloadPage(java.lang.String pageAddress)
+Downloads a page/content from the Internet.
+ |
+
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public static java.lang.String downloadPage(java.lang.String pageAddress) + throws java.net.MalformedURLException, + java.io.IOException+
pageAddress
.
+
+ NOTE: pageAddress
should be a correct URL, else
+ this method will throw MalformedURLException
.
pageAddress
- Address of the web page to get from the Internet.java.net.MalformedURLException
- Address of the web page is not correct.java.io.IOException
- Error while loading the page from the Internet or connection
+ got disconnected.public static class Tools.HTML
+extends java.lang.Object
+Constructor and Description | +
---|
Tools.HTML() |
+
Modifier and Type | +Method and Description | +
---|---|
static java.lang.String |
+strictAddress(java.lang.String inputString)
+Stricts a non-strict or non-compliant web address
+ to a proper URL.
+ |
+
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public static java.lang.String strictAddress(java.lang.String inputString)+
Note: This function checks and stricts only some parts of the + URL, which are necessary to be corrected for accessing data from + the OpenWeatherMap.org
inputString
- String to be converted to strict HTML addresspublic class Tools
+extends java.lang.Object
+Note: This class directly do not provide any functions, but has
+ static
sub-classes which provide various
+ related tools, i.e., this class only behaves as the container for those
+ classes.
Modifier and Type | +Class and Description | +
---|---|
static class |
+Tools.Convertor
+Provides methods to do conversions.
+ |
+
static class |
+Tools.Downloader
+Provides methods to download data or files from the Internet.
+ |
+
static class |
+Tools.HTML
+Provides functions to handle HTML, e.g., correcting
+ non-compliant or non-strict web addresses, etc.
+ |
+
Modifier and Type | +Class and Description | +
---|---|
static class |
+CurrentWeatherData.Clouds
+Parses data about clouds (from the JSON data) and provides methods
+ to get/access the information.
+ |
+
static class |
+ForecastWeatherData.Forecast.Clouds
+Parses data about clouds (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
Modifier and Type | +Class and Description | +
---|---|
static class |
+CurrentWeatherData.Coord
+Parses data about geographic coordinates (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
static class |
+DailyForecastData.City.Coord
+Parses data about geographic coordinates (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
static class |
+ForecastWeatherData.City.Coord
+Parses data about geographic coordinates (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
Modifier and Type | +Class and Description | +
---|---|
static class |
+CurrentWeatherData.Main
+Parses data about main weather elements (from the JSON data) and
+ provides methods to get/access the information.
+ |
+
static class |
+ForecastWeatherData.Forecast.Main
+Parses data about main weather elements (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
Modifier and Type | +Class and Description | +
---|---|
static class |
+CurrentWeatherData.Weather
+Parses data about weather code, name, etc.
+ |
+
static class |
+DailyForecastData.Forecast.Weather
+Parses data about weather (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
static class |
+ForecastWeatherData.Forecast.Weather
+Parses data about weather (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
Modifier and Type | +Class and Description | +
---|---|
static class |
+CurrentWeatherData.Wind
+Parses data about winds (from the JSON data) and provides methods
+ to get/access the information.
+ |
+
static class |
+ForecastWeatherData.Forecast.Wind
+Parses data about wind (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
Modifier and Type | +Class and Description | +
---|---|
class |
+CurrentWeatherData
+Parses current weather data (from the JSON data) and provides methods
+ to get/access the information about current weather.
+ |
+
static class |
+DailyForecastData.Forecast
+Parses data about forecasts (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
static class |
+ForecastWeatherData.Forecast
+Parses data about forecasts (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
Modifier and Type | +Field and Description | +
---|---|
private CurrentWeatherData.Clouds |
+CurrentWeatherData.clouds |
+
Modifier and Type | +Method and Description | +
---|---|
CurrentWeatherData.Clouds |
+CurrentWeatherData.getClouds_Object() |
+
Modifier and Type | +Field and Description | +
---|---|
private CurrentWeatherData.Coord |
+CurrentWeatherData.coord |
+
Modifier and Type | +Method and Description | +
---|---|
CurrentWeatherData.Coord |
+CurrentWeatherData.getCoordinates_Object() |
+
Modifier and Type | +Field and Description | +
---|---|
private CurrentWeatherData.Main |
+CurrentWeatherData.main |
+
Modifier and Type | +Method and Description | +
---|---|
CurrentWeatherData.Main |
+CurrentWeatherData.getMainData_Object() |
+
Modifier and Type | +Field and Description | +
---|---|
private CurrentWeatherData.Rain |
+CurrentWeatherData.rain |
+
Modifier and Type | +Method and Description | +
---|---|
CurrentWeatherData.Rain |
+CurrentWeatherData.getRain_Object() |
+
Modifier and Type | +Field and Description | +
---|---|
private CurrentWeatherData.Sys |
+CurrentWeatherData.sys |
+
Modifier and Type | +Method and Description | +
---|---|
CurrentWeatherData.Sys |
+CurrentWeatherData.getSysData_Object() |
+
Modifier and Type | +Field and Description | +
---|---|
private java.util.List<CurrentWeatherData.Weather> |
+CurrentWeatherData.weatherList
+List of weather information (code, name, etc.)
+ |
+
Modifier and Type | +Method and Description | +
---|---|
java.util.List<CurrentWeatherData.Weather> |
+CurrentWeatherData.getWeather_List() |
+
Modifier and Type | +Field and Description | +
---|---|
private CurrentWeatherData.Wind |
+CurrentWeatherData.wind |
+
Modifier and Type | +Method and Description | +
---|---|
CurrentWeatherData.Wind |
+CurrentWeatherData.getWind_Object() |
+
Modifier and Type | +Method and Description | +
---|---|
CurrentWeatherData |
+OpenWeatherMap.currentWeatherByCityCode(long cityCode) |
+
CurrentWeatherData |
+OpenWeatherMap.currentWeatherByCityName(java.lang.String cityName) |
+
CurrentWeatherData |
+OpenWeatherMap.currentWeatherByCityName(java.lang.String cityName,
+ java.lang.String countryCode) |
+
CurrentWeatherData |
+OpenWeatherMap.currentWeatherByCoordinates(float latitude,
+ float longitude) |
+
CurrentWeatherData |
+OpenWeatherMap.currentWeatherFromResponse(java.lang.String jsonResponse) |
+
Modifier and Type | +Field and Description | +
---|---|
private DailyForecastData.City.Coord |
+DailyForecastData.City.coord |
+
Modifier and Type | +Method and Description | +
---|---|
DailyForecastData.City.Coord |
+DailyForecastData.City.getCoordinates_Object() |
+
Modifier and Type | +Field and Description | +
---|---|
private DailyForecastData.City |
+DailyForecastData.city |
+
Modifier and Type | +Method and Description | +
---|---|
DailyForecastData.City |
+DailyForecastData.getCity_Object() |
+
Modifier and Type | +Field and Description | +
---|---|
private DailyForecastData.Forecast.Temperature |
+DailyForecastData.Forecast.temp |
+
Modifier and Type | +Method and Description | +
---|---|
DailyForecastData.Forecast.Temperature |
+DailyForecastData.Forecast.getTemperature_Object() |
+
Modifier and Type | +Field and Description | +
---|---|
private java.util.List<DailyForecastData.Forecast.Weather> |
+DailyForecastData.Forecast.weatherList
+List of weather information (code, name, etc.)
+ |
+
Modifier and Type | +Method and Description | +
---|---|
java.util.List<DailyForecastData.Forecast.Weather> |
+DailyForecastData.Forecast.getWeather_List() |
+
Modifier and Type | +Field and Description | +
---|---|
private java.util.List<DailyForecastData.Forecast> |
+DailyForecastData.forecastList
+List of forecast information
+ |
+
Modifier and Type | +Method and Description | +
---|---|
java.util.List<DailyForecastData.Forecast> |
+DailyForecastData.getForecast_List() |
+
Modifier and Type | +Method and Description | +
---|---|
DailyForecastData |
+OpenWeatherMap.dailyForecastByCityCode(long cityCode,
+ byte count) |
+
DailyForecastData |
+OpenWeatherMap.dailyForecastByCityName(java.lang.String cityName,
+ byte count) |
+
DailyForecastData |
+OpenWeatherMap.dailyForecastByCityName(java.lang.String cityName,
+ java.lang.String countryCode,
+ byte count) |
+
DailyForecastData |
+OpenWeatherMap.dailyForecastByCoordinates(float latitude,
+ float longitude,
+ byte count) |
+
DailyForecastData |
+OpenWeatherMap.dailyForecastFromResponse(java.lang.String jsonResponse) |
+
Modifier and Type | +Field and Description | +
---|---|
private ForecastWeatherData.City.Coord |
+ForecastWeatherData.City.coord |
+
Modifier and Type | +Method and Description | +
---|---|
ForecastWeatherData.City.Coord |
+ForecastWeatherData.City.getCoordinates_Object() |
+
Modifier and Type | +Field and Description | +
---|---|
private ForecastWeatherData.City |
+ForecastWeatherData.city |
+
Modifier and Type | +Method and Description | +
---|---|
ForecastWeatherData.City |
+ForecastWeatherData.getCity_Object() |
+
Modifier and Type | +Field and Description | +
---|---|
private ForecastWeatherData.Forecast.Clouds |
+ForecastWeatherData.Forecast.clouds |
+
Modifier and Type | +Method and Description | +
---|---|
ForecastWeatherData.Forecast.Clouds |
+ForecastWeatherData.Forecast.getClouds_Object() |
+
Modifier and Type | +Field and Description | +
---|---|
private ForecastWeatherData.Forecast.Main |
+ForecastWeatherData.Forecast.main |
+
Modifier and Type | +Method and Description | +
---|---|
ForecastWeatherData.Forecast.Main |
+ForecastWeatherData.Forecast.getMainData_Object() |
+
Modifier and Type | +Field and Description | +
---|---|
private ForecastWeatherData.Forecast.Sys |
+ForecastWeatherData.Forecast.sys |
+
Modifier and Type | +Method and Description | +
---|---|
ForecastWeatherData.Forecast.Sys |
+ForecastWeatherData.Forecast.getSysData_Object() |
+
Modifier and Type | +Field and Description | +
---|---|
private java.util.List<ForecastWeatherData.Forecast.Weather> |
+ForecastWeatherData.Forecast.weatherList
+List of weather information (code, name, etc.)
+ |
+
Modifier and Type | +Method and Description | +
---|---|
java.util.List<ForecastWeatherData.Forecast.Weather> |
+ForecastWeatherData.Forecast.getWeather_List() |
+
Modifier and Type | +Field and Description | +
---|---|
private ForecastWeatherData.Forecast.Wind |
+ForecastWeatherData.Forecast.wind |
+
Modifier and Type | +Method and Description | +
---|---|
ForecastWeatherData.Forecast.Wind |
+ForecastWeatherData.Forecast.getWind_Object() |
+
Modifier and Type | +Field and Description | +
---|---|
private java.util.List<ForecastWeatherData.Forecast> |
+ForecastWeatherData.forecastList
+List of forecast information
+ |
+
Modifier and Type | +Method and Description | +
---|---|
java.util.List<ForecastWeatherData.Forecast> |
+ForecastWeatherData.getForecast_List() |
+
Modifier and Type | +Method and Description | +
---|---|
ForecastWeatherData |
+OpenWeatherMap.forecastWeatherByCityCode(long cityCode) |
+
ForecastWeatherData |
+OpenWeatherMap.forecastWeatherByCityName(java.lang.String cityName) |
+
ForecastWeatherData |
+OpenWeatherMap.forecastWeatherByCityName(java.lang.String cityName,
+ java.lang.String countryCode) |
+
ForecastWeatherData |
+OpenWeatherMap.forecastWeatherByCoordinates(float latitude,
+ float longitude) |
+
ForecastWeatherData |
+OpenWeatherMap.forecastWeatherFromResponse(java.lang.String jsonResponse) |
+
Modifier and Type | +Field and Description | +
---|---|
private OpenWeatherMap.OWM_Response |
+OpenWeatherMap.owmResponse
+Declaring this class
+ |
+
Modifier and Type | +Method and Description | +
---|---|
static OpenWeatherMap.OWM_URL |
+OpenWeatherMap.OWM_URL.valueOf(java.lang.String name)
+Returns the enum constant of this type with the specified name.
+ |
+
static OpenWeatherMap.OWM_URL[] |
+OpenWeatherMap.OWM_URL.values()
+Returns an array containing the constants of this enum type, in
+the order they are declared.
+ |
+
Constructor and Description | +
---|
OpenWeatherMap.OWM_Response(OpenWeatherMap.OWM_URL unit,
+ java.lang.String apiKey) |
+
OpenWeatherMap(OpenWeatherMap.OWM_URL unit,
+ java.lang.String apiKey) |
+
Class | +Description | +
---|---|
AbstractWeatherData | +
+ This class provides default implementations for
+CurrentWeatherData
+ and ForecastWeatherData classes. |
+
AbstractWeatherData.Clouds | +
+ This class provides default implementations for
+Clouds . |
+
AbstractWeatherData.Coord | +
+ This class provides default implementations for
+Coord . |
+
AbstractWeatherData.Main | +
+ This class provides default implementations for
+Main . |
+
AbstractWeatherData.Weather | +
+ This class provides default implementations for
+Weather . |
+
AbstractWeatherData.Wind | +
+ This class provides default implementations for
+Wind . |
+
CurrentWeatherData | +
+ Parses current weather data (from the JSON data) and provides methods
+ to get/access the information about current weather.
+ |
+
CurrentWeatherData.Clouds | +
+ Parses data about clouds (from the JSON data) and provides methods
+ to get/access the information.
+ |
+
CurrentWeatherData.Coord | +
+ Parses data about geographic coordinates (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
CurrentWeatherData.Main | +
+ Parses data about main weather elements (from the JSON data) and
+ provides methods to get/access the information.
+ |
+
CurrentWeatherData.Rain | +
+ Parses data about rain (from the JSON data) and provides methods
+ to get/access the information.
+ |
+
CurrentWeatherData.Sys | +
+ Parses data about country, sunrise, and sunset (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
CurrentWeatherData.Weather | +
+ Parses data about weather code, name, etc.
+ |
+
CurrentWeatherData.Wind | +
+ Parses data about winds (from the JSON data) and provides methods
+ to get/access the information.
+ |
+
DailyForecastData | +
+ Parses daily forecast data (from the JSON data) and provides methods
+ to get/access the information about daily forecasted weather.
+ |
+
DailyForecastData.City | +
+ Parses data about city (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
DailyForecastData.City.Coord | +
+ Parses data about geographic coordinates (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
DailyForecastData.Forecast | +
+ Parses data about forecasts (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
DailyForecastData.Forecast.Temperature | +
+ Parses data about temperature (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
DailyForecastData.Forecast.Weather | +
+ Parses data about weather (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
ForecastWeatherData | +
+ Parses forecast weather data (from the JSON data) and provides methods
+ to get/access the information about forecasted weather.
+ |
+
ForecastWeatherData.City | +
+ Parses data about city (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
ForecastWeatherData.City.Coord | +
+ Parses data about geographic coordinates (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
ForecastWeatherData.Forecast | +
+ Parses data about forecasts (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
ForecastWeatherData.Forecast.Clouds | +
+ Parses data about clouds (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
ForecastWeatherData.Forecast.Main | +
+ Parses data about main weather elements (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
ForecastWeatherData.Forecast.Sys | +
+ Parses data about main weather elements (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
ForecastWeatherData.Forecast.Weather | +
+ Parses data about weather (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
ForecastWeatherData.Forecast.Wind | +
+ Parses data about wind (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
OpenWeatherMap | +
+ Provides methods to get weather, forecast, and other data from
+ OpenWeatherMap.org
+ |
+
OpenWeatherMap.OWM_Response | ++ |
Tools | +
+ Provides various tools, which help doing tasks in this application.
+ |
+
Tools.Convertor | +
+ Provides methods to do conversions.
+ |
+
Tools.Downloader | +
+ Provides methods to download data or files from the Internet.
+ |
+
Tools.HTML | +
+ Provides functions to handle HTML, e.g., correcting
+ non-compliant or non-strict web addresses, etc.
+ |
+
Enum | +Description | +
---|---|
OpenWeatherMap.OWM_URL | ++ |
Class and Description | +
---|
AbstractWeatherData
+ This class provides default implementations for
+CurrentWeatherData
+ and ForecastWeatherData classes. |
+
AbstractWeatherData.Clouds
+ This class provides default implementations for
+Clouds . |
+
AbstractWeatherData.Coord
+ This class provides default implementations for
+Coord . |
+
AbstractWeatherData.Main
+ This class provides default implementations for
+Main . |
+
AbstractWeatherData.Weather
+ This class provides default implementations for
+Weather . |
+
AbstractWeatherData.Wind
+ This class provides default implementations for
+Wind . |
+
CurrentWeatherData
+ Parses current weather data (from the JSON data) and provides methods
+ to get/access the information about current weather.
+ |
+
CurrentWeatherData.Clouds
+ Parses data about clouds (from the JSON data) and provides methods
+ to get/access the information.
+ |
+
CurrentWeatherData.Coord
+ Parses data about geographic coordinates (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
CurrentWeatherData.Main
+ Parses data about main weather elements (from the JSON data) and
+ provides methods to get/access the information.
+ |
+
CurrentWeatherData.Rain
+ Parses data about rain (from the JSON data) and provides methods
+ to get/access the information.
+ |
+
CurrentWeatherData.Sys
+ Parses data about country, sunrise, and sunset (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
CurrentWeatherData.Weather
+ Parses data about weather code, name, etc.
+ |
+
CurrentWeatherData.Wind
+ Parses data about winds (from the JSON data) and provides methods
+ to get/access the information.
+ |
+
DailyForecastData
+ Parses daily forecast data (from the JSON data) and provides methods
+ to get/access the information about daily forecasted weather.
+ |
+
DailyForecastData.City
+ Parses data about city (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
DailyForecastData.City.Coord
+ Parses data about geographic coordinates (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
DailyForecastData.Forecast
+ Parses data about forecasts (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
DailyForecastData.Forecast.Temperature
+ Parses data about temperature (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
DailyForecastData.Forecast.Weather
+ Parses data about weather (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
ForecastWeatherData
+ Parses forecast weather data (from the JSON data) and provides methods
+ to get/access the information about forecasted weather.
+ |
+
ForecastWeatherData.City
+ Parses data about city (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
ForecastWeatherData.City.Coord
+ Parses data about geographic coordinates (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
ForecastWeatherData.Forecast
+ Parses data about forecasts (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
ForecastWeatherData.Forecast.Clouds
+ Parses data about clouds (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
ForecastWeatherData.Forecast.Main
+ Parses data about main weather elements (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
ForecastWeatherData.Forecast.Sys
+ Parses data about main weather elements (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
ForecastWeatherData.Forecast.Weather
+ Parses data about weather (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
ForecastWeatherData.Forecast.Wind
+ Parses data about wind (from the JSON data)
+ and provides methods to get/access the information.
+ |
+
OpenWeatherMap.OWM_Response | +
OpenWeatherMap.OWM_URL | +
has
and the get
+ * methods for information about weather or forecast (for example,
+ * temperature, pressure, weather, clouds, wind, etc.) are defined here.
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/07/26
+ * @since 2.5.0.1
+ */
+abstract public class AbstractWeatherData {
+ /** Key for JSON object - Clouds */
+ protected final String JSON_CLOUDS = "clouds";
+ /** Key for JSON object - Coordinates (Geographic coordinates) */
+ protected final String JSON_COORD = "coord";
+ /** Key for JSON object - Main (Temperature, pressure, etc.) */
+ protected final String JSON_MAIN = "main";
+ /** Key for JSON array - Weather (Weather name, description, etc.) */
+ protected final String JSON_WEATHER = "weather";
+ /** Key for JSON object - Wind */
+ protected final String JSON_WIND = "wind";
+
+
+ /*
+ ************************
+ * Defining sub-classes
+ ************************
+ */
+
+ /**
+ * This class provides default implementations for Clouds
.
+ * Standard behaviors like the has
and the get
+ * methods for information about clouds (for example, percentage of
+ * clouds, etc.) are defined here.
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/07/27
+ * @since 2.5.0.1
+ */
+ abstract public static class Clouds {
+ /**
+ * Key for JSON variable Clouds -> All
+ * (percentage of all clouds)
+ */
+ private final String JSON_CLOUDS_ALL = "all";
+
+ /** Percentage of all clouds */
+ private final float percentOfClouds;
+
+ /**
+ * Non-parameterized constructor
+ *
+ * Initializes variables as per following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ */
+ public Clouds() {
+ this.percentOfClouds = Float.NaN;
+ }
+
+ /**
+ * Parameterized constructor
+ *
+ * Initializes variables from values from the given JSON object.
+ *
+ * @param jsonObj JSON object containing data about clouds
+ */
+ public Clouds(JSONObject jsonObj) {
+ this.percentOfClouds = (float) jsonObj.optDouble(this.JSON_CLOUDS_ALL, Double.NaN);
+ }
+
+ /**
+ * Tells if the data for percentage of all clouds is available or not.
+ * @return true
if data available, otherwise false
+ */
+ public boolean hasPercentageOfClouds() {
+ return (this.percentOfClouds != Float.NaN);
+ }
+
+ /**
+ * Returns data for percentage of all clouds.
+ * @return Percentage of all clouds if available,
+ * otherwise Float.NaN
, i.e., Not a Number.
+ */
+ public float getPercentageOfClouds() {
+ return this.percentOfClouds;
+ }
+ }
+
+
+ /**
+ * This class provides default implementations for Coord
.
+ * Standard behaviors like the has
and the get
+ * methods for information about geographic coordinates (latitude
+ * and longitude) are defined here.
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/07/28
+ */
+ abstract public static class Coord {
+ /** Key for JSON variable Coord -> Latitude
*/
+ private final String JSON_COORD_LATITUDE = "lat";
+ /** Key for JSON variable Coord -> Longitude
*/
+ private final String JSON_COORD_LONGITUDE = "lon";
+
+ /** Latitude */
+ private final float lat;
+ /** Longitude */
+ private final float lon;
+
+ /**
+ * Non-parameterized constructor
+ *
+ *
Initializes variables as per following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ */
+ public Coord() {
+ this.lat = Float.NaN;
+ this.lon = Float.NaN;
+ }
+
+ /**
+ * Parameterized constructor
+ *
+ * Initializes variables from values from the given JSON object.
+ *
+ * @param jsonObj JSON object containing data about coordinates
+ */
+ public 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);
+ }
+
+ /**
+ * Tells if the data for latitude of the city is available or not.
+ * @return true
if data available, otherwise false
+ */
+ public boolean hasLatitude() {
+ return (this.lat != Float.NaN);
+ }
+
+ /**
+ * Tells if the data for longitude of the city is available or not.
+ * @return true
if data available, otherwise false
+ */
+ public boolean hasLongitude() {
+ return (this.lon != Float.NaN);
+ }
+
+ /**
+ * Returns data for latitude of the city.
+ * @return Latitude of the city if available,
+ * otherwise Float.NaN
, i.e., Not a Number.
+ */
+ public float getLatitude() {
+ return this.lat;
+ }
+
+ /**
+ * Returns data for longitude of the city.
+ * @return Longitude of the city if available,
+ * otherwise Float.NaN
, i.e., Not a Number.
+ */
+ public float getLongitude() {
+ return this.lon;
+ }
+ }
+
+
+ /**
+ * This class provides default implementations for Main
.
+ * Standard behaviors like the has
and the get
+ * methods for information about main weather elements (for example,
+ * temperature, pressure, humidity, etc.) are defined here.
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/07/28
+ * @since 2.5.0.1
+ */
+ abstract public static class Main {
+ /** Key for JSON variable Main -> Temperature
*/
+ private final String JSON_MAIN_TEMP = "temp";
+ /** Key for JSON variable Main -> Minimum temperature
*/
+ private final String JSON_MAIN_TEMP_MIN = "temp_min";
+ /** Key for JSON variable Main -> Maximum temperature
*/
+ private final String JSON_MAIN_TEMP_MAX = "temp_max";
+ /** Key for JSON variable Main -> Pressure
*/
+ private final String JSON_MAIN_PRESSURE = "pressure";
+ /** Key for JSON variable Main -> Humidity
*/
+ private final String JSON_MAIN_HUMIDITY = "humidity";
+
+ /** Temperature */
+ private final float temp;
+ /** Minimum temperature */
+ private final float minTemp;
+ /** Maximum temperature */
+ private final float maxTemp;
+ /** Pressure */
+ private final float pressure;
+ /** Humidity */
+ private final float humidity;
+
+ /**
+ * Non-parameterized constructor
+ *
+ *
Initializes variables as per following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ */
+ public Main() {
+ this.temp = Float.NaN;
+ this.minTemp = Float.NaN;
+ this.maxTemp = Float.NaN;
+ this.pressure = Float.NaN;
+ this.humidity = Float.NaN;
+ }
+
+ /**
+ * Parameterized constructor
+ *
+ * Initializes variables from values from the given JSON object.
+ *
+ * @param jsonObj JSON object containing data about main weather
+ * elements. For example, temperature, pressure, etc.
+ */
+ public 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);
+ }
+
+ /**
+ * Tells if the data for temperature of the city is available or not.
+ * @return true
if data available, otherwise false
+ */
+ public boolean hasTemperature() {
+ return (this.temp != Float.NaN);
+ }
+
+ /**
+ * Tells if the data for minimum temperature of the city is available or not.
+ * @return true
if data available, otherwise false
+ */
+ public boolean hasMinTemperature() {
+ return (this.minTemp != Float.NaN);
+ }
+
+ /**
+ * Tells if the data for maximum temperature of the city is available or not.
+ * @return true
if data available, otherwise false
+ */
+ public boolean hasMaxTemperature() {
+ return (this.maxTemp != Float.NaN);
+ }
+
+ /**
+ * Tells if the data for pressure of the city is available or not.
+ * @return true
if data available, otherwise false
+ */
+ public boolean hasPressure() {
+ return (this.pressure != Float.NaN);
+ }
+
+ /**
+ * Tells if the data for humidity of the city is available or not.
+ * @return true
if data available, otherwise false
+ */
+ public boolean hasHumidity() {
+ return (this.humidity != Float.NaN);
+ }
+
+ /**
+ * Returns data for temperature of the city.
+ * @return Temperature of the city if available,
+ * otherwise Float.NaN
, i.e., Not a Number.
+ */
+ public float getTemperature() {
+ return this.temp;
+ }
+
+ /**
+ * Returns data for minimum temperature of the city.
+ * @return Minimum temperature of the city if available,
+ * otherwise Float.NaN
, i.e., Not a Number.
+ */
+ public float getMinTemperature() {
+ return this.minTemp;
+ }
+
+ /**
+ * Returns data for maximum temperature of the city.
+ * @return Maximum temperature of the city if available,
+ * otherwise Float.NaN
, i.e., Not a Number.
+ */
+ public float getMaxTemperature() {
+ return this.maxTemp;
+ }
+
+ /**
+ * Returns data for pressure of the city.
+ * @return Pressure of the city if available,
+ * otherwise Float.NaN
, i.e., Not a Number.
+ */
+ public float getPressure() {
+ return this.pressure;
+ }
+
+ /**
+ * Returns data for humidity of the city.
+ * @return Humidity of the city if available,
+ * otherwise Float.NaN
, i.e., Not a Number.
+ */
+ public float getHumidity() {
+ return this.humidity;
+ }
+ }
+
+
+ /**
+ * This class provides default implementations for Weather
.
+ * Standard behaviors like the has
and the get
+ * methods for information about weather (for example, id, name,
+ * description, icon, etc.) are defined here.
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/07/28
+ * @since 2.5.0.1
+ */
+ abstract public static class Weather {
+ /** Key for JSON variable in array Weather -> ID
*/
+ private final String JSON_WEATHER_ID = "id";
+ /** Key for JSON variable in array Weather -> Main (name of weather)
*/
+ private final String JSON_WEATHER_MAIN = "main";
+ /** Key for JSON variable Weather -> Description
*/
+ private final String JSON_WEATHER_DESCRIPTION = "description";
+ /** Key for JSON variable in array Weather -> Icon
*/
+ private final String JSON_WEATHER_ICON = "icon";
+
+ /** Weather ID */
+ private final int id;
+ /** Weather name */
+ private final String name;
+ /** Weather description */
+ private final String description;
+ /** Weather icon */
+ private final String icon;
+
+ /**
+ * Non-parameterized constructor
+ *
+ *
Initializes variables as per following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ */
+ public Weather() {
+ this.id = Integer.MIN_VALUE;
+ this.name = null;
+ this.description = null;
+ this.icon = null;
+ }
+
+ /**
+ * Parameterized constructor
+ *
+ * Initializes variables from values from the given JSON object.
+ *
+ * @param jsonObj JSON object containing data about weather id, name, etc.
+ */
+ public 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);
+ }
+
+ /**
+ * Tells if the data for weather's code is available or not.
+ * @return true
if data available, otherwise false
+ */
+ public boolean hasWeatherCode() {
+ return (this.id != Integer.MIN_VALUE);
+ }
+
+ /**
+ * Tells if the data for weather's name is available or not.
+ * @return true
if data available, otherwise false
+ */
+ public boolean hasWeatherName() {
+ return (this.name != null);
+ }
+
+ /**
+ * Tells if the data for weather's description is available or not.
+ * @return true
if data available, otherwise false
+ */
+ public boolean hasWeatherDescription() {
+ return (this.description != null);
+ }
+
+ /**
+ * Tells if the data for name of weather's icon is available or not.
+ * @return true
if data available, otherwise false
+ */
+ public boolean hasWeatherIconName() {
+ return (this.icon != null);
+ }
+
+ /**
+ * Returns data for code for weather of the city.
+ * @return Code for weather of the city if available,
+ * otherwise Integer.MIN_VALUE
+ */
+ public int getWeatherCode() {
+ return this.id;
+ }
+
+ /**
+ * Returns data for name for weather of the city.
+ * @return Name for weather of the city if available,
+ * otherwise null
+ */
+ public String getWeatherName() {
+ return this.name;
+ }
+
+ /**
+ * Returns data for description for weather of the city.
+ * @return Description for weather of the city if available,
+ * otherwise null
+ */
+ public String getWeatherDescription() {
+ return this.description;
+ }
+
+ /**
+ * Returns data for name of icon for weather of the city.
+ * @return Name of icon for weather of the city if available,
+ * otherwise null
+ */
+ public String getWeatherIconName() {
+ return this.icon;
+ }
+ }
+
+
+ /**
+ * This class provides default implementations for Wind
.
+ * Standard behaviors like the has
and the get
+ * methods for information about wind (for example, speed, degree,
+ * etc.) are defined here.
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/07/28
+ * @since 2.5.0.1
+ */
+ abstract public static class Wind {
+ /** Key for JSON variable Wind -> Speed
*/
+ private final String JSON_WIND_SPEED = "speed";
+ /** Key for JSON variable Wind -> Degree
*/
+ private final String JSON_WIND_DEGREE = "deg";
+
+ /** Wind speed */
+ private final float speed;
+ /** Wind degree (direction of wind) */
+ private final float degree;
+
+ /**
+ * Non-parameterized constructor
+ *
+ *
Initializes variables as per following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ */
+ public Wind() {
+ this.speed = Float.NaN;
+ this.degree = Float.NaN;
+ }
+
+ /**
+ * Parameterized constructor
+ *
+ * Initializes variables from values from the given JSON object.
+ *
+ * @param jsonObj JSON object containing data about wind
+ */
+ public 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);
+ }
+
+ /**
+ * Tells if the data for speed of wind in the city is available or not.
+ * @return true
if data available, otherwise false
+ */
+ public boolean hasWindSpeed() {
+ return (this.speed != Float.NaN);
+ }
+
+ /**
+ * Tells if the data for degree (degree gives direction) of wind
+ * in the city is available or not.
+ * @return true
if data available, otherwise false
+ */
+ public boolean hasWindDegree() {
+ return (this.hasWindSpeed() && (this.degree != Float.NaN));
+ }
+
+ /**
+ * Returns data for speed of wind in the city.
+ * @return Speed of wind in the city if available,
+ * otherwise Float.NaN
, i.e., Not a Number.
+ */
+ public float getWindSpeed() {
+ return this.speed;
+ }
+
+ /**
+ * Returns data for degree of wind in the city.
+ * @return Degree of wind in the city if available,
+ * otherwise Float.NaN
, i.e., Not a Number.
+ */
+ public float getWindDegree() {
+ return this.degree;
+ }
+ }
+
+
+ /*
+ ***********************
+ * Declaring this class
+ ***********************
+ */
+
+ /** Key for JSON variable Date-Time (date & time of the weather) */
+ private final String JSON_DATE_TIME = "dt";
+
+ /**
+ * Date and time of the weather. This is answer for the question that
+ * when is/will be this weather.
+ */
+ private final Date dateTime;
+
+ /**
+ * Non-parameterized constructor
+ *
+ *
Initializes variables as per following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ */
+ public AbstractWeatherData() {
+ this.dateTime = null;
+ }
+
+ /**
+ * Parameterized constructor
+ *
+ * Initializes variables from values from the given JSON object.
+ *
+ * @param jsonObj JSON object containing weather data
+ */
+ public AbstractWeatherData(JSONObject jsonObj) {
+ // getting seconds from the data
+ long sec = (jsonObj != null) ? jsonObj.optLong(this.JSON_DATE_TIME, Long.MIN_VALUE) : Long.MIN_VALUE;
+
+ // converting seconds to Date object
+ if (sec != Long.MIN_VALUE) {
+ this.dateTime = new Date(sec);
+ } else {
+ this.dateTime = null;
+ }
+ }
+
+ /**
+ * Tells if the data for date and time of this weather is available or not.
+ * @return true
if data available, otherwise false
+ */
+ public boolean hasDateTime() {
+ return (this.dateTime != null);
+ }
+
+ /**
+ * Returns data for date and time of this weather.
+ * @return Date and time (in object of {@link java.util.Date}) if available,
+ * otherwise null
+ */
+ public Date getDateTime() {
+ return this.dateTime;
+ }
+}
diff --git a/src/net/aksingh/java/api/owm/CurrentWeatherData.java b/src/net/aksingh/java/api/owm/CurrentWeatherData.java
new file mode 100644
index 0000000..3caa8ca
--- /dev/null
+++ b/src/net/aksingh/java/api/owm/CurrentWeatherData.java
@@ -0,0 +1,656 @@
+/*
+ * Copyright (C)2013 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 shall be used for Good, not Evil.
+ *
+ * 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.
+ */
+package net.aksingh.java.api.owm;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import org.json.JSONArray;
+import org.json.JSONObject;
+
+/**
+ * Parses current weather data (from the JSON data) and provides methods
+ * to get/access the information about current weather.
+ * This class provides has
and get
methods
+ * to access the information.
+ *
+ *
has
methods can be used to check
+ * if the data exists, i.e., if the data was available (successfully
+ * downloaded) and was parsed correctly.
+ *
+ *
get
methods can be used to access the data, if the data
+ * exists, otherwise get
methods will give value as per
+ * following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/08/07
+ * @since 2.5.0.1
+ */
+public class CurrentWeatherData extends AbstractWeatherData {
+ /** Key for JSON object - Rain */
+ private final String JSON_RAIN = "rain";
+ /** Key for JSON object - Sys */
+ private final String JSON_SYS = "sys";
+
+
+ /*
+ ************************
+ * Declaring sub-classes
+ ************************
+ */
+
+ /**
+ * Parses data about clouds (from the JSON data) and provides methods
+ * to get/access the information.
+ * This class provides has
and get
methods
+ * to access the information.
+ *
+ *
has
methods can be used to check
+ * if the data exists, i.e., if the data was available (successfully
+ * downloaded) and was parsed correctly.
+ *
+ *
get
methods can be used to access the data, if the data
+ * exists, otherwise get
methods will give value as per
+ * following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/08/07
+ * @since 2.5.0.1
+ */
+ public static class Clouds extends AbstractWeatherData.Clouds {
+
+ /**
+ * Non-parameterized constructor
+ *
+ *
Initializes variables as per following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ */
+ public Clouds() {
+ super();
+ }
+
+ /**
+ * Parameterized constructor
+ *
+ * Initializes variables from values from the given JSON object.
+ *
+ * @param jsonObj JSON object containing data about clouds
+ */
+ public Clouds(JSONObject jsonObj) {
+ super(jsonObj);
+ }
+ }
+
+
+ /**
+ * Parses data about geographic coordinates (from the JSON data)
+ * and provides methods to get/access the information.
+ * This class provides has
and get
methods
+ * to access the information.
+ *
+ *
has
methods can be used to check
+ * if the data exists, i.e., if the data was available (successfully
+ * downloaded) and was parsed correctly.
+ *
+ *
get
methods can be used to access the data, if the data
+ * exists, otherwise get
methods will give value as per
+ * following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/08/07
+ * @since 2.5.0.1
+ */
+ public static class Coord extends AbstractWeatherData.Coord {
+
+ /**
+ * Non-parameterized constructor
+ *
+ *
Initializes variables as per following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ */
+ public Coord() {
+ super();
+ }
+
+ /**
+ * Parameterized constructor
+ *
+ * Initializes variables from values from the given JSON object.
+ *
+ * @param jsonObj JSON object containing data about coordinates
+ */
+ public Coord(JSONObject jsonObj) {
+ super(jsonObj);
+ }
+ }
+
+
+ /**
+ * Parses data about main weather elements (from the JSON data) and
+ * provides methods to get/access the information.
+ * This class provides has
and get
methods
+ * to access the information.
+ *
+ *
has
methods can be used to check
+ * if the data exists, i.e., if the data was available (successfully
+ * downloaded) and was parsed correctly.
+ *
+ *
get
methods can be used to access the data, if the data
+ * exists, otherwise get
methods will give value as per
+ * following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/08/07
+ * @since 2.5.0.1
+ */
+ public static class Main extends AbstractWeatherData.Main {
+
+ /**
+ * Non-parameterized constructor
+ *
+ *
Initializes variables as per following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ */
+ public Main() {
+ super();
+ }
+
+ /**
+ * Parameterized constructor
+ *
+ * Initializes variables from values from the given JSON object.
+ *
+ * @param jsonObj JSON object containing data about main
+ * weather elements (temperature, pressure, etc.)
+ */
+ public Main(JSONObject jsonObj) {
+ super(jsonObj);
+ }
+ }
+
+
+ /**
+ * Parses data about rain (from the JSON data) and provides methods
+ * to get/access the information.
+ * This class provides has
and get
methods
+ * to access the information.
+ *
+ *
has
methods can be used to check
+ * if the data exists, i.e., if the data was available (successfully
+ * downloaded) and was parsed correctly.
+ *
+ *
get
methods can be used to access the data, if the data
+ * exists, otherwise get
methods will give value as per
+ * following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/08/07
+ * @since 2.5.0.1
+ */
+ public static class Rain {
+ /** Key for JSON variable Rain -> Rain per 3 hours
*/
+ private final String JSON_RAIN_3HOURS = "3h";
+
+ /** Rain per 3 hours */
+ private final float rain3h;
+
+ /**
+ * Non-parameterized constructor
+ *
+ *
Initializes variables as per following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ */
+ public Rain() {
+ this.rain3h = Float.NaN;
+ }
+
+ /**
+ * Parameterized constructor
+ *
+ * Initializes variables from values from the given JSON object.
+ *
+ * @param jsonObj JSON object containing data about rain
+ */
+ public Rain(JSONObject jsonObj) {
+ this.rain3h = (float) jsonObj.optDouble(this.JSON_RAIN_3HOURS, Double.NaN);
+ }
+
+ public boolean hasRain3Hours() {
+ return (this.rain3h != Float.NaN);
+ }
+
+ public float getRain3Hours() {
+ return this.rain3h;
+ }
+ }
+
+
+ /**
+ * Parses data about country, sunrise, and sunset (from the JSON data)
+ * and provides methods to get/access the information.
+ * This class provides has
and get
methods
+ * to access the information.
+ *
+ *
has
methods can be used to check
+ * if the data exists, i.e., if the data was available (successfully
+ * downloaded) and was parsed correctly.
+ *
+ *
get
methods can be used to access the data, if the data
+ * exists, otherwise get
methods will give value as per
+ * following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/08/07
+ * @since 2.5.0.1
+ */
+ public static class Sys {
+ /** Key for JSON variable Sys -> Country
*/
+ private final String JSON_SYS_COUNTRY_CODE = "country";
+ /** Key for JSON variable Sys -> Sunrise
*/
+ private final String JSON_SYS_SUNRISE = "sunrise";
+ /** Key for JSON variable Sys -> Sunset
*/
+ private final String JSON_SYS_SUNSET = "sunset";
+
+ /** Country code for the city */
+ private final String countryCode;
+ /** Sunrise time */
+ private final Date sunrise;
+ /** Sunset time */
+ private final Date sunset;
+
+ /**
+ * Non-parameterized constructor
+ *
+ *
Initializes variables as per following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ */
+ public Sys() {
+ this.countryCode = null;
+ this.sunrise = null;
+ this.sunset = null;
+ }
+
+ /**
+ * Parameterized constructor
+ *
+ * Initializes variables from values from the given JSON object.
+ *
+ * @param jsonObj JSON object containing data about country, sunrise,
+ * and sunset.
+ */
+ public Sys(JSONObject jsonObj) {
+ this.countryCode = jsonObj.optString(this.JSON_SYS_COUNTRY_CODE, null);
+
+ long sr_secs = jsonObj.optLong(this.JSON_SYS_SUNRISE, Long.MIN_VALUE);
+ if (sr_secs != Long.MIN_VALUE) {
+ this.sunrise = new Date(sr_secs);
+ } else {
+ this.sunrise = null;
+ }
+
+ long ss_secs = jsonObj.optLong(this.JSON_SYS_SUNSET, Long.MIN_VALUE);
+ if (ss_secs != Long.MIN_VALUE) {
+ this.sunset = new Date(ss_secs);
+ } else {
+ this.sunset = null;
+ }
+ }
+
+ public boolean hasCountryCode() {
+ return (this.countryCode != null);
+ }
+
+ public boolean hasSunriseTime() {
+ return (this.sunrise != null);
+ }
+
+ public boolean hasSunsetTime() {
+ return (this.sunset != null);
+ }
+
+ public String getCountryCode() {
+ return this.countryCode;
+ }
+
+ public Date getSunriseTime() {
+ return this.sunrise;
+ }
+
+ public Date getSunsetTime() {
+ return this.sunset;
+ }
+ }
+
+
+ /**
+ * Parses data about weather code, name, etc. (from the JSON data)
+ * and provides methods to get/access the information.
+ * This class provides has
and get
methods
+ * to access the information.
+ *
+ *
has
methods can be used to check
+ * if the data exists, i.e., if the data was available (successfully
+ * downloaded) and was parsed correctly.
+ *
+ *
get
methods can be used to access the data, if the data
+ * exists, otherwise get
methods will give value as per
+ * following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/08/07
+ * @since 2.5.0.1
+ */
+ public static class Weather extends AbstractWeatherData.Weather {
+
+ /**
+ * Non-parameterized constructor
+ *
+ *
Initializes variables as per following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ */
+ public Weather () {
+ super();
+ }
+
+ /**
+ * Parameterized constructor
+ *
+ * Initializes variables from values from the given JSON object.
+ *
+ * @param jsonObj JSON object containing data about weather id, name, etc.
+ */
+ public Weather (JSONObject jsonObj) {
+ super(jsonObj);
+ }
+ }
+
+
+ /**
+ * Parses data about winds (from the JSON data) and provides methods
+ * to get/access the information.
+ * This class provides has
and get
methods
+ * to access the information.
+ *
+ *
has
methods can be used to check
+ * if the data exists, i.e., if the data was available (successfully
+ * downloaded) and was parsed correctly.
+ *
+ *
get
methods can be used to access the data, if the data
+ * exists, otherwise get
methods will give value as per
+ * following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/08/07
+ * @since 2.5.0.1
+ */
+ public static class Wind extends AbstractWeatherData.Wind {
+ /** Key for JSON variable Wind -> Gust
*/
+ private final String JSON_WIND_GUST = "gust";
+
+ /** Wind gust */
+ private final float gust;
+
+ /**
+ * Non-parameterized constructor
+ *
+ *
Initializes variables as per following basis: Initializes variables as per following basis: Initializes variables as per following basis: Initializes variables as per following basis: Initializes variables as per following basis: Initializes variables as per following basis: Initializes variables as per following basis: Initializes variables as per following basis: Initializes variables as per following basis: Initializes variables as per following basis: Initializes variables as per following basis: Initializes variables as per following basis: Initializes variables as per following basis: Initializes variables as per following basis: Note: This class directly do not provide any functions, but has
+ * NOTE: Note: This function checks and stricts only some parts of the
+ * URL, which are necessary to be corrected for accessing data from
+ * the OpenWeatherMap.org
+ *
+ * @param inputString String to be converted to strict HTML address
+ * @return HTML standards-followed and stricted URL
+ */
+ public static String strictAddress(String inputString) {
+ String outputString = "";
+
+ if (inputString != null) {
+ outputString = inputString.replace(" ", "%20").replace(".", "%2E");
+ }
+
+ return outputString;
+ }
+ }
+
+
+ /**
+ * Provides methods to do conversions.
+ * For example, converting degree to direction, etc.
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/08/05
+ * @since 2.5.0.1
+ */
+ public static class Convertor {
+
+ /**
+ * Converts degree to direction.
+ * @return Direction
+ *
+ * @throws IllegalArgumentException
+ * Degree should be between 0 and 360.
+ */
+ public String convertDegree2Direction(float degree)
+ throws IllegalArgumentException{
+ String direction;
+
+ // degree should be between 0 and 360
+ if ((degree < 0.0f) || (degree > 360.0f)) {
+ throw new IllegalArgumentException("Degree cannot be less than 0 or more than 360.");
+ }
+
+ if (degree <= 11.25f) {
+ direction = "N";
+ }
+ else if (degree <= 33.75f) {
+ direction = "NNE";
+ }
+ else if (degree <= 56.25f) {
+ direction = "NE";
+ }
+ else if (degree <= 78.75f) {
+ direction = "ENE";
+ }
+ else if (degree <= 101.25f) {
+ direction = "E";
+ }
+ else if (degree <= 123.75f) {
+ direction = "ESE";
+ }
+ else if (degree <= 146.25f) {
+ direction = "SE";
+ }
+ else if (degree <= 168.75f) {
+ direction = "SSE";
+ }
+ else if (degree <= 191.25f) {
+ direction = "S";
+ }
+ else if (degree <= 213.75f) {
+ direction = "SSW";
+ }
+ else if (degree <= 236.25f) {
+ direction = "SW";
+ }
+ else if (degree <= 258.75f) {
+ direction = "WSW";
+ }
+ else if (degree <= 281.25f) {
+ direction = "W";
+ }
+ else if (degree <= 303.75f) {
+ direction = "WNW";
+ }
+ else if (degree <= 326.25f) {
+ direction = "NW";
+ }
+ else if (degree <= 348.75f) {
+ direction = "NNW";
+ }
+ else {
+ direction = "N";
+ }
+
+ return direction;
+ }
+ }
+}
\ No newline at end of file
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ */
+ public Wind () {
+ super ();
+
+ this.gust = Float.NaN;
+ }
+
+ /**
+ * Parameterized constructor
+ *
+ * Initializes variables from values from the given JSON object.
+ *
+ * @param jsonObj JSON object containing data about wind
+ */
+ public Wind (JSONObject jsonObj) {
+ super (jsonObj);
+
+ this.gust = (float) jsonObj.optDouble(this.JSON_WIND_GUST, Double.NaN);
+ }
+
+ public boolean hasWindGust() {
+ return (this.gust != Float.NaN);
+ }
+
+ public float getWindGust() {
+ return this.gust;
+ }
+ }
+
+
+ /*
+ ***********************
+ * Declaring this class
+ ***********************
+ */
+
+ /** Key for JSON variable Base
*/
+ private final String JSON_BASE = "base";
+ /** Key for JSON variable City code (ID)
*/
+ private final String JSON_CITY_ID = "id";
+ /** Key for JSON variable City name
*/
+ private final String JSON_CITY_NAME = "name";
+ /** Key for JSON variable Response code
*/
+ private final String JSON_RESPONSE_CODE = "cod";
+
+ /** Base */
+ private final String base;
+ /** City code (ID) */
+ private final long cityID;
+ /** City name */
+ private final String cityName;
+ /** Response code */
+ private final int responseCode;
+
+ private final Clouds clouds;
+ private final Coord coord;
+ private final Main main;
+ private final Rain rain;
+ private final Sys sys;
+ private final Wind wind;
+
+ /** List of weather information (code, name, etc.) */
+ private final Listhas
and get
methods
+ * to access the information.
+ *
+ * has
methods can be used to check
+ * if the data exists, i.e., if the data was available (successfully
+ * downloaded) and was parsed correctly.
+ *
+ * get
methods can be used to access the data, if the data
+ * exists, otherwise get
methods will give value as per
+ * following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Objects: Data initialized with default/non-parameterized constructor
+ * Others: null
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/08/07
+ * @since 2.5.0.1
+ */
+public class DailyForecastData {
+ /** Key for JSON object - City */
+ private final String JSON_CITY = "city";
+ /** Key for JSON object - List of forecasts */
+ private final String JSON_FORECAST_LIST = "list";
+
+
+ /*
+ ************************
+ * Declaring sub-classes
+ ************************
+ */
+
+ /**
+ * Parses data about city (from the JSON data)
+ * and provides methods to get/access the information.
+ * For example, city name, coordinates, country name, population, etc.
+ * This class provides has
and get
methods
+ * to access the information.
+ *
+ * has
methods can be used to check
+ * if the data exists, i.e., if the data was available (successfully
+ * downloaded) and was parsed correctly.
+ *
+ * get
methods can be used to access the data, if the data
+ * exists, otherwise get
methods will give value as per
+ * following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/08/07
+ * @since 2.5.0.1
+ */
+ public static class City {
+ /** Key for JSON object - Coordinates */
+ private final String JSON_CITY_COORD = "coord";
+
+
+ /**
+ * Parses data about geographic coordinates (from the JSON data)
+ * and provides methods to get/access the information.
+ * This class provides has
and get
methods
+ * to access the information.
+ *
+ * has
methods can be used to check
+ * if the data exists, i.e., if the data was available (successfully
+ * downloaded) and was parsed correctly.
+ *
+ * get
methods can be used to access the data, if the data
+ * exists, otherwise get
methods will give value as per
+ * following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/08/07
+ * @since 2.5.0.1
+ */
+ public static class Coord extends AbstractWeatherData.Coord {
+
+ /**
+ * Non-parameterized constructor
+ *
+ *
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ */
+ public Coord() {
+ super();
+ }
+
+ /**
+ * Parameterized constructor
+ *
+ * Initializes variables from values from the given JSON object.
+ *
+ * @param jsonObj JSON object containing data about clouds
+ */
+ public Coord(JSONObject jsonObj) {
+ super(jsonObj);
+ }
+ }
+
+
+ /** Key for JSON variable City code (ID)
*/
+ private final String JSON_CITY_ID = "id";
+ /** Key for JSON variable City name
*/
+ private final String JSON_CITY_NAME = "name";
+ /** Key for JSON variable Country code of city
*/
+ private final String JSON_CITY_COUNTRY_CODE = "country";
+ /** Key for JSON variable Population of city
*/
+ private final String JSON_CITY_POPULATION = "population";
+
+ /** City code (ID) */
+ private final long cityID;
+ /** City name */
+ private final String cityName;
+ /** Country code of city */
+ private final String countryCode;
+ /** Population of city */
+ private final long population;
+
+ private final Coord coord;
+
+ /**
+ * Non-parameterized constructor
+ *
+ *
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ */
+ public City() {
+ this.cityID = Long.MIN_VALUE;
+ this.cityName = null;
+ this.countryCode = null;
+ this.population = Long.MIN_VALUE;
+
+ this.coord = new Coord();
+ }
+
+ /**
+ * Parameterized constructor
+ *
+ * Initializes variables from values from the given JSON object.
+ *
+ * @param jsonObj JSON object containing data about city
+ */
+ public 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;
+
+ JSONObject jsonObjCoord = (jsonObj != null) ? jsonObj.optJSONObject(this.JSON_CITY_COORD) : null;
+ this.coord = (jsonObjCoord != null) ? new Coord(jsonObjCoord) : new Coord();
+ }
+
+ public boolean hasCityCode() {
+ return (this.cityID != Long.MIN_VALUE);
+ }
+
+ public boolean hasCityName() {
+ return (this.cityName != null);
+ }
+
+ public boolean hasCountryCode() {
+ return (this.countryCode != null);
+ }
+
+ public boolean hasCityPopulation() {
+ return (this.population != Long.MIN_VALUE);
+ }
+
+ public long getCityCode() {
+ return this.cityID;
+ }
+
+ public String getCityName() {
+ return this.cityName;
+ }
+
+ public String getCountryCode() {
+ return this.countryCode;
+ }
+
+ public long getCityPopulation() {
+ return this.population;
+ }
+
+ // Objects
+
+ public Coord getCoordinates_Object() {
+ return this.coord;
+ }
+ }
+
+
+ /**
+ * Parses data about forecasts (from the JSON data)
+ * and provides methods to get/access the information.
+ * This class provides has
and get
methods
+ * to access the information.
+ *
+ * has
methods can be used to check
+ * if the data exists, i.e., if the data was available (successfully
+ * downloaded) and was parsed correctly.
+ *
+ * get
methods can be used to access the data, if the data
+ * exists, otherwise get
methods will give value as per
+ * following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/08/07
+ * @since 2.5.0.1
+ */
+ public static class Forecast extends AbstractWeatherData {
+ /** Key for JSON object - Temperature */
+ public final String JSON_TEMP = "temp";
+
+ /*
+ ***************************
+ * Declaring sub-sub-classes
+ ***************************
+ */
+
+ /**
+ * Parses data about weather (from the JSON data)
+ * and provides methods to get/access the information.
+ * For example, weather id, name, etc.
+ * This class provides has
and get
methods
+ * to access the information.
+ *
+ * has
methods can be used to check
+ * if the data exists, i.e., if the data was available (successfully
+ * downloaded) and was parsed correctly.
+ *
+ * get
methods can be used to access the data, if the data
+ * exists, otherwise get
methods will give value as per
+ * following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/08/07
+ * @since 2.5.0.1
+ */
+ public static class Weather extends AbstractWeatherData.Weather {
+
+ /**
+ * Non-parameterized constructor
+ *
+ *
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ */
+ public Weather () {
+ super();
+ }
+
+ /**
+ * Parameterized constructor
+ *
+ * Initializes variables from values from the given JSON object.
+ *
+ * @param jsonObj JSON object containing data about weather
+ */
+ public Weather (JSONObject jsonObj) {
+ super(jsonObj);
+ }
+ }
+
+ /**
+ * Parses data about temperature (from the JSON data)
+ * and provides methods to get/access the information.
+ * For example, weather id, name, etc.
+ * This class provides has
and get
methods
+ * to access the information.
+ *
+ * has
methods can be used to check
+ * if the data exists, i.e., if the data was available (successfully
+ * downloaded) and was parsed correctly.
+ *
+ * get
methods can be used to access the data, if the data
+ * exists, otherwise get
methods will give value as per
+ * following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/08/07
+ * @since 2.5.0.1
+ */
+ public static class Temperature {
+ /** Key for JSON variable Temp -> Day
*/
+ public final String JSON_TEMP_DAY = "day";
+ /** Key for JSON variable Temp -> Minimum
*/
+ public final String JSON_TEMP_MIN = "min";
+ /** Key for JSON variable Temp -> Maximum
*/
+ public final String JSON_TEMP_MAX = "max";
+ /** Key for JSON variable Temp -> Night
*/
+ public final String JSON_TEMP_NIGHT = "night";
+ /** Key for JSON variable Temp -> Evening
*/
+ public final String JSON_TEMP_EVENING = "eve";
+ /** Key for JSON variable Temp -> Morning
*/
+ public final String JSON_TEMP_MORNING = "morn";
+
+ /** Day temperature */
+ private final float dayTemp;
+ /** Minimum temperature */
+ private final float minTemp;
+ /** Maximum temperature */
+ private final float maxTemp;
+ /** Night temperature */
+ private final float nightTemp;
+ /** Evening temperature */
+ private final float eveTemp;
+ /** Morning temperature */
+ private final float mornTemp;
+
+ /**
+ * Non-parameterized constructor
+ *
+ *
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ */
+ public Temperature() {
+ this.dayTemp = Float.NaN;
+ this.minTemp = Float.NaN;
+ this.maxTemp = Float.NaN;
+ this.nightTemp = Float.NaN;
+ this.eveTemp = Float.NaN;
+ this.mornTemp = Float.NaN;
+ }
+
+ /**
+ * Parameterized constructor
+ *
+ * Initializes variables from values from the given JSON object.
+ *
+ * @param jsonObj JSON object containing data about temperature
+ */
+ public 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;
+ }
+
+ public boolean hasDayTemperature() {
+ return (this.dayTemp != Float.NaN);
+ }
+
+ public boolean hasMinimumTemperature() {
+ return (this.minTemp != Float.NaN);
+ }
+
+ public boolean hasMaximumTemperature() {
+ return (this.maxTemp != Float.NaN);
+ }
+
+ public boolean hasNightTemperature() {
+ return (this.nightTemp != Float.NaN);
+ }
+
+ public boolean hasEveningTemperature() {
+ return (this.eveTemp != Float.NaN);
+ }
+
+ public boolean hasMorningTemperature() {
+ return (this.mornTemp != Float.NaN);
+ }
+
+ public float getDayTemperature() {
+ return this.dayTemp;
+ }
+
+ public float getMinimumTemperature() {
+ return this.minTemp;
+ }
+
+ public float getMaximumTemperature() {
+ return this.maxTemp;
+ }
+
+ public float getNightTemperature() {
+ return this.nightTemp;
+ }
+
+ public float getEveningTemperature() {
+ return this.eveTemp;
+ }
+
+ public float getMorningTemperature() {
+ return this.mornTemp;
+ }
+ }
+
+ /*
+ ************************
+ * Declaring this sub-class
+ ************************
+ */
+
+ /** Key for JSON variable Pressure
*/
+ private final String JSON_FORECAST_PRESSURE = "pressure";
+ /** Key for JSON variable Humidity
*/
+ private final String JSON_FORECAST_HUMIDITY = "humidity";
+ /** Key for JSON variable Wind speed
*/
+ private final String JSON_FORECAST_WIND_SPEED = "speed";
+ /** Key for JSON variable Wind degree
*/
+ private final String JSON_FORECAST_WIND_DEGREE = "deg";
+ /** Key for JSON variable Percentage of clouds
*/
+ private final String JSON_FORECAST_CLOUDS = "clouds";
+
+ /** Pressure */
+ private final float pressure;
+ /** Humidity */
+ private final float humidity;
+ /** Wind speed */
+ private final float windSpeed;
+ /** Wind degree */
+ private final float windDegree;
+ /** Percentage of clouds */
+ private final float cloudsPercent;
+
+ private final Temperature temp;
+
+ /** List of weather information (code, name, etc.) */
+ private final List
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ */
+ public Forecast() {
+ super();
+
+ this.pressure = Float.NaN;
+ this.humidity = Float.NaN;
+ this.windSpeed = Float.NaN;
+ this.windDegree = Float.NaN;
+ this.cloudsPercent = Float.NaN;
+
+ this.temp = new Temperature();
+
+ this.weatherList = Collections.EMPTY_LIST;
+ this.weatherListCount = this.weatherList.size();
+ }
+
+ /**
+ * Parameterized constructor
+ *
+ * Initializes variables from values from the given JSON object.
+ *
+ * @param jsonObj JSON object containing data about forecasts
+ */
+ public Forecast(JSONObject jsonObj) {
+ super(jsonObj);
+
+ JSONObject jsonObjTemp = (jsonObj != null) ? jsonObj.optJSONObject(this.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;
+
+ JSONArray jsonArrWeather = (jsonObj != null) ? jsonObj.optJSONArray(this.JSON_WEATHER) : null;
+ this.weatherList = (jsonArrWeather != null) ? new ArrayListResponse code
*/
+ private final String JSON_RESPONSE_CODE = "cod";
+ /** Key for JSON variable Response time
*/
+ private final String JSON_RESPONSE_TIME = "message";
+ /** Key for JSON variable Forecast count
*/
+ private final String JSON_RESPONSE_FORECAST_COUNT = "cnt";
+
+ /** Response code */
+ private final String responseCode;
+ /** Response time */
+ private final float responseTime;
+ /** Forecast count */
+ private final int responseForecastCount;
+
+ private final City city;
+
+ /** List of forecast information */
+ private final Listhas
and get
methods
+ * to access the information.
+ *
+ * has
methods can be used to check
+ * if the data exists, i.e., if the data was available (successfully
+ * downloaded) and was parsed correctly.
+ *
+ * get
methods can be used to access the data, if the data
+ * exists, otherwise get
methods will give value as per
+ * following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Objects: Data initialized with default/non-parameterized constructor
+ * Others: null
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/08/07
+ * @since 2.5.0.1
+ */
+public class ForecastWeatherData {
+ /** Key for JSON object - City */
+ private final String JSON_CITY = "city";
+ /** Key for JSON object - List of forecasts */
+ private final String JSON_FORECAST_LIST = "list";
+
+
+ /*
+ ************************
+ * Declaring sub-classes
+ ************************
+ */
+
+ /**
+ * Parses data about city (from the JSON data)
+ * and provides methods to get/access the information.
+ * For example, city name, coordinates, country name, population, etc.
+ * This class provides has
and get
methods
+ * to access the information.
+ *
+ * has
methods can be used to check
+ * if the data exists, i.e., if the data was available (successfully
+ * downloaded) and was parsed correctly.
+ *
+ * get
methods can be used to access the data, if the data
+ * exists, otherwise get
methods will give value as per
+ * following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/08/07
+ * @since 2.5.0.1
+ */
+ public static class City {
+ /** Key for JSON object - Coordinates */
+ private final String JSON_CITY_COORD = "coord";
+
+ /**
+ * Parses data about geographic coordinates (from the JSON data)
+ * and provides methods to get/access the information.
+ * This class provides has
and get
methods
+ * to access the information.
+ *
+ * has
methods can be used to check
+ * if the data exists, i.e., if the data was available (successfully
+ * downloaded) and was parsed correctly.
+ *
+ * get
methods can be used to access the data, if the data
+ * exists, otherwise get
methods will give value as per
+ * following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/08/07
+ * @since 2.5.0.1
+ */
+ public static class Coord extends AbstractWeatherData.Coord {
+
+ /**
+ * Non-parameterized constructor
+ *
+ *
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ */
+ public Coord() {
+ super();
+ }
+
+ /**
+ * Parameterized constructor
+ *
+ * Initializes variables from values from the given JSON object.
+ *
+ * @param jsonObj JSON object containing data about clouds
+ */
+ public Coord(JSONObject jsonObj) {
+ super(jsonObj);
+ }
+ }
+
+
+ /** Key for JSON variable City code (ID)
*/
+ private final String JSON_CITY_ID = "id";
+ /** Key for JSON variable City name
*/
+ private final String JSON_CITY_NAME = "name";
+ /** Key for JSON variable Country code of city
*/
+ private final String JSON_CITY_COUNTRY_CODE = "country";
+ /** Key for JSON variable Population of city
*/
+ private final String JSON_CITY_POPULATION = "population";
+
+ /** City code (ID) */
+ private final long cityID;
+ /** City name */
+ private final String cityName;
+ /** Country code of city */
+ private final String countryCode;
+ /** Population of city */
+ private final long population;
+
+ private final Coord coord;
+
+ /**
+ * Non-parameterized constructor
+ *
+ *
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ */
+ public City() {
+ this.cityID = Long.MIN_VALUE;
+ this.cityName = null;
+ this.countryCode = null;
+ this.population = Long.MIN_VALUE;
+
+ this.coord = new Coord();
+ }
+
+ /**
+ * Parameterized constructor
+ *
+ * Initializes variables from values from the given JSON object.
+ *
+ * @param jsonObj JSON object containing data about city
+ */
+ public 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;
+
+ JSONObject jsonObjCoord = (jsonObj != null) ? jsonObj.optJSONObject(this.JSON_CITY_COORD) : null;
+ this.coord = (jsonObjCoord != null) ? new Coord(jsonObjCoord) : new Coord();
+ }
+
+ public boolean hasCityCode() {
+ return (this.cityID != Long.MIN_VALUE);
+ }
+
+ public boolean hasCityName() {
+ return (this.cityName != null);
+ }
+
+ public boolean hasCountryCode() {
+ return (this.countryCode != null);
+ }
+
+ public boolean hasCityPopulation() {
+ return (this.population != Long.MIN_VALUE);
+ }
+
+ public long getCityCode() {
+ return this.cityID;
+ }
+
+ public String getCityName() {
+ return this.cityName;
+ }
+
+ public String getCountryCode() {
+ return this.countryCode;
+ }
+
+ public long getCityPopulation() {
+ return this.population;
+ }
+
+ // Objects
+
+ public Coord getCoordinates_Object() {
+ return this.coord;
+ }
+ }
+
+
+ /**
+ * Parses data about forecasts (from the JSON data)
+ * and provides methods to get/access the information.
+ * This class provides has
and get
methods
+ * to access the information.
+ *
+ * has
methods can be used to check
+ * if the data exists, i.e., if the data was available (successfully
+ * downloaded) and was parsed correctly.
+ *
+ * get
methods can be used to access the data, if the data
+ * exists, otherwise get
methods will give value as per
+ * following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/08/07
+ * @since 2.5.0.1
+ */
+ public static class Forecast extends AbstractWeatherData {
+ /** Key for JSON object - Sys (pod, etc.) */
+ private final String JSON_SYS = "sys";
+
+ /*
+ ***************************
+ * Declaring sub-sub-classes
+ ***************************
+ */
+
+ /**
+ * Parses data about clouds (from the JSON data)
+ * and provides methods to get/access the information.
+ * This class provides has
and get
methods
+ * to access the information.
+ *
+ * has
methods can be used to check
+ * if the data exists, i.e., if the data was available (successfully
+ * downloaded) and was parsed correctly.
+ *
+ * get
methods can be used to access the data, if the data
+ * exists, otherwise get
methods will give value as per
+ * following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/08/07
+ * @since 2.5.0.1
+ */
+ public static class Clouds extends AbstractWeatherData.Clouds {
+
+ /**
+ * Non-parameterized constructor
+ *
+ *
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ */
+ public Clouds() {
+ super();
+ }
+
+ /**
+ * Parameterized constructor
+ *
+ * Initializes variables from values from the given JSON object.
+ *
+ * @param jsonObj JSON object containing data about clouds
+ */
+ public Clouds(JSONObject jsonObj) {
+ super(jsonObj);
+ }
+ }
+
+ /**
+ * Parses data about main weather elements (from the JSON data)
+ * and provides methods to get/access the information.
+ * For example, temperature, pressure, sea level, etc.
+ * This class provides has
and get
methods
+ * to access the information.
+ *
+ * has
methods can be used to check
+ * if the data exists, i.e., if the data was available (successfully
+ * downloaded) and was parsed correctly.
+ *
+ * get
methods can be used to access the data, if the data
+ * exists, otherwise get
methods will give value as per
+ * following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/08/07
+ * @since 2.5.0.1
+ */
+ public static class Main extends AbstractWeatherData.Main {
+ /** Key for JSON variable Main -> Sea level
*/
+ private final String JSON_MAIN_SEA_LEVEL = "sea_level";
+ /** Key for JSON variable Main -> Ground level
*/
+ private final String JSON_MAIN_GRND_LEVEL = "grnd_level";
+ /** Key for JSON variable Main -> Temperature KF
*/
+ private final String JSON_MAIN_TMP_KF = "temp_kf";
+
+ /** Sea level */
+ private final float seaLevel;
+ /** Ground level */
+ private final float groundLevel;
+ /** Temperature KF */
+ private final float tempKF;
+
+ /**
+ * Non-parameterized constructor
+ *
+ *
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ */
+ public Main() {
+ super();
+
+ this.seaLevel = Float.NaN;
+ this.groundLevel = Float.NaN;
+ this.tempKF = Float.NaN;
+ }
+
+ /**
+ * Parameterized constructor
+ *
+ * Initializes variables from values from the given JSON object.
+ *
+ * @param jsonObj JSON object containing data about main
+ * weather elements
+ */
+ public 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;
+ }
+
+ public boolean hasSeaLevel() {
+ return (this.seaLevel != Float.NaN);
+ }
+
+ public boolean hasGroundLevel() {
+ return (this.groundLevel != Float.NaN);
+ }
+
+ public boolean hasTempKF() {
+ return (this.tempKF != Float.NaN);
+ }
+
+ public float getSeaLevel() {
+ return this.seaLevel;
+ }
+
+ public float getGroundLevel() {
+ return this.groundLevel;
+ }
+
+ public float getTempKF() {
+ return this.tempKF;
+ }
+ }
+
+ /**
+ * Parses data about main weather elements (from the JSON data)
+ * and provides methods to get/access the information.
+ * For example, temperature, pressure, sea level, etc.
+ * This class provides has
and get
methods
+ * to access the information.
+ *
+ * has
methods can be used to check
+ * if the data exists, i.e., if the data was available (successfully
+ * downloaded) and was parsed correctly.
+ *
+ * get
methods can be used to access the data, if the data
+ * exists, otherwise get
methods will give value as per
+ * following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/08/07
+ * @since 2.5.0.1
+ */
+ public static class Sys {
+ /** Key for JSON variable Sys -> Pod
*/
+ private final String JSON_SYS_POD = "pod";
+
+ /** Pod */
+ private final String pod;
+
+ /**
+ * Non-parameterized constructor
+ *
+ *
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ */
+ public Sys() {
+ this.pod = null;
+ }
+
+ /**
+ * Parameterized constructor
+ *
+ * Initializes variables from values from the given JSON object.
+ *
+ * @param jsonObj JSON object containing data about sys.
+ * For example, pod, etc.
+ */
+ public Sys(JSONObject jsonObj) {
+ this.pod = (jsonObj != null) ? jsonObj.optString(this.JSON_SYS_POD, null) : null;
+ }
+
+ public boolean hasPod() {
+ return (this.pod != null);
+ }
+
+ public String getPod() {
+ return this.pod;
+ }
+ }
+
+ /**
+ * Parses data about weather (from the JSON data)
+ * and provides methods to get/access the information.
+ * For example, weather id, name, etc.
+ * This class provides has
and get
methods
+ * to access the information.
+ *
+ * has
methods can be used to check
+ * if the data exists, i.e., if the data was available (successfully
+ * downloaded) and was parsed correctly.
+ *
+ * get
methods can be used to access the data, if the data
+ * exists, otherwise get
methods will give value as per
+ * following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/08/07
+ * @since 2.5.0.1
+ */
+ public static class Weather extends AbstractWeatherData.Weather {
+
+ /**
+ * Non-parameterized constructor
+ *
+ *
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ */
+ public Weather () {
+ super();
+ }
+
+ /**
+ * Parameterized constructor
+ *
+ * Initializes variables from values from the given JSON object.
+ *
+ * @param jsonObj JSON object containing data about weather
+ * code, name, etc.
+ */
+ public Weather (JSONObject jsonObj) {
+ super(jsonObj);
+ }
+ }
+
+ /**
+ * Parses data about wind (from the JSON data)
+ * and provides methods to get/access the information.
+ * This class provides has
and get
methods
+ * to access the information.
+ *
+ * has
methods can be used to check
+ * if the data exists, i.e., if the data was available (successfully
+ * downloaded) and was parsed correctly.
+ *
+ * get
methods can be used to access the data, if the data
+ * exists, otherwise get
methods will give value as per
+ * following basis:
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/08/07
+ * @since 2.5.0.1
+ */
+ public static class Wind extends AbstractWeatherData.Wind {
+
+ /**
+ * Non-parameterized constructor
+ *
+ *
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ */
+ public Wind () {
+ super ();
+ }
+
+ /**
+ * Parameterized constructor
+ *
+ * Initializes variables from values from the given JSON object.
+ *
+ * @param jsonObj JSON object containing data about wind
+ */
+ public Wind (JSONObject jsonObj) {
+ super (jsonObj);
+ }
+ }
+
+ /*
+ ************************
+ * Declaring this sub-class
+ ************************
+ */
+
+
+ /** Key for JSON variable Date time text
*/
+ private final String JSON_DATE_TIME_TEXT = "dt_txt";
+
+ /** Date time text */
+ private final String dateTimeText;
+
+ private final Clouds clouds;
+ private final Main main;
+ private final Sys sys;
+ private final Wind wind;
+
+ /** List of weather information (code, name, etc.) */
+ private final List
+ * Boolean: false
+ * Integral: Minimum value (MIN_VALUE)
+ * Floating point: Not a number (NaN)
+ * Others: null
+ */
+ public Forecast() {
+ super();
+
+ this.dateTimeText = null;
+
+ this.clouds = new Clouds();
+ this.main = new Main();
+ this.sys = new Sys();
+ this.weatherList = Collections.EMPTY_LIST;
+ this.weatherListCount = this.weatherList.size();
+ this.wind = new Wind();
+ }
+
+ /**
+ * Parameterized constructor
+ *
+ * Initializes variables from values from the given JSON object.
+ *
+ * @param jsonObj JSON object containing data about forecasts
+ */
+ public Forecast(JSONObject jsonObj) {
+ super(jsonObj);
+
+ this.dateTimeText = (jsonObj != null) ? jsonObj.optString(this.JSON_DATE_TIME_TEXT, null) : null;
+
+ JSONObject jsonObjClouds = (jsonObj != null) ? jsonObj.optJSONObject(this.JSON_CLOUDS) : null;
+ this.clouds = (jsonObjClouds != null) ? new Clouds(jsonObjClouds) : new Clouds();
+
+ JSONObject jsonObjMain = (jsonObj != null) ? jsonObj.optJSONObject(this.JSON_MAIN) : null;
+ this.main = (jsonObjMain != null) ? new Main(jsonObjMain) : new Main();
+
+ JSONObject jsonObjSys = (jsonObj != null) ? jsonObj.optJSONObject(this.JSON_SYS) : null;
+ this.sys = (jsonObjSys != null) ? new Sys(jsonObjSys) : new Sys();
+
+ JSONArray jsonArrWeather = (jsonObj != null) ? jsonObj.optJSONArray(this.JSON_WEATHER) : null;
+ this.weatherList = (jsonArrWeather != null) ? new ArrayListResponse code
*/
+ private final String JSON_RESPONSE_CODE = "cod";
+ /** Key for JSON variable Response time
*/
+ private final String JSON_RESPONSE_TIME = "message";
+ /** Key for JSON variable Forecast count
*/
+ private final String JSON_RESPONSE_FORECAST_COUNT = "cnt";
+
+ /** Response code */
+ private final String responseCode;
+ /** Response time */
+ private final float responseTime;
+ /** Forecast count */
+ private final int responseForecastCount;
+
+ private final City city;
+
+ /** List of forecast information */
+ private final Liststatic
sub-classes which provide various
+ * related tools, i.e., this class only behaves as the container for those
+ * classes.
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013-08-05
+ * @since 2.5.0.1
+ */
+public class Tools {
+
+ /**
+ * Provides methods to download data or files from the Internet.
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013-07-24
+ * @since 2.5.0.1
+ */
+ public static class Downloader {
+
+ /**
+ * Downloads a page/content from the Internet.
+ * This method gets the content of the web page, whose URL is given by
+ * the pageAddress
.
+ *
+ * pageAddress
should be a correct URL, else
+ * this method will throw {@link MalformedURLException}.
+ *
+ * @param pageAddress
+ * Address of the web page to get from the Internet.
+ *
+ * @return Content of the web page
+ *
+ * @throws MalformedURLException
+ * Address of the web page is not correct.
+ *
+ * @throws IOException
+ * Error while loading the page from the Internet or connection
+ * got disconnected.
+ */
+ public static String downloadPage(String pageAddress)
+ throws MalformedURLException, IOException {
+ String webPage = null;
+
+ URL url = new URL(pageAddress);
+ InputStream iStream = url.openStream();
+
+ if (iStream != null) {
+ // converting InputStream to String (as we require String)
+ webPage = (new Scanner(iStream)).useDelimiter("\\A").next();
+ }
+ iStream.close();
+
+ return webPage;
+ }
+ }
+
+
+ /**
+ * Provides functions to handle HTML, e.g., correcting
+ * non-compliant or non-strict web addresses, etc.
+ *
+ * @author Ashutosh Kumar Singh
+ * @version 2013/08/05
+ * @since 2.5.0.1
+ */
+ public static class HTML {
+
+ /**
+ * Stricts a non-strict or non-compliant web address
+ * to a proper URL.
+ *
+ *