public class WeatherDistributor
extends java.util.AbstractMap<java.lang.Enum,java.lang.Object>
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String[] |
WEATHER_STATION_TYPES
Types of weather stations (abbreviations) to be appended to generic weather station data strings.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addWeatherListener(WeatherListener l)
Register a WeatherListener to be notified of updates in the weather data.
|
java.util.Set<java.util.Map.Entry<java.lang.Enum,java.lang.Object>> |
entrySet()
Returns a
Set view of the mappings contained in this map. |
java.lang.Object |
get(java.lang.Object key)
Returns the value to which the specified key is mapped,
or
null if this map contains no mapping for the key. |
java.lang.Number |
get(WeatherEnum e)
Fetch a numeric value from the weather data.
|
static WeatherDistributor |
getInstance()
Get the WeatherDistributor singleton.
|
static java.lang.String[] |
getWeatherModelNameStrings()
Returns an array of localized weather station model names, in the same order as the
standard abbreviations.
|
boolean |
isEmpty()
Returns
true if this map contains no key-value mappings. |
java.util.Set<java.lang.Enum> |
keySet()
Returns a Set view of the keys contained in this map.
|
void |
loadCurrentWeather(java.util.Map<? extends java.lang.Enum,?> extensions)
Copy weather data from some other map into the currentWeather map in this WeatherDistributor.
|
PositionlessWeatherReport |
makeWeatherMsg()
Build a PositionlessWeatherReport from the current state of the collected local weather data.
|
java.util.Map<java.lang.Enum,java.lang.Object> |
parseWeatherData(java.lang.String line,
java.util.Map<java.lang.Enum,java.lang.Object> currentWeather)
Decode weather data in Peet Bros format into the distributor's cache.
|
java.lang.Object |
put(WeatherEnum e,
java.lang.Object value)
Store a new value into the weather map.
|
void |
removeWeatherListener(WeatherListener l)
Deregister a WeatherListener so it will no longer be informed of changes in the local weather data.
|
int |
size()
Returns the number of key-value mappings in this map.
|
java.util.Collection<java.lang.Object> |
values()
Returns a Collection view of the values contained in this map.
|
clear, clone, containsKey, containsValue, equals, hashCode, put, putAll, remove, toStringpublic static final java.lang.String[] WEATHER_STATION_TYPES
public static WeatherDistributor getInstance()
public java.util.Map<java.lang.Enum,java.lang.Object> parseWeatherData(java.lang.String line,
java.util.Map<java.lang.Enum,java.lang.Object> currentWeather)
line - String to parsecurrentWeather - Map for storing the extracted weather datapublic void loadCurrentWeather(java.util.Map<? extends java.lang.Enum,?> extensions)
extensions - Map of WeatherEnums to valuespublic java.lang.Number get(WeatherEnum e)
e - WeatherEnum for the data item wantedpublic java.lang.Object put(WeatherEnum e, java.lang.Object value)
e - WeatherEnum identifying the field to be updatedvalue - Object value to be stored; note that most WeatherEnums require
a Number subclass as their valuejava.lang.ClassCastException - if trying to store a non-numeric value for a WeatherEnum
that expects a Numberpublic void addWeatherListener(WeatherListener l)
l - WeatherListener to registerpublic void removeWeatherListener(WeatherListener l)
l - WeatherListener to deregisterpublic PositionlessWeatherReport makeWeatherMsg()
public static java.lang.String[] getWeatherModelNameStrings()
public java.util.Set<java.util.Map.Entry<java.lang.Enum,java.lang.Object>> entrySet()
Set view of the mappings contained in this map.
The set is backed by the map, so changes to the map are
reflected in the set, and vice-versa. If the map is modified
while an iteration over the set is in progress (except through
the iterator's own remove operation, or through the
setValue operation on a map entry returned by the
iterator) the results of the iteration are undefined. The set
supports element removal, which removes the corresponding
mapping from the map, via the Iterator.remove,
Set.remove, removeAll, retainAll and
clear operations. It does not support the
add or addAll operations.entrySet in interface java.util.Map<java.lang.Enum,java.lang.Object>entrySet in class java.util.AbstractMap<java.lang.Enum,java.lang.Object>public int size()
Integer.MAX_VALUE elements, returns
Integer.MAX_VALUE.size in interface java.util.Map<java.lang.Enum,java.lang.Object>size in class java.util.AbstractMap<java.lang.Enum,java.lang.Object>public boolean isEmpty()
true if this map contains no key-value mappings.isEmpty in interface java.util.Map<java.lang.Enum,java.lang.Object>isEmpty in class java.util.AbstractMap<java.lang.Enum,java.lang.Object>true if this map contains no key-value mappingspublic java.lang.Object get(java.lang.Object key)
null if this map contains no mapping for the key.
More formally, if this map contains a mapping from a key
k to a value v such that (key==null ? k==null :
key.equals(k)), then this method returns v; otherwise
it returns null. (There can be at most one such mapping.)
If this map permits null values, then a return value of
null does not necessarily indicate that the map
contains no mapping for the key; it's also possible that the map
explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.
get in interface java.util.Map<java.lang.Enum,java.lang.Object>get in class java.util.AbstractMap<java.lang.Enum,java.lang.Object>key - the key whose associated value is to be returnednull if this map contains no mapping for the keyjava.lang.ClassCastException - if the key is of an inappropriate type for
this mapjava.lang.NullPointerException - if the specified key is null and this map
does not permit null keyspublic java.util.Set<java.lang.Enum> keySet()
remove operation), the results of
the iteration are undefined. The set supports element removal,
which removes the corresponding mapping from the map, via the
Iterator.remove, Set.remove,
removeAll, retainAll, and clear
operations. It does not support the add or addAll
operations.keySet in interface java.util.Map<java.lang.Enum,java.lang.Object>keySet in class java.util.AbstractMap<java.lang.Enum,java.lang.Object>public java.util.Collection<java.lang.Object> values()
remove operation),
the results of the iteration are undefined. The collection
supports element removal, which removes the corresponding
mapping from the map, via the Iterator.remove,
Collection.remove, removeAll,
retainAll and clear operations. It does not
support the add or addAll operations.values in interface java.util.Map<java.lang.Enum,java.lang.Object>values in class java.util.AbstractMap<java.lang.Enum,java.lang.Object>