weather_service.weatherprovider
Class WeatherGateway

java.lang.Object
  extended by weather_service.weatherprovider.WeatherGateway

public class WeatherGateway
extends java.lang.Object

Gateway to the weather.com XML Data Feed. Performs its own caching, in compliance with the mandatory refresh rates in the weather.com implementation guide.


Field Summary
protected static org.apache.commons.logging.Log LOG
           
 
Constructor Summary
WeatherGateway(WeatherConfigurationIF config)
           
 
Method Summary
protected  SearchLocations doSearchQuery(org.apache.commons.httpclient.NameValuePair[] queryString)
           
protected  WeatherReport doWeatherQuery(java.lang.String locationID, long allowedAge, org.apache.commons.httpclient.NameValuePair[] query)
          this method actually performs the "local" query against the weather.com server.
 WeatherReport getCurrentConditions(java.lang.String locationID)
           
 WeatherReport getCurrentConditions(java.lang.String locationID, boolean metricSystem)
           
static WeatherGateway getDefaultInstance()
           
 WeatherReport getForecast(java.lang.String locationID, int forecastLength)
           
 WeatherReport getForecast(java.lang.String locationID, int forecastLength, boolean metricSystem)
           
 WeatherReport getFullForecast(java.lang.String locationID, int forecastLength)
           
 WeatherReport getLocation(java.lang.String locationID)
           
 SearchLocations searchForLocations(java.lang.String where)
           
 void setDefaultMetricSystem(boolean defaultMetricSystem)
           
 void setUIHook(Task.ProgressMonitor.UIHookAdapter hook)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LOG

protected static org.apache.commons.logging.Log LOG
Constructor Detail

WeatherGateway

public WeatherGateway(WeatherConfigurationIF config)
Method Detail

getDefaultInstance

public static WeatherGateway getDefaultInstance()

setUIHook

public void setUIHook(Task.ProgressMonitor.UIHookAdapter hook)

searchForLocations

public SearchLocations searchForLocations(java.lang.String where)
                                   throws WeatherError,
                                          java.io.IOException
Throws:
WeatherError
java.io.IOException

doSearchQuery

protected SearchLocations doSearchQuery(org.apache.commons.httpclient.NameValuePair[] queryString)
                                 throws WeatherError,
                                        java.io.IOException
Throws:
WeatherError
java.io.IOException

getFullForecast

public WeatherReport getFullForecast(java.lang.String locationID,
                                     int forecastLength)
                              throws WeatherError,
                                     java.io.IOException
Throws:
WeatherError
java.io.IOException

getLocation

public WeatherReport getLocation(java.lang.String locationID)
                          throws WeatherError,
                                 java.io.IOException
Throws:
WeatherError
java.io.IOException

getCurrentConditions

public WeatherReport getCurrentConditions(java.lang.String locationID)
                                   throws WeatherError,
                                          java.io.IOException
Throws:
WeatherError
java.io.IOException

getCurrentConditions

public WeatherReport getCurrentConditions(java.lang.String locationID,
                                          boolean metricSystem)
                                   throws java.io.IOException,
                                          WeatherError
Throws:
java.io.IOException
WeatherError

getForecast

public WeatherReport getForecast(java.lang.String locationID,
                                 int forecastLength)
                          throws java.io.IOException,
                                 WeatherError
Throws:
java.io.IOException
WeatherError

getForecast

public WeatherReport getForecast(java.lang.String locationID,
                                 int forecastLength,
                                 boolean metricSystem)
                          throws java.io.IOException,
                                 WeatherError
Throws:
java.io.IOException
WeatherError

setDefaultMetricSystem

public void setDefaultMetricSystem(boolean defaultMetricSystem)

doWeatherQuery

protected WeatherReport doWeatherQuery(java.lang.String locationID,
                                       long allowedAge,
                                       org.apache.commons.httpclient.NameValuePair[] query)
                                throws WeatherError,
                                       java.io.IOException
this method actually performs the "local" query against the weather.com server. the response is an XML document with the element and data, or an elment and errors. It should not return an empty document - if it does, then an a WeatherError.WEATHER_PARSING_ERROR will be thrown. If there is a problem getting this call over the network, then an IOException is thrown.

Throws:
WeatherError
java.io.IOException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object