org.placelab.stumbler
Class SpotterExtension

java.lang.Object
  extended byorg.placelab.stumbler.SpotterExtension
All Implemented Interfaces:
Spotter, SpotterListener

public class SpotterExtension
extends java.lang.Object
implements Spotter, SpotterListener


Field Summary
static long GPS_STALE_TIME
           
 
Constructor Summary
SpotterExtension(Spotter spotter, boolean isQuick, long staleTimeMillis)
           
 
Method Summary
 void addListener(SpotterListener listener)
          Adds a SpotterListener to be called back whenever new Measurements are generated by the Spotter.
 void close()
          Unloads resources used by the spotter.
 Measurement getLatestMeasurement()
           
 Measurement getMeasurement()
          A blocking call to get a new Measurement.
 Spotter getSpotter()
           
 void gotMeasurement(Spotter sender, Measurement m)
           
 boolean isScanning()
           
 void open()
          Load resources used by the spotter.
 void removeListener(SpotterListener listener)
           
 void scanOnce()
          Performs a single background scan for Measurements and returns the result to registered SpotterListeners' SpotterListener.gotMeasurement(Spotter, Measurement) method.
 void scanOnce(EventSystem evs)
          Like scanOnce() but instead uses the given EventSystem to deliver the callback to hide the background thread from the application.
 void spotterExceptionThrown(Spotter s, SpotterException ex)
           
 void startScanning()
          Start scanning for Measurements in the background and return the Measurements by notifying SpotterListeners with the SpotterListener.gotMeasurement(Spotter, Measurement) method.
 void startScanning(EventSystem evs)
          Start scanning for Measurements.
 void stopScanning()
          Stops a currently running background scan started from either scanOnce or startScanning.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GPS_STALE_TIME

public static long GPS_STALE_TIME
Constructor Detail

SpotterExtension

public SpotterExtension(Spotter spotter,
                        boolean isQuick,
                        long staleTimeMillis)
Method Detail

getSpotter

public Spotter getSpotter()

open

public void open()
          throws SpotterException
Description copied from interface: Spotter
Load resources used by the spotter. Applications should be able to invoke this methods multiple times in sequence and have the "right" things happen. All Spotters should be opened before being used.

Specified by:
open in interface Spotter
Throws:
SpotterException - if the necessary hardware or software for this spotter is not present

close

public void close()
           throws SpotterException
Description copied from interface: Spotter
Unloads resources used by the spotter. Multiple calls to close are ok.

Specified by:
close in interface Spotter
Throws:
SpotterException

getLatestMeasurement

public Measurement getLatestMeasurement()
                                 throws SpotterException
Throws:
SpotterException

getMeasurement

public Measurement getMeasurement()
                           throws SpotterException
Description copied from interface: Spotter
A blocking call to get a new Measurement. A spotter implementation may choose to just return the last cached Measurement, or go ahead and do a new scan and return the results of that scan. Note that the accuracy of timestamps returned by this usage model depends on the spotter implementation. You should not call this method while this Spotter is performing a continous scan. Doing so will result in a SpotterException being thrown.

Specified by:
getMeasurement in interface Spotter
Throws:
SpotterException

startScanning

public void startScanning()
Description copied from interface: Spotter
Start scanning for Measurements in the background and return the Measurements by notifying SpotterListeners with the SpotterListener.gotMeasurement(Spotter, Measurement) method. Depending on the Spotter implementation this may start up a new background thread. Callbacks to the SpotterListener are not guaranteed to (and probably won't) be in the the same thread as startScanning was called in.

Specified by:
startScanning in interface Spotter
See Also:
Spotter.startScanning(EventSystem)

startScanning

public void startScanning(EventSystem evs)
Description copied from interface: Spotter
Start scanning for Measurements. This method may or may not create a new thread internally, but should never expose that thread to the application. Instead callbacks to SpotterListeners should be invoked via the Eventsystem.notifyTransientEvent() method, so that the callbacks get run through the EventSystem thread.

Specified by:
startScanning in interface Spotter
See Also:
Spotter.startScanning()

isScanning

public boolean isScanning()

stopScanning

public void stopScanning()
Description copied from interface: Spotter
Stops a currently running background scan started from either scanOnce or startScanning.

Specified by:
stopScanning in interface Spotter

scanOnce

public void scanOnce()
Description copied from interface: Spotter
Performs a single background scan for Measurements and returns the result to registered SpotterListeners' SpotterListener.gotMeasurement(Spotter, Measurement) method. This may start a new thread and deliver the callback in that new thread.

Registered SpotterListeners that also implement the ScanOnceListener interface will also receive ScanOnceListener.endOfScan(Spotter) notifications.

Specified by:
scanOnce in interface Spotter
See Also:
Spotter.scanOnce(EventSystem)

scanOnce

public void scanOnce(EventSystem evs)
Description copied from interface: Spotter
Like Spotter.scanOnce() but instead uses the given EventSystem to deliver the callback to hide the background thread from the application.

Specified by:
scanOnce in interface Spotter

addListener

public void addListener(SpotterListener listener)
Description copied from interface: Spotter
Adds a SpotterListener to be called back whenever new Measurements are generated by the Spotter.

Specified by:
addListener in interface Spotter

removeListener

public void removeListener(SpotterListener listener)
Specified by:
removeListener in interface Spotter

gotMeasurement

public void gotMeasurement(Spotter sender,
                           Measurement m)
Specified by:
gotMeasurement in interface SpotterListener

spotterExceptionThrown

public void spotterExceptionThrown(Spotter s,
                                   SpotterException ex)
Specified by:
spotterExceptionThrown in interface SpotterListener