Package org.jfree.data.time
Class TimeSeriesDataItem
java.lang.Object
org.jfree.data.time.TimeSeriesDataItem
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable
public class TimeSeriesDataItem extends Object implements Cloneable, Comparable, 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.
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description TimeSeriesDataItem(RegularTimePeriod period, double value)
Constructs a new data item that associates a value with a time period.TimeSeriesDataItem(RegularTimePeriod period, Number value)
Constructs a new data item that associates a value with a time period. -
Method Summary
Modifier and Type Method Description Object
clone()
Clones the data item.int
compareTo(Object o1)
Returns an integer indicating the order of this data pair object relative to another object.boolean
equals(Object o)
Tests this object for equality with an arbitrary object.RegularTimePeriod
getPeriod()
Returns the time period.Number
getValue()
Returns the value.int
hashCode()
Returns a hash code.void
setValue(Number value)
Sets the value for this data item.
-
Constructor Details
-
TimeSeriesDataItem
Constructs a new data item that associates a value with a time period.- Parameters:
period
- the time period (null
not permitted).value
- the value (null
permitted).
-
TimeSeriesDataItem
Constructs a new data item that associates a value with a time period.- Parameters:
period
- the time period (null
not permitted).value
- the value associated with the time period.
-
-
Method Details
-
getPeriod
Returns the time period.- Returns:
- The time period (never
null
).
-
getValue
Returns the value.- Returns:
- The value (
null
possible).
-
setValue
Sets the value for this data item.- Parameters:
value
- the value (null
permitted).
-
equals
Tests this object for equality with an arbitrary object. -
hashCode
public int hashCode()Returns a hash code. -
compareTo
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 interfaceComparable
- Parameters:
o1
- The object being compared to.- Returns:
- An integer indicating the order of the data pair object relative to another object.
-
clone
Clones the data item.Notes: --> no need to clone the period or value since they are immutable classes.
- Returns:
- A clone of the data item.
-