net.degreedays.api.data
Class LocationDataRequest

java.lang.Object
  extended by net.degreedays.api.Request
      extended by net.degreedays.api.data.LocationDataRequest
All Implemented Interfaces:
java.io.Serializable

public final class LocationDataRequest
extends Request
implements java.io.Serializable

Defines a request for one or more sets of degree-day data from a particular location. A successfully-processed LocationDataRequest will result in a LocationDataResponse containing the specified data.

Here's an example showing how to create a request for one set of data from the EGLL weather station in London, UK. The request specifies heating degree days with a base temperature of 15.5 C, broken down on a daily basis and covering the whole of July 2011:

 Period period = Period.dayRange(Day.of(2011, 7, 1).to(Day.of(2011, 7, 31)));
 DatedBreakdown breakdown = DatedBreakdown.daily(period);
 Temperature baseTemp = Temperature.celsius(15.5);
 Calculation calculation = Calculation.heatingDegreeDays(baseTemp);
 DatedDataSpec dataSpec = DataSpec.dated(calculation, breakdown);
 Location location = Location.stationId("EGLL");
 LocationDataRequest request = new LocationDataRequest(
         location, new DataSpecs(dataSpec));
 

Here's an example showing how to create a request for two sets of data from Times Square in New York. We specify the location as a zip code (a type of GeographicLocation), leaving it to the API to choose the most appropriate weather station in the area. The request specifies heating degree days with a base temperature of 55 F, and cooling degree days with a base temperature of 65 F, both broken down on a monthly basis and covering the last 12 months:

 DatedBreakdown breakdown = DatedBreakdown.monthly(Period.latestValues(12));
 DatedDataSpec hddSpec = DataSpec.dated(
         Calculation.heatingDegreeDays(Temperature.fahrenheit(55)),
         breakdown);
 DatedDataSpec cddSpec = DataSpec.dated(
         Calculation.coolingDegreeDays(Temperature.fahrenheit(65)),
         breakdown);
 LocationDataRequest request = new LocationDataRequest(
         Location.postalCode("10036", "US"),
         new DataSpecs(new DataSpec[] { hddSpec, cddSpec }));
 

See DataApi for an example of how to submit a LocationDataRequest to the API and get a LocationDataResponse back containing the data you requested.

See Also:
DataApi.getLocationData(LocationDataRequest)

Instances of this class are immutable. You can safely reuse them and call them from multiple threads at once.


Constructor Summary
LocationDataRequest(Location location, DataSpecs dataSpecs)
          Constructs a LocationDataRequest object with the specified Location and DataSpecs.
 
Method Summary
 DataSpecs dataSpecs()
          Returns the non-null DataSpecs object that specifies how the set(s) of data should be calculated and broken down.
 boolean equals(java.lang.Object o)
          Two LocationDataRequest objects are equal if it can be ascertained that they are specifying the same set(s) of data from the same location.
 int hashCode()
          Overridden to ensure consistency with equals.
 Location location()
          Returns the non-null Location object that specifies the location for which the degree days should be generated.
 java.lang.String toString()
          Returns a non-null, non-empty string representation of this object for logging and debugging purposes.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LocationDataRequest

public LocationDataRequest(Location location,
                           DataSpecs dataSpecs)
Constructs a LocationDataRequest object with the specified Location and DataSpecs.

Parameters:
location - the non-null location for which the degree days should be generated.
dataSpecs - the non-null specification of how the set(s) of data should be calculated and broken down.
Throws:
java.lang.NullPointerException - if location or dataSpecs is null.
Method Detail

location

public Location location()
Returns the non-null Location object that specifies the location for which the degree days should be generated.


dataSpecs

public DataSpecs dataSpecs()
Returns the non-null DataSpecs object that specifies how the set(s) of data should be calculated and broken down.


equals

public boolean equals(java.lang.Object o)
Two LocationDataRequest objects are equal if it can be ascertained that they are specifying the same set(s) of data from the same location. In other words, they are equal if their dataSpecs() objects are equal and their location() objects are equal.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overridden to ensure consistency with equals.

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Returns a non-null, non-empty string representation of this object for logging and debugging purposes.

The exact details of the representation are unspecified and subject to change.

Overrides:
toString in class java.lang.Object


www.degreedays.net/api/