org.placelab.core
Class Measurement

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

public class Measurement
extends java.lang.Object
implements Observable

Measurements are produced by Spotters and represent the result of a single scan of the environment.


Constructor Summary
Measurement(long timestampInMillis)
          Creates a Measurement with the given timestamp
 
Method Summary
static Measurement fromCompressedBytes(byte[] array)
          Reconstruct the Measurement from its compressed form
 long getTimestamp()
          Gets the time at which the Measurement was taken.
 void setTimestamp(long timestamp)
           
 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Measurement

public Measurement(long timestampInMillis)
Creates a Measurement with the given timestamp

Parameters:
timestampInMillis - the time at which the Measurement was taken
Method Detail

setTimestamp

public void setTimestamp(long timestamp)

getTimestamp

public long getTimestamp()
Gets the time at which the Measurement was taken.

Specified by:
getTimestamp in interface Observable

toLogString

public java.lang.String toLogString()
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.


toShortString

public java.lang.String toShortString()
A short string based representation for debugging purposes


toCompressedBytes

public byte[] toCompressedBytes()
For storage on impoverished devices

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

fromCompressedBytes

public static Measurement fromCompressedBytes(byte[] array)
Reconstruct the Measurement from its compressed form

See Also:
toCompressedBytes()