org.android.activityminer.logic.devices
Class LocationDataCache

Package class diagram package LocationDataCache
java.lang.Object
  extended by org.android.activityminer.logic.util.AbstractActivatableComponentImpl
      extended by org.android.activityminer.logic.devices.LocationDataCache
All Implemented Interfaces:
SensorDataSource<NetworkLocationData>, ActivatableComponent

public class LocationDataCache
extends AbstractActivatableComponentImpl
implements SensorDataSource<NetworkLocationData>

The data cache to hold location samples for scanner polls.


Field Summary
protected  ConcurrentLinkedQueue<NetworkLocationData> cache
          The sample cache.
private  NetworkLocationData lastSample
          Last sample.
 
Constructor Summary
LocationDataCache()
          Constructor
 
Method Summary
 void add(double lon, double lat, double speed, long ts)
          Does add a new sample to the cache.
 void add(Location currentData, long ts)
          Does add a new sample to the cache.
protected  boolean hasSample()
          Test method for valid samples
protected  void onActivationStateChange(boolean active)
          Handler for activation state changes
 void onDestroy()
          This method is for cleanup in case of termination.
 NetworkLocationData takeSample(Long ts)
          Getter for the current sample
 
Methods inherited from class org.android.activityminer.logic.util.AbstractActivatableComponentImpl
isActive, setActivationState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lastSample

private NetworkLocationData lastSample
Last sample.


cache

protected final ConcurrentLinkedQueue<NetworkLocationData> cache
The sample cache.

Constructor Detail

LocationDataCache

public LocationDataCache()
Constructor

Method Detail

takeSample

public final NetworkLocationData takeSample(Long ts)
Description copied from interface: SensorDataSource
Getter for the current sample

Specified by:
takeSample in interface SensorDataSource<NetworkLocationData>
Parameters:
ts - the requested time stamp
Returns:
the current sample

onDestroy

public final void onDestroy()
Description copied from interface: SensorDataSource
This method is for cleanup in case of termination.

Specified by:
onDestroy in interface SensorDataSource<NetworkLocationData>

hasSample

protected final boolean hasSample()
Test method for valid samples

Returns:
true if a sample is available

onActivationStateChange

protected final void onActivationStateChange(boolean active)
Description copied from class: AbstractActivatableComponentImpl
Handler for activation state changes

Specified by:
onActivationStateChange in class AbstractActivatableComponentImpl
Parameters:
active - the new activation state

add

public final void add(Location currentData,
                      long ts)
Does add a new sample to the cache.

Parameters:
currentData - the location data to add
ts - the original sample time stamp

add

public final void add(double lon,
                      double lat,
                      double speed,
                      long ts)
Does add a new sample to the cache.

Parameters:
lon - the longitude
lat - the latitude
speed - the speed
ts - the original time stamp