edu.berkeley.guir.ptk.input
Class WeatherInput

java.lang.Object
  extended byedu.berkeley.guir.ptk.PTK
      extended byedu.berkeley.guir.ptk.input.InputSource
          extended byedu.berkeley.guir.ptk.input.WeatherInput
All Implemented Interfaces:
java.lang.Runnable

public class WeatherInput
extends InputSource

Gets weather information for a given location: high temperature, low temperature, forecast (e.g., "sunny," "partly cloudy"), wind speeds and direction, and the chance of rain (in percent). The metadata of the events this class creates is WeatherConstants.WEATHER.


Field Summary
static java.lang.String MY_ID
          The unique ID String for this input, found in WeatherConstants, which is an application specific class.
static java.lang.String URL
          The location string at the end of the Yahoo Weather URL.
 java.lang.String url_location
           
 
Fields inherited from class edu.berkeley.guir.ptk.input.InputSource
history, mds, my_id, my_ip, time_between_events
 
Fields inherited from class edu.berkeley.guir.ptk.PTK
debug, MAX_DEBUG, MED_DEBUG, MIN_DEBUG, NO_DEBUG
 
Constructor Summary
WeatherInput()
          Constructor for non-distributed applications.
WeatherInput(java.lang.String my_ip)
          Constructor for distributed applications.
 
Method Summary
static void main(java.lang.String[] argsv)
          This main method allows the input to run, continually getting new input and dispatching the data in events to the PTK server.
 Events newInput()
          Gets the high temperature, low temperature, forecast, wind, barometric pressure, humidity, sunrise, and sunset from the Yahoo weather webpage for today in a user-specified location.
 
Methods inherited from class edu.berkeley.guir.ptk.input.InputSource
addMetadata, addMetadataItem, addMyMetadataToEvent, dispatchEvent, finalize, getAbstractThenSendInputEvent, getMetadata, getMetadataItemsAsArray, getThenSendInputEvent, register, run, setMetadata, setTimeBetweenEvents, startInput
 
Methods inherited from class edu.berkeley.guir.ptk.PTK
getMAX, getMED, getMIN, getNO, printDebug, printDebug, printError
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MY_ID

public static final java.lang.String MY_ID
The unique ID String for this input, found in WeatherConstants, which is an application specific class. The ID must be unique per PTK server instance.

See Also:
Constant Field Values

URL

public static final java.lang.String URL
The location string at the end of the Yahoo Weather URL.

See Also:
Constant Field Values

url_location

public java.lang.String url_location
Constructor Detail

WeatherInput

public WeatherInput()
Constructor for non-distributed applications. An input that uses this constructor cannot be part of an application on another machine.


WeatherInput

public WeatherInput(java.lang.String my_ip)
Constructor for distributed applications. An input that uses this constructor can send evets to remote applications.

Method Detail

newInput

public Events newInput()
Gets the high temperature, low temperature, forecast, wind, barometric pressure, humidity, sunrise, and sunset from the Yahoo weather webpage for today in a user-specified location. Set the location when this parser is initialized. The Event with these pieces of data is returned to be dispatched to the PTK server and eventually sent to outputs that subscribe to its metadata. Uses the PTKWebPageParser class to parse the Yahoo Web page.

Specified by:
newInput in class InputSource
Returns:
Event a Event object that contains the weather information.

main

public static void main(java.lang.String[] argsv)
This main method allows the input to run, continually getting new input and dispatching the data in events to the PTK server.