saaps.util
Class ObjectTimeSeries

java.lang.Object
  |
  +--saaps.util.ObjectTimeSeries
All Implemented Interfaces:
java.io.Serializable

public class ObjectTimeSeries
extends java.lang.Object
implements java.io.Serializable

See Also:
Serialized Form

Field Summary
private  java.util.Calendar cal
           
private  DatabaseObject[] items
           
private  int numOfData
           
private  int numOfDataFields
           
private  int numOfFields
           
private  java.util.TimeZone tz
           
 
Constructor Summary
ObjectTimeSeries(DatabaseObject[] objArr)
          Create an ObjectTimeSeries from an array of DatabaseObjects.
ObjectTimeSeries(java.util.Vector dbov)
          Create a ObjectTimeSeries object from a Vector of DatabaseObject:s
 
Method Summary
 DatabaseObject average()
          Averages all fields in the data and returns a new DatabaseObject.
 DatabaseObject average(java.util.Date sampleTime, long wa, long wb)
          Averages all fields in the data for the selected time interval and returns a new DatabaseObject.
 boolean checkDbValid(MetaData meta)
          Run this to check if the time series is valid according to the database it's supposed to be in.
static java.util.Vector fillDataGaps(java.util.Vector dbov, MetaData meta)
          Run this to create an ObjectTimeSeries with empty data values for the data gaps.
 ObjectTimeSeries fitToDatabase(MetaData meta, java.util.Date lastInDb)
          Run this to create an ObjectTimeSeries with empty data values for the dates in between lastInDb and first in ObjectTimeSeries.
 DatabaseObject getDataObject(int i)
          Get one data Object
 java.util.Date getDate(int i)
          Get one Date object.
 DatabaseObject getFirst()
          Get first object.
 DatabaseObject getLast()
          Get last object
 int getLength()
          Get the length of the ObjectTimeSeries object.
 int getNumOfDataFields()
          Get the number of data fields.
static void main(java.lang.String[] args)
           
 void print()
          Print info.
 byte resample(long dt0, long dt, long wa, long wb)
          Resamples all fields in the data.
private  java.util.Calendar setCalDay(java.util.Date d)
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

items

private DatabaseObject[] items

numOfData

private int numOfData

numOfFields

private int numOfFields

numOfDataFields

private int numOfDataFields

tz

private java.util.TimeZone tz

cal

private java.util.Calendar cal
Constructor Detail

ObjectTimeSeries

public ObjectTimeSeries(DatabaseObject[] objArr)
Create an ObjectTimeSeries from an array of DatabaseObjects.

ObjectTimeSeries

public ObjectTimeSeries(java.util.Vector dbov)
                 throws IllegalTimeSeriesException
Create a ObjectTimeSeries object from a Vector of DatabaseObject:s
Parameters:
dbov - The DatabaseObject vector
Method Detail

setCalDay

private java.util.Calendar setCalDay(java.util.Date d)

getLength

public int getLength()
Get the length of the ObjectTimeSeries object.

getDate

public java.util.Date getDate(int i)
Get one Date object.

getDataObject

public DatabaseObject getDataObject(int i)
Get one data Object

getFirst

public DatabaseObject getFirst()
Get first object.
Returns:
the first object

getLast

public DatabaseObject getLast()
Get last object
Returns:
the last object

getNumOfDataFields

public int getNumOfDataFields()
Get the number of data fields.

checkDbValid

public boolean checkDbValid(MetaData meta)
                     throws IllegalTimeSeriesException,
                            TimeSeriesSequenceException,
                            TimeSeriesContinuityException
Run this to check if the time series is valid according to the database it's supposed to be in. If it's not we return false ...

print

public void print()
Print info. about data to standard output

average

public DatabaseObject average()
Averages all fields in the data and returns a new DatabaseObject. The time is set to the middle of the data.
Returns:
the averaged object

average

public DatabaseObject average(java.util.Date sampleTime,
                              long wa,
                              long wb)
Averages all fields in the data for the selected time interval and returns a new DatabaseObject. The time is set to the sample time.
Parameters:
sampleTime - time of the resulting object.
wa - time offset 1 (negative value means before sampleTime)
wb - time offset 2 (positive value means after sampleTime)
Returns:
the averaged object

fitToDatabase

public ObjectTimeSeries fitToDatabase(MetaData meta,
                                      java.util.Date lastInDb)
                               throws IllegalTimeSeriesException
Run this to create an ObjectTimeSeries with empty data values for the dates in between lastInDb and first in ObjectTimeSeries.

fillDataGaps

public static java.util.Vector fillDataGaps(java.util.Vector dbov,
                                            MetaData meta)
                                     throws IllegalTimeSeriesException
Run this to create an ObjectTimeSeries with empty data values for the data gaps.

resample

public byte resample(long dt0,
                     long dt,
                     long wa,
                     long wb)
Resamples all fields in the data. XXX The list of objects has to be scanned through for every new sample.
Parameters:
dt0 - offset time from the first time in the series [ms]
dt - new sample interval (timestep [ms])
wa - time offset where resampling begins [ms]
wb - time offset where resampling ends [ms]
Returns:
-1 if failed 0 when normal operation.

main

public static void main(java.lang.String[] args)