org.placelab.core
Class BeaconMeasurement

java.lang.Object
  extended byorg.placelab.core.Measurement
      extended byorg.placelab.core.BeaconMeasurement
All Implemented Interfaces:
Observable
Direct Known Subclasses:
StumblerMeasurement

public class BeaconMeasurement
extends Measurement

BeaconMeasurements contain all the BeaconReadings seen during a single scan of the environment for Beacons.


Field Summary
protected  java.lang.String interfaceName
           
static BeaconReading[] noBtReadings
           
static BeaconReading[] noGSMReadings
           
static BeaconReading[] noWifiReadings
           
protected  int numReadings
           
protected  BeaconReading[] readings
           
 
Constructor Summary
BeaconMeasurement(long timestamp)
           
BeaconMeasurement(long timestamp, BeaconReading[] readings)
           
BeaconMeasurement(long timestamp, boolean mergeDuplicateReadings)
           
BeaconMeasurement(java.lang.String type, long time, java.io.DataInputStream dis)
           
 
Method Summary
 boolean addReading(BeaconReading r)
          Add a BeaconReading to this BeaconMeasurement
 void addReadings(BeaconReading[] readings)
          Batch load the given readings
 BeaconReading getReading(int index)
           
 BeaconReading getReadingById(java.lang.String id)
           
 BeaconReading[] getReadings()
          Gets all the readings for this BeaconReading.
protected  java.lang.String ifStr()
           
 java.util.Enumeration iterator()
           
 int numberOfReadings()
           
 void setInterfaceName(java.lang.String _interfaceName)
           
 byte[] toCompressedBytes()
          For storage on impoverished devices
 java.lang.String toLogString()
          Converts the Measurement to a form which is convenient for writing to a log file.
 java.lang.String toShortString()
          A short string based representation for debugging purposes
 
Methods inherited from class org.placelab.core.Measurement
fromCompressedBytes, getTimestamp, setTimestamp
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

readings

protected BeaconReading[] readings

numReadings

protected int numReadings

interfaceName

protected java.lang.String interfaceName

noWifiReadings

public static final BeaconReading[] noWifiReadings

noGSMReadings

public static final BeaconReading[] noGSMReadings

noBtReadings

public static final BeaconReading[] noBtReadings
Constructor Detail

BeaconMeasurement

public BeaconMeasurement(long timestamp)

BeaconMeasurement

public BeaconMeasurement(long timestamp,
                         boolean mergeDuplicateReadings)
Parameters:
timestamp - the time at which the scan for BeaconReadings began
mergeDuplicateReadings - merge BeaconReadings that have the same unique id

BeaconMeasurement

public BeaconMeasurement(long timestamp,
                         BeaconReading[] readings)
Parameters:
timestamp - the time at which the scan for BeaconReadings began
readings - the set of BeaconReadings to start with

BeaconMeasurement

public BeaconMeasurement(java.lang.String type,
                         long time,
                         java.io.DataInputStream dis)
                  throws java.io.IOException
Method Detail

setInterfaceName

public void setInterfaceName(java.lang.String _interfaceName)

ifStr

protected java.lang.String ifStr()

addReading

public boolean addReading(BeaconReading r)
Add a BeaconReading to this BeaconMeasurement

Parameters:
r - the BeaconReading to add
Returns:
whether or not a BeaconReading with the same unique id as r already existed in this BeaconMeasurement

addReadings

public void addReadings(BeaconReading[] readings)
Batch load the given readings


getReadings

public BeaconReading[] getReadings()
Gets all the readings for this BeaconReading. Returns a copy so that changes to the returned array do not affect the BeaconMeasurement


numberOfReadings

public int numberOfReadings()

getReading

public BeaconReading getReading(int index)

getReadingById

public BeaconReading getReadingById(java.lang.String id)

toLogString

public java.lang.String toLogString()
Description copied from class: Measurement
Converts the Measurement to a form which is convenient for writing to a log file. The convention is to have the following form:
 TYPE=type|TIME=timestamp|OTHERFIELD=value ...
 
All necessary fields should be stored in that pipe separated format, and all values should be percentEscaped with StringUtil.percentEscape(String)

Such a format is easily converted into a HashMap form, and a Measurement should (but is not required to) provide a constructor to build itself from a HashMap created from its log string form.

Overrides:
toLogString in class Measurement

toShortString

public java.lang.String toShortString()
Description copied from class: Measurement
A short string based representation for debugging purposes

Overrides:
toShortString in class Measurement

toCompressedBytes

public byte[] toCompressedBytes()
Description copied from class: Measurement
For storage on impoverished devices

Overrides:
toCompressedBytes in class Measurement
Returns:
a compressed form of the Measurement suitable for storing on small devices such as phones

iterator

public java.util.Enumeration iterator()