Package adams.data.timeseries
Class Timeseries<P extends TimeseriesPoint,R extends Report,S extends TimeseriesStatistic>
- java.lang.Object
-
- adams.data.container.AbstractDataContainer<P>
-
- adams.data.timeseries.Timeseries<P,R,S>
-
- All Implemented Interfaces:
CloneHandler
,Mergeable<DataContainer>
,UniqueIDHandler
,DataContainer<P>
,DatabaseIDHandler
,IDHandler
,MutableDatabaseIDHandler
,MutableIDHandler
,NotesHandler
,MutableReportHandler<R>
,ReportHandler<R>
,SpreadSheetSupporter
,InformativeStatisticSupporter<TimeseriesStatistic>
,Serializable
,Comparable
,Iterable<P>
,Collection<P>
public class Timeseries<P extends TimeseriesPoint,R extends Report,S extends TimeseriesStatistic> extends AbstractDataContainer<P> implements MutableReportHandler<R>, MutableDatabaseIDHandler, NotesHandler, SpreadSheetSupporter, InformativeStatisticSupporter<TimeseriesStatistic>
Container for a full timeseries.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static TimeseriesPointComparator
m_Comparator
the default comparator.protected int
m_DatabaseID
the database ID.protected TimeseriesPoint
m_MaxValue
point of greatest value.protected TimeseriesPoint
m_MinValue
point of smallest value.protected Notes
m_Notes
the notes.protected R
m_Report
the report.-
Fields inherited from class adams.data.container.AbstractDataContainer
m_ID, m_Points, m_UUID
-
-
Constructor Summary
Constructors Constructor Description Timeseries()
Initializes the profile with no RFID tag ID.Timeseries(String id)
Initializes the profile with the specified RFID tag ID.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
assign(DataContainer<P> other)
Obtains the stored variables from the other data point, but not the actual data points.int
compareToHeader(Object o)
Compares this object with the specified object for order.TimeseriesPoint
find(Date timestamp)
Returns the TimeseriesPoint with the exact timestamp, null if not found.TimeseriesPoint
findClosest(Date timestamp)
Returns the TimeseriesPoint with a timestamp closest to the one provided.TimeseriesPointComparator
getComparator()
Returns the comparator in use.int
getDatabaseID()
Returns the database ID.Timeseries
getHeader()
Returns a timeseries with just the header information, but no data points.TimeseriesPoint
getMaxValue()
Get point with greatest timeseries value.TimeseriesPoint
getMinValue()
Get point with smallest timeseries value.Notes
getNotes()
Returns the currently stored notes.R
getReport()
Returns the report.boolean
hasReport()
Checks whether a report is present.protected void
invalidateMinMax()
Invalidates the min/max timeseries points.protected boolean
modifiedListener(boolean modified)
Method that gets notified about changes in the collection of data points.TimeseriesPointComparator
newComparator()
Returns a new instance of the default comparator.P
newPoint()
Returns a new instance of a DataContainer point.protected R
newReport()
Creates a new, empty report.void
setDatabaseID(int value)
Sets the database ID.void
setID(String value)
Sets the ID of the profile.void
setReport(R value)
Sets a new report.SpreadSheet
toSpreadSheet()
Returns the content as spreadsheet.S
toStatistic()
Returns a statistic object of this profile.protected void
validateMinMax()
Initializes the min/max timeseries points.-
Methods inherited from class adams.data.container.AbstractDataContainer
add, addAll, clear, compareTo, compareToData, contains, containsAll, ensureCapacity, equals, equalsData, equalsHeader, getClone, getID, getUniqueID, hashCode, isEmpty, iterator, mergeWith, newInstance, remove, removeAll, retainAll, size, toArray, toArray, toList, toList, toString, toTreeSet, toTreeSet, trimToSize
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, spliterator, stream, toArray
-
-
-
-
Field Detail
-
m_Comparator
protected static TimeseriesPointComparator m_Comparator
the default comparator.
-
m_DatabaseID
protected int m_DatabaseID
the database ID.
-
m_Notes
protected Notes m_Notes
the notes.
-
m_MaxValue
protected TimeseriesPoint m_MaxValue
point of greatest value.
-
m_MinValue
protected TimeseriesPoint m_MinValue
point of smallest value.
-
-
Constructor Detail
-
Timeseries
public Timeseries()
Initializes the profile with no RFID tag ID.
-
Timeseries
public Timeseries(String id)
Initializes the profile with the specified RFID tag ID.- Parameters:
id
- the RFID tag ID
-
-
Method Detail
-
newReport
protected R newReport()
Creates a new, empty report.- Returns:
- the report
-
modifiedListener
protected boolean modifiedListener(boolean modified)
Method that gets notified about changes in the collection of data points. Just passes the modified state through.- Overrides:
modifiedListener
in classAbstractDataContainer<P extends TimeseriesPoint>
- Parameters:
modified
- whether the action modified the collection- Returns:
- the same as the input
-
newComparator
public TimeseriesPointComparator newComparator()
Returns a new instance of the default comparator.- Specified by:
newComparator
in interfaceDataContainer<P extends TimeseriesPoint>
- Returns:
- the comparator instance
-
getComparator
public TimeseriesPointComparator getComparator()
Returns the comparator in use.- Specified by:
getComparator
in interfaceDataContainer<P extends TimeseriesPoint>
- Returns:
- the comparator in use
-
newPoint
public P newPoint()
Returns a new instance of a DataContainer point.- Specified by:
newPoint
in interfaceDataContainer<P extends TimeseriesPoint>
- Returns:
- the new DataContainer point
-
invalidateMinMax
protected void invalidateMinMax()
Invalidates the min/max timeseries points.
-
validateMinMax
protected void validateMinMax()
Initializes the min/max timeseries points.
-
getMaxValue
public TimeseriesPoint getMaxValue()
Get point with greatest timeseries value.- Returns:
- the data point
-
getMinValue
public TimeseriesPoint getMinValue()
Get point with smallest timeseries value.- Returns:
- the data point
-
assign
public void assign(DataContainer<P> other)
Obtains the stored variables from the other data point, but not the actual data points.- Specified by:
assign
in interfaceDataContainer<P extends TimeseriesPoint>
- Overrides:
assign
in classAbstractDataContainer<P extends TimeseriesPoint>
- Parameters:
other
- the data point to get the values from
-
getHeader
public Timeseries getHeader()
Returns a timeseries with just the header information, but no data points.- Specified by:
getHeader
in interfaceDataContainer<P extends TimeseriesPoint>
- Overrides:
getHeader
in classAbstractDataContainer<P extends TimeseriesPoint>
- Returns:
- the new header
-
hasReport
public boolean hasReport()
Checks whether a report is present.- Specified by:
hasReport
in interfaceReportHandler<P extends TimeseriesPoint>
- Returns:
- true if a report is present
-
setReport
public void setReport(R value)
Sets a new report.- Specified by:
setReport
in interfaceMutableReportHandler<P extends TimeseriesPoint>
- Parameters:
value
- the new report
-
getReport
public R getReport()
Returns the report.- Specified by:
getReport
in interfaceReportHandler<P extends TimeseriesPoint>
- Returns:
- the report, can be null if none available
-
getDatabaseID
public int getDatabaseID()
Returns the database ID.- Specified by:
getDatabaseID
in interfaceDatabaseIDHandler
- Returns:
- the database ID
-
setDatabaseID
public void setDatabaseID(int value)
Sets the database ID.- Specified by:
setDatabaseID
in interfaceMutableDatabaseIDHandler
- Parameters:
value
- the database ID
-
setID
public void setID(String value)
Sets the ID of the profile.- Specified by:
setID
in interfaceMutableIDHandler
- Overrides:
setID
in classAbstractDataContainer<P extends TimeseriesPoint>
- Parameters:
value
- the new ID
-
compareToHeader
public int compareToHeader(Object o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.- Specified by:
compareToHeader
in interfaceDataContainer<P extends TimeseriesPoint>
- Overrides:
compareToHeader
in classAbstractDataContainer<P extends TimeseriesPoint>
- Parameters:
o
- the object to be compared.- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
- Throws:
ClassCastException
- if the specified object's type prevents it from being compared to this object.
-
toStatistic
public S toStatistic()
Returns a statistic object of this profile.- Specified by:
toStatistic
in interfaceInformativeStatisticSupporter<P extends TimeseriesPoint>
- Returns:
- statistics about this profile
-
find
public TimeseriesPoint find(Date timestamp)
Returns the TimeseriesPoint with the exact timestamp, null if not found.- Parameters:
timestamp
- the timestamp to look for- Returns:
- the TimeseriesPoint or null if not found
-
findClosest
public TimeseriesPoint findClosest(Date timestamp)
Returns the TimeseriesPoint with a timestamp closest to the one provided.- Parameters:
timestamp
- the timestamp to look for- Returns:
- the TimeseriesPoint
-
getNotes
public Notes getNotes()
Returns the currently stored notes.- Specified by:
getNotes
in interfaceNotesHandler
- Returns:
- the current notes
-
toSpreadSheet
public SpreadSheet toSpreadSheet()
Returns the content as spreadsheet.- Specified by:
toSpreadSheet
in interfaceSpreadSheetSupporter
- Returns:
- the content
-
-