org.jfree.data.time
Class TimeSeriesDataItem

java.lang.Object
  |
  +--org.jfree.data.time.TimeSeriesDataItem
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable, java.io.Serializable

public class TimeSeriesDataItem
extends java.lang.Object
implements java.lang.Cloneable, java.lang.Comparable, java.io.Serializable

Represents one data item in a time series.

The time period can be any of the following:

The time period is an immutable property of the data item. Data items 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 items in order.

Author:
David Gilbert
See Also:
Serialized Form

Constructor Summary
TimeSeriesDataItem(RegularTimePeriod period, double value)
          Constructs a new data pair.
TimeSeriesDataItem(RegularTimePeriod 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.
 boolean equals(java.lang.Object target)
          Tests this object for equality with the target object.
 RegularTimePeriod 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
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeSeriesDataItem

public TimeSeriesDataItem(RegularTimePeriod period,
                          java.lang.Number value)
Constructs a new data pair.

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

TimeSeriesDataItem

public TimeSeriesDataItem(RegularTimePeriod 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
Returns:
a clone of this data pair.

getPeriod

public RegularTimePeriod 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.

equals

public boolean equals(java.lang.Object target)
Tests this object for equality with the target object.

Overrides:
equals in class java.lang.Object
Parameters:
target - the other object.
Returns:
A boolean.

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 the data pair object relative to another object.