org.android.activityminer.model.timeseries
Class SensorObservationCutoutImpl<T extends Enum<T> & Dimensions,U>

Package class diagram package SensorObservationCutoutImpl
java.lang.Object
  extended by org.android.activityminer.model.timeseries.SensorObservationCutoutImpl<T,U>
Type Parameters:
T - the enumeration type for the sensor observation dimensions
U - the data type for the dimension values
All Implemented Interfaces:
SerializableData, ObservableEvent, SensorObservationCutout<T,U>

public final class SensorObservationCutoutImpl<T extends Enum<T> & Dimensions,U>
extends Object
implements SensorObservationCutout<T,U>

A sensor observation cut-out does hold a subsequence of a longer time series of sensor observations.


Field Summary
private  List<SensorObservation<T,U>> sensorObservations
          The list with the sensor observations.
 
Constructor Summary
SensorObservationCutoutImpl()
          Constructor
SensorObservationCutoutImpl(List<SensorObservation<T,U>> sensorObservations)
          Constructor
 
Method Summary
 void addObservation(SensorObservation<T,U> observation)
          Method to add a sensor observation to this type.
 void addObservations(List<? extends SensorObservation<T,U>> observations)
          Method to add a sample collection to this type.
 void clear()
          Method to clear the current content.
 void cutBeforeTime(long startTimeStamp)
          Method to cut the cut-out by removing all observations younger than the given time stamp.
 List<U> getDimensionValues(T dimension)
          Getter for the values of a specific dimension.
 U[] getDimensionValuesAsArray(T dimension)
          Getter for the values of a specific dimension as array.
 long getDuration()
          Getter for the duration of the sensor observation series.
 SensorObservation<T,U> getSensorObservation(int pos)
          Getter for the sensor observations at a given position.
 List<SensorObservation<T,U>> getSensorObservations()
          Getter for the sensor observations.
 List<SensorObservation<T,U>> getSensorObservations(int startPos, int cnt)
          Getter for the given count of sensor observations from a given start position.
 long getStartTime()
          getter for the start time
 Long getTimeStamp(int index)
          Getter for the time stamp at the given index.
 List<Long> getTimeStamps()
          Getter for the time stamps of the sensor observation series.
 Long[] getTimeStampsAsArray()
          Getter for the time stamps the sensor observation series as Array.
 U getValue(T dimension, int index)
          Getter for a single sensor value of a specific dimension at the given index.
 int size()
          Getter for the frame size ( current sample count in this frame ).
 String toXML()
           
 void truncateAfterTime(long maxTimeStamp)
          Method to truncate the cut-out by removing all observations older than the given time stamp.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sensorObservations

private final List<SensorObservation<T extends Enum<T> & Dimensions,U>> sensorObservations
The list with the sensor observations.

Constructor Detail

SensorObservationCutoutImpl

public SensorObservationCutoutImpl(List<SensorObservation<T,U>> sensorObservations)
Constructor

Parameters:
sensorObservations - the sensor observations

SensorObservationCutoutImpl

public SensorObservationCutoutImpl()
Constructor

Method Detail

addObservation

public final void addObservation(SensorObservation<T,U> observation)
Description copied from interface: SensorObservationCutout
Method to add a sensor observation to this type.

Specified by:
addObservation in interface SensorObservationCutout<T extends Enum<T> & Dimensions,U>
Parameters:
observation - the observation to add

addObservations

public final void addObservations(List<? extends SensorObservation<T,U>> observations)
Description copied from interface: SensorObservationCutout
Method to add a sample collection to this type.

Specified by:
addObservations in interface SensorObservationCutout<T extends Enum<T> & Dimensions,U>
Parameters:
observations - the observations to add

getSensorObservations

public List<SensorObservation<T,U>> getSensorObservations()
Description copied from interface: SensorObservationCutout
Getter for the sensor observations.

Specified by:
getSensorObservations in interface SensorObservationCutout<T extends Enum<T> & Dimensions,U>
Returns:
the sensor observations

getSensorObservations

public List<SensorObservation<T,U>> getSensorObservations(int startPos,
                                                          int cnt)
Description copied from interface: SensorObservationCutout
Getter for the given count of sensor observations from a given start position.

Specified by:
getSensorObservations in interface SensorObservationCutout<T extends Enum<T> & Dimensions,U>
Parameters:
startPos - the start position
cnt - the count
Returns:
the sensor observations

