|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.oopitis.weather.WeatherReport
public class WeatherReport
A group of weather data associated with a time and a location. This class is
fundamentally a wrapper of the data access interface
WeatherPropertyMap. Every WeatherReport object
belongs to a feature that outlines the data in it. A time and a location
are always associated with a weather report. The interpretation of the time
and location depends on the feature. For example, the time in a report from
WeatherService.CONDITIONS_HOUR indicates the hour of a day while
the time in a WeatherService.ALERT report generally means the
expiration date.
Weather reports are created by weather services as the result of queries.
While this class does not provide any iteration methods, it is possible to
discover all the data a weather report contains through the
Feature object. Here is an example:
Map<WeatherProperty, Object> data =
report.get(report.getFeature().getProperties(service));
for (Iterator<WeatherProperty> it = data.keySet().iterator();
it.hasNext();) {
WeatherProperty p = it.next();
Object rawData = data.get(p);
String display = p.format(rawData);
}
Note that the example above examines the data a report may have, not
the data it must have. Unless documented otherwise by a provider, the
availability of data is not guaranteed even though the property that
represents it is listed by the feature.
Implementation note: The type of the location object in this class is
not made generic because the location object in general is the same as the
one used in the query, although this is not required. A weather service
should clearly document the conditions if users are expected to cast the
location object to a subtype. For example, different subclasses of
GeoLocation may be used in reports from different features.
Feature.getProperties(WeatherService),
WeatherProperty.format(Object)| Constructor Summary | |
|---|---|
protected |
WeatherReport(Feature feature,
java.util.Date time,
GeoLocation location)
Creates a weather report without data. |
|
WeatherReport(Feature feature,
java.util.Date time,
GeoLocation location,
WeatherPropertyMap map)
Creates a weather report. |
| Method Summary | ||
|---|---|---|
|
get(WeatherProperty<T> property)
Gets the data represented by a weather property. |
|
java.util.Map<WeatherProperty,java.lang.Object> |
get(WeatherPropertySet set)
Gets the data for a set of weather properties. |
|
Feature |
getFeature()
Returns the feature to which this report belongs |
|
GeoLocation |
getLocation()
Returns the location associated with this report. |
|
|
getStandardDeviation(WeatherProperty<T> property)
Gets the variability of the data from which a property value is calculated. |
|
java.util.Date |
getTime()
Returns the time associated with this report. |
|
java.lang.String |
toString()
Returns a string representation of this report. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public WeatherReport(Feature feature,
java.util.Date time,
GeoLocation location,
WeatherPropertyMap map)
feature - the feature to which this report belongstime - the time associated with this reportlocation - the location associated with this reportmap - the weather data
java.lang.NullPointerException - if any of the arguments is null
protected WeatherReport(Feature feature,
java.util.Date time,
GeoLocation location)
WeatherPropertyMap to return data. By
default all data access methods return null.
feature - the feature to which this report belongstime - the time associated with this reportlocation - the location associated with this report
java.lang.NullPointerException - if any of the arguments is nullWeatherPropertyMap| Method Detail |
|---|
public final Feature getFeature()
public final java.util.Date getTime()
public final GeoLocation getLocation()
public <T> T get(WeatherProperty<T> property)
WeatherPropertyMap
get in interface WeatherPropertyMapT - the type of the dataproperty - the property for which the data is to be returned
null
if no data is available or if the given property is not
supportedpublic <T> T getStandardDeviation(WeatherProperty<T> property)
WeatherPropertyMapget(WeatherProperty)
is the average of all data collected, then the value returned by this
method shows how much variation or dispersion exists from the average.
Smaller variation implies higher confidence statistically.
Implementation note: While this method in general is only
applicable to numeric property values, the standard deviation does not
have to be an instance of java.lang.Number. The return
object however must have the same type as that of the property value.
When the comparison between the standard deviation
(returned by this method) and the mean (returned by
get(WeatherProperty)) is not obvious, a helper method may
be provided to illustrate the confidence level in other ways such as the
coefficient of variation in percentages.
getStandardDeviation in interface WeatherPropertyMapT - the data type of the property valueproperty - the property for which the data variability is to be
returned
null if such information is unavailable
or the given property is not supportedWeatherPropertyMap.get(WeatherProperty)public java.util.Map<WeatherProperty,java.lang.Object> get(WeatherPropertySet set)
set - the weather property set
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||