com.oopitis.weather.owm
Class OwmLocation

java.lang.Object
  extended by com.oopitis.weather.GeoLocation
      extended by com.oopitis.weather.owm.OwmLocation

public class OwmLocation
extends GeoLocation

The type of location objects for querying Open Weather Map weather data.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.oopitis.weather.GeoLocation
GeoLocation.Coordinates
 
Constructor Summary
OwmLocation(float latitude, float longitude)
          Constructs a location with a pair of geographic coordinates.
OwmLocation(long id)
          Constructs a location with a city ID.
OwmLocation(java.lang.String city)
          Constructs a location with a city name.
OwmLocation(java.lang.String city, java.util.Locale country)
          Constructs a location with a city and the country it belongs to.
OwmLocation(java.lang.String city, java.lang.String county)
          Constructs a location with a city and the county it belongs to.
 
Method Summary
 java.lang.String toString()
          Returns a string representation of this location.
static java.lang.String toUrlQuery(GeoLocation loc)
          Constructs the URL query string for a GeoLocation object.
 
Methods inherited from class com.oopitis.weather.GeoLocation
formatCoordinate, getCity, getCoordinates, getId, getLocale, getRegion, getZipCode, newCoordinates
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OwmLocation

public OwmLocation(long id)
Constructs a location with a city ID.

Parameters:
id - the city ID
Throws:
java.lang.NullPointerException - if the given ID is null

OwmLocation

public OwmLocation(java.lang.String city)
Constructs a location with a city name.

Parameters:
city - the name of the city
Throws:
java.lang.NullPointerException - if the given city name is null

OwmLocation

public OwmLocation(java.lang.String city,
                   java.lang.String county)
Constructs a location with a city and the county it belongs to.

Parameters:
city - the city
county - the county that contains the city
Throws:
java.lang.NullPointerException - if the given city is null

OwmLocation

public OwmLocation(java.lang.String city,
                   java.util.Locale country)
Constructs a location with a city and the country it belongs to.

Parameters:
city - the city
country - a locale of the country. Only the country code of the locale is used.
Throws:
java.lang.NullPointerException - if the given city is null

OwmLocation

public OwmLocation(float latitude,
                   float longitude)
Constructs a location with a pair of geographic coordinates.

Parameters:
latitude - the latitude
longitude - the longitude
Throws:
java.lang.IllegalArgumentException - if the latitude or longitude is out of range
Method Detail

toUrlQuery

public static java.lang.String toUrlQuery(GeoLocation loc)
Constructs the URL query string for a GeoLocation object. The choice of identification is in the following order:
  1. The city ID.
  2. The latitude and the longitude.
  3. The city and the county.
  4. The city and the country.

Parameters:
loc - the GeoLocation object
Returns:
the URL query string

toString

public java.lang.String toString()
Description copied from class: GeoLocation
Returns a string representation of this location. The format is "[id] city, region zipCode, countryCode (countryName) @(latitude,longitude)".

Overrides:
toString in class GeoLocation
Returns:
a string representation of this location