net.aksingh.owmjapis
Class OpenWeatherMap

java.lang.Object
  extended by net.aksingh.owmjapis.OpenWeatherMap

public class OpenWeatherMap
extends java.lang.Object

Lets you access data from OpenWeatherMap.org using its Web APIs. Henceforth, it's shortened as OWM.org to ease commenting.

Sample code:
OpenWeatherMap.org owm = new OpenWeatherMap("your-api-key");
OpenWeatherMap.org owm = new OpenWeatherMap(your-units, "your-api-key");
OpenWeatherMap.org owm = new OpenWeatherMap(your-units, your-language, "your-api-key");

Since:
2.5.0.1
Version:
12/19/2014
Author:
Ashutosh Kumar Singh
See Also:
OpenWeatherMap.org, OpenWeatherMap.org API

Nested Class Summary
static class OpenWeatherMap.Language
          Languages that can be set for getting data from OWM.org
static class OpenWeatherMap.OWMAddress
          Generates addresses for accessing the information from OWM.org
static class OpenWeatherMap.Units
          Units that can be set for getting data from OWM.org
 
Constructor Summary
OpenWeatherMap(OpenWeatherMap.Units units, OpenWeatherMap.Language lang, java.lang.String apiKey)
          Constructor
OpenWeatherMap(OpenWeatherMap.Units units, java.lang.String apiKey)
          Constructor
OpenWeatherMap(java.lang.String apiKey)
          Constructor
 
Method Summary
 CurrentWeather currentWeatherByCityCode(long cityCode)
           
 CurrentWeather currentWeatherByCityName(java.lang.String cityName)
           
 CurrentWeather currentWeatherByCityName(java.lang.String cityName, java.lang.String countryCode)
           
 CurrentWeather currentWeatherByCoordinates(float latitude, float longitude)
           
 CurrentWeather currentWeatherFromRawResponse(java.lang.String response)
           
 DailyForecast dailyForecastByCityCode(long cityCode, byte count)
           
 DailyForecast dailyForecastByCityName(java.lang.String cityName, byte count)
           
 DailyForecast dailyForecastByCityName(java.lang.String cityName, java.lang.String countryCode, byte count)
           
 DailyForecast dailyForecastByCoordinates(float latitude, float longitude, byte count)
           
 DailyForecast dailyForecastFromRawResponse(java.lang.String response)
           
 java.lang.String getApiKey()
           
 OpenWeatherMap.Language getLang()
           
 java.lang.String getMode()
           
 OpenWeatherMap.OWMAddress getOwmAddressInstance()
           
 OpenWeatherMap.Units getUnits()
           
 HourlyForecast hourlyForecastByCityCode(long cityCode)
           
 HourlyForecast hourlyForecastByCityName(java.lang.String cityName)
           
 HourlyForecast hourlyForecastByCityName(java.lang.String cityName, java.lang.String countryCode)
           
 HourlyForecast hourlyForecastByCoordinates(float latitude, float longitude)
           
 HourlyForecast hourlyForecastFromRawResponse(java.lang.String response)
           
 void setApiKey(java.lang.String appId)
          Set API key for getting data from OWM.org
 void setLang(OpenWeatherMap.Language lang)
          Set language for getting data from OWM.org
 void setUnits(OpenWeatherMap.Units units)
          Set units for getting data from OWM.org
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OpenWeatherMap

public OpenWeatherMap(java.lang.String apiKey)
Constructor

Parameters:
apiKey - API key from OWM.org
See Also:
OWM.org API Key

OpenWeatherMap

public OpenWeatherMap(OpenWeatherMap.Units units,
                      java.lang.String apiKey)
Constructor

Parameters:
units - Any constant from Units
apiKey - API key from OWM.org
See Also:
OpenWeatherMap.Units, OWM.org API Key

OpenWeatherMap

public OpenWeatherMap(OpenWeatherMap.Units units,
                      OpenWeatherMap.Language lang,
                      java.lang.String apiKey)
Constructor

Parameters:
units - Any constant from Units
lang - Any constant from Language
apiKey - API key from OWM.org
See Also:
OpenWeatherMap.Units, OpenWeatherMap.Language, OWM.org's Multilingual support, OWM.org's API Key
Method Detail

getOwmAddressInstance

public OpenWeatherMap.OWMAddress getOwmAddressInstance()

getApiKey

public java.lang.String getApiKey()

getUnits

public OpenWeatherMap.Units getUnits()

getMode

public java.lang.String getMode()

getLang

public OpenWeatherMap.Language getLang()

setUnits

public void setUnits(OpenWeatherMap.Units units)
Set units for getting data from OWM.org

Parameters:
units - Any constant from Units
See Also:
OpenWeatherMap.Units

setApiKey

public void setApiKey(java.lang.String appId)
Set API key for getting data from OWM.org

Parameters:
appId - API key from OWM.org
See Also:
OWM.org's API Key

setLang

public void setLang(OpenWeatherMap.Language lang)
Set language for getting data from OWM.org

Parameters:
lang - Any constant from Language
See Also:
OpenWeatherMap.Language, OWM.org's Multilingual support

currentWeatherByCityName

public CurrentWeather currentWeatherByCityName(java.lang.String cityName)
                                        throws java.io.IOException,
                                               org.json.JSONException
Throws:
java.io.IOException
org.json.JSONException

currentWeatherByCityName

public CurrentWeather currentWeatherByCityName(java.lang.String cityName,
                                               java.lang.String countryCode)
                                        throws java.io.IOException,
                                               org.json.JSONException
Throws:
java.io.IOException
org.json.JSONException

currentWeatherByCityCode

public CurrentWeather currentWeatherByCityCode(long cityCode)
                                        throws org.json.JSONException
Throws:
org.json.JSONException

currentWeatherByCoordinates

public CurrentWeather currentWeatherByCoordinates(float latitude,
                                                  float longitude)
                                           throws org.json.JSONException
Throws:
org.json.JSONException

currentWeatherFromRawResponse

public CurrentWeather currentWeatherFromRawResponse(java.lang.String response)
                                             throws org.json.JSONException
Throws:
org.json.JSONException

hourlyForecastByCityName

public HourlyForecast hourlyForecastByCityName(java.lang.String cityName)
                                        throws java.io.IOException,
                                               org.json.JSONException
Throws:
java.io.IOException
org.json.JSONException

hourlyForecastByCityName

public HourlyForecast hourlyForecastByCityName(java.lang.String cityName,
                                               java.lang.String countryCode)
                                        throws java.io.IOException,
                                               org.json.JSONException
Throws:
java.io.IOException
org.json.JSONException

hourlyForecastByCityCode

public HourlyForecast hourlyForecastByCityCode(long cityCode)
                                        throws org.json.JSONException
Throws:
org.json.JSONException

hourlyForecastByCoordinates

public HourlyForecast hourlyForecastByCoordinates(float latitude,
                                                  float longitude)
                                           throws org.json.JSONException
Throws:
org.json.JSONException

hourlyForecastFromRawResponse

public HourlyForecast hourlyForecastFromRawResponse(java.lang.String response)
                                             throws org.json.JSONException
Throws:
org.json.JSONException

dailyForecastByCityName

public DailyForecast dailyForecastByCityName(java.lang.String cityName,
                                             byte count)
                                      throws java.io.IOException,
                                             org.json.JSONException
Throws:
java.io.IOException
org.json.JSONException

dailyForecastByCityName

public DailyForecast dailyForecastByCityName(java.lang.String cityName,
                                             java.lang.String countryCode,
                                             byte count)
                                      throws java.io.IOException,
                                             org.json.JSONException
Throws:
java.io.IOException
org.json.JSONException

dailyForecastByCityCode

public DailyForecast dailyForecastByCityCode(long cityCode,
                                             byte count)
                                      throws org.json.JSONException
Throws:
org.json.JSONException

dailyForecastByCoordinates

public DailyForecast dailyForecastByCoordinates(float latitude,
                                                float longitude,
                                                byte count)
                                         throws org.json.JSONException
Throws:
org.json.JSONException

dailyForecastFromRawResponse

public DailyForecast dailyForecastFromRawResponse(java.lang.String response)
                                           throws org.json.JSONException
Throws:
org.json.JSONException