Package org.jfree.data.time
Class TimeSeriesDataItem
- java.lang.Object
-
- org.jfree.data.time.TimeSeriesDataItem
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Comparable
public class TimeSeriesDataItem extends java.lang.Object implements java.lang.Cloneable, java.lang.Comparable, java.io.SerializableRepresents 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
Comparableinterface so that standard Java sorting can be used to keep the data items in order.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private RegularTimePeriodperiodThe time period.private static longserialVersionUIDFor serialization.private java.lang.NumbervalueThe value associated with the time period.
-
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, java.lang.Number value)Constructs a new data item that associates a value with a time period.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectclone()Clones the data item.intcompareTo(java.lang.Object o1)Returns an integer indicating the order of this data pair object relative to another object.booleanequals(java.lang.Object obj)Tests this object for equality with an arbitrary object.RegularTimePeriodgetPeriod()Returns the time period.java.lang.NumbergetValue()Returns the value.inthashCode()Returns a hash code.voidsetValue(java.lang.Number value)Sets the value for this data item.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
For serialization.- See Also:
- Constant Field Values
-
period
private RegularTimePeriod period
The time period.
-
value
private java.lang.Number value
The value associated with the time period.
-
-
Constructor Detail
-
TimeSeriesDataItem
public TimeSeriesDataItem(RegularTimePeriod period, java.lang.Number value)
Constructs a new data item that associates a value with a time period.- Parameters:
period- the time period (nullnot permitted).value- the value (nullpermitted).
-
TimeSeriesDataItem
public TimeSeriesDataItem(RegularTimePeriod period, double value)
Constructs a new data item that associates a value with a time period.- Parameters:
period- the time period (nullnot permitted).value- the value associated with the time period.
-
-
Method Detail
-
getPeriod
public RegularTimePeriod getPeriod()
Returns the time period.- Returns:
- The time period (never
null).
-
getValue
public java.lang.Number getValue()
Returns the value.- Returns:
- The value (
nullpossible). - See Also:
setValue(java.lang.Number)
-
setValue
public void setValue(java.lang.Number value)
Sets the value for this data item.- Parameters:
value- the value (nullpermitted).- See Also:
getValue()
-
equals
public boolean equals(java.lang.Object obj)
Tests this object for equality with an arbitrary object.- Overrides:
equalsin classjava.lang.Object- Parameters:
obj- the other object (nullpermitted).- Returns:
- A boolean.
-
hashCode
public int hashCode()
Returns a hash code.- Overrides:
hashCodein classjava.lang.Object- Returns:
- A hash code.
-
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:
compareToin interfacejava.lang.Comparable- Parameters:
o1- The object being compared to.- Returns:
- An integer indicating the order of the data item object relative to another object.
-
clone
public java.lang.Object clone()
Clones the data item. Note: there is no need to clone the period or value since they are immutable classes.- Overrides:
clonein classjava.lang.Object- Returns:
- A clone of the data item.
-
-