getSensorObservation

public SensorObservation<T,U> getSensorObservation(int pos)
Description copied from interface: SensorObservationCutout
Getter for the sensor observations at a given position.

Specified by:
getSensorObservation in interface SensorObservationCutout<T extends Enum<T> & Dimensions,U>
Parameters:
pos - the position
Returns:
the sensor observation

getDimensionValues

public final List<U> getDimensionValues(T dimension)
Description copied from interface: SensorObservationCutout
Getter for the values of a specific dimension.

Specified by:
getDimensionValues in interface SensorObservationCutout<T extends Enum<T> & Dimensions,U>
Parameters:
dimension - the requested dimension
Returns:
the values in a list

getDimensionValuesAsArray

public final U[] getDimensionValuesAsArray(T dimension)
Description copied from interface: SensorObservationCutout
Getter for the values of a specific dimension as array.

Specified by:
getDimensionValuesAsArray in interface SensorObservationCutout<T extends Enum<T> & Dimensions,U>
Parameters:
dimension - the requested dimension
Returns:
the values as array

size

public final int size()
Description copied from interface: SensorObservationCutout
Getter for the frame size ( current sample count in this frame ).

Specified by:
size in interface SensorObservationCutout<T extends Enum<T> & Dimensions,U>
Returns:
the size of this frame

clear

public final void clear()
Description copied from interface: SensorObservationCutout
Method to clear the current content.

Specified by:
clear in interface SensorObservationCutout<T extends Enum<T> & Dimensions,U>

getTimeStamps

public final List<Long> getTimeStamps()
Description copied from interface: SensorObservationCutout
Getter for the time stamps of the sensor observation series.

Specified by:
getTimeStamps in interface SensorObservationCutout<T extends Enum<T> & Dimensions,U>
Returns:
the series time stamps as list

getDuration

public long getDuration()
Description copied from interface: SensorObservationCutout
Getter for the duration of the sensor observation series. The duration is the difference between the time stamps of the last and the first sensor observation.

Specified by:
getDuration in interface SensorObservationCutout<T extends Enum<T> & Dimensions,U>
Returns:
the duration of the series

getTimeStampsAsArray

public final Long[] getTimeStampsAsArray()
Description copied from interface: SensorObservationCutout
Getter for the time stamps the sensor observation series as Array.

Specified by:
getTimeStampsAsArray in interface SensorObservationCutout<T extends Enum<T> & Dimensions,U>
Returns:
the series time stamps as array

toXML

public final String toXML()
                   throws Exception
Specified by:
toXML in interface SerializableData
Throws:
Exception

getValue

public U getValue(T dimension,
                  int index)
Description copied from interface: SensorObservationCutout
Getter for a single sensor value of a specific dimension at the given index.

Specified by:
getValue in interface SensorObservationCutout<T extends Enum<T> & Dimensions,U>
Parameters:
dimension - the requested sensor observation dimension
index - the index position in the time series of sensor observations
Returns:
the value for the given dimension and index if exists, null otherwise

getTimeStamp

public Long getTimeStamp(int index)
Description copied from interface: SensorObservationCutout
Getter for the time stamp at the given index.

Specified by:
getTimeStamp in interface SensorObservationCutout<T extends Enum<T> & Dimensions,U>
Parameters:
index - the index position in the time series of sensor observations
Returns:
the time stamp at the given index if exists, null otherwise

truncateAfterTime

public void truncateAfterTime(long maxTimeStamp)
Description copied from interface: SensorObservationCutout
Method to truncate the cut-out by removing all observations older than the given time stamp.

Specified by:
truncateAfterTime in interface SensorObservationCutout<T extends Enum<T> & Dimensions,U>
Parameters:
maxTimeStamp - the maximum time stamp to truncate for

cutBeforeTime

public void cutBeforeTime(long startTimeStamp)
Description copied from interface: SensorObservationCutout
Method to cut the cut-out by removing all observations younger than the given time stamp.

Specified by:
cutBeforeTime in interface SensorObservationCutout<T extends Enum<T> & Dimensions,U>
Parameters:
startTimeStamp - the new minimum time stamp to set as start time

getStartTime

public long getStartTime()
Description copied from interface: SensorObservationCutout
getter for the start time

Specified by:
getStartTime in interface SensorObservationCutout<T extends Enum<T> & Dimensions,U>
Returns:
the start time stamp