com.jrefinery.data
Class TimeSeriesDataPair

java.lang.Object
  extended by com.jrefinery.data.TimeSeriesDataPair
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable

public class TimeSeriesDataPair
extends java.lang.Object
implements java.lang.Cloneable, java.lang.Comparable

Represents one data item in a time series.

The time period can be any of the following: Year, Quarter, Month, Week, Day, Hour, Minute, Second or Millisecond.

The time period is an immutable property of the data pair. Data pairs will often be sorted within a list, and allowing the time period to be changed could destroy the sort order.

Implements the Comparable interface so that standard Java sorting can be used to keep the data pairs in order.


Field Summary
protected  TimePeriod period
          The time period.
protected  java.lang.Number value
          The value associated with the time period.
 
Constructor Summary
TimeSeriesDataPair(TimePeriod period, double value)
          Constructs a new data pair.
TimeSeriesDataPair(TimePeriod period, java.lang.Number value)
          Constructs a new data pair.
 
Method Summary
 java.lang.Object clone()
          Clones the data pair.
 int compareTo(java.lang.Object o1)
          Returns an integer indicating the order of this data pair object relative to another object.
 TimePeriod getPeriod()
          Returns the time period.
 java.lang.Number getValue()
          Returns the value.
 void setValue(java.lang.Number value)
          Sets the value for this data pair.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

period

protected TimePeriod period
The time period.


value

protected java.lang.Number value
The value associated with the time period.

Constructor Detail

TimeSeriesDataPair

public TimeSeriesDataPair(TimePeriod period,
                          java.lang.Number value)
Constructs a new data pair.

Parameters:
period - The time period.
value - The value associated with the time period.

TimeSeriesDataPair

public TimeSeriesDataPair(TimePeriod period,
                          double value)
Constructs a new data pair.

Parameters:
period - The time period.
value - The value associated with the time period.
Method Detail

clone

public java.lang.Object clone()
Clones the data pair.

Notes: --> no need to clone the period or value since they are immutable classes;

Overrides:
clone in class java.lang.Object

getPeriod

public TimePeriod getPeriod()
Returns the time period.

Returns:
The time period.

getValue

public java.lang.Number getValue()
Returns the value.

Returns:
The value.

setValue

public void setValue(java.lang.Number value)
Sets the value for this data pair.

Parameters:
value - The new value.

compareTo

public int compareTo(java.lang.Object o1)
Returns an integer indicating the order of this data pair object relative to another object.

For the order we consider only the timing: negative == before, zero == same, positive == after.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o1 - The object being compared to.
Returns:
An integer indicating the order of this data pair object relative to another object.


Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.