|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jstatcom.ts.TS
public final class TS
This class pools information about a particular time series:
TS
object must have at least one
observation, the data is therefore initialized with
new double[1]
. Any attempt to set the data to a zero length
array or to null
is ignored.
Once a time series is created, it is not possible anymore to change the
underlying data, instead, a new TS
must be instantiated. The
type may be changed. Type changes throw a TS_TYPE_CHANGED
PropertyChangeEvent
.
This class is thread-safe. All access to mutable data is synchronized.
Field Summary | |
---|---|
static java.lang.String |
TS_TYPE_CHANGED
Type changed property event name. |
Constructor Summary | |
---|---|
TS(double[] newObservations,
java.lang.String newName)
Creates a TS object with the type being guessed and the
project is the default. |
|
TS(double[] newObservations,
java.lang.String newName,
TSDate newDate)
Creates a TS object, with the type being guessed and the
project is the default. |
|
TS(double[] newObservations,
java.lang.String newName,
TSDate newDate,
TSTypes tsType)
Creates a TS object with the default project. |
|
TS(double[] newObservations,
java.lang.String newName,
TSDate newDate,
TSTypes tsType,
TSProject newProject)
Preferred constructor for a TS object with everything
explicitely specified. |
|
TS(TS ts)
TS copy-constructor. |
Method Summary | |
---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
|
TS |
createDiff(int periods)
Applies the difference operator to a copy of the series and returns the new series with the name oldName + "_d" + Math.abs(periods) . |
TS |
createLog()
Applies the log operator to a copy of the series and returns the new series with the name oldName + "_log" . |
boolean |
equals(java.lang.Object o)
Overrides equals() to provide logical comparison of two
different TS. |
static double[][] |
getMergedData(TS[] tsArray)
Gets the merged data of all time series in the given array. |
int |
hashCode()
Overrides hashCode , because equals was overwritten. |
java.lang.String |
name()
Returns the identifying name of this time series object. |
int |
numOfObs()
Returns the number of observations. |
void |
print(java.io.PrintStream p)
Prints this object to the argument print stream with the time index and the respective observation next to it. |
TSProject |
project()
Gets project that this TS belongs to. |
TSDateRange |
range()
Returns the TSDateRange defining the beginning and the end
of this time series. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
|
void |
setName(java.lang.String newValue)
Sets the name of this time series to a new name. |
void |
setTSProject(TSProject newTSProject)
Sets project that this TS belongs to. |
void |
setTSType(TSTypes newTSType)
Sets the type of this time series. |
TSDate |
start()
Returns the date when the first observation in this TS
occurs. |
java.lang.String |
toString()
String representation of a timeseries. |
TSTypes |
type()
Gets the type of this time series. |
double |
valueAt(int i)
Returns the observation at index i . |
double |
valueAt(TSDate date)
Returns the observation at a given date. |
double[] |
values()
Returns a copy of the array of observations. |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String TS_TYPE_CHANGED
Constructor Detail |
---|
public TS(double[] newObservations, java.lang.String newName)
TS
object with the type being guessed and the
project is the default. For the start date the TSDate
default constructor is used.
newObservations
- the array of observationsnewName
- the identifying name
java.lang.IllegalArgumentException
- if newName
is null
public TS(double[] newObservations, java.lang.String newName, TSDate newDate)
TS
object, with the type being guessed and the
project is the default.
newObservations
- the array of observationsnewName
- the identifying namenewDate
- the date of the first observation.
java.lang.IllegalArgumentException
- if newName
or newDate
is
null
public TS(double[] newObservations, java.lang.String newName, TSDate newDate, TSTypes tsType)
TS
object with the default project.
newObservations
- the array of observationsnewName
- the identifying namenewDate
- the date of the first observation.tsType
- the type or null
if it should be automatically
defined
java.lang.IllegalArgumentException
- if newName
or newDate
is
null
public TS(double[] newObservations, java.lang.String newName, TSDate newDate, TSTypes tsType, TSProject newProject)
TS
object with everything
explicitely specified.
newObservations
- the array of observationsnewName
- the identifying namenewDate
- the date of the first observation.tsType
- the type or null
if it should be automatically
definednewProject
- the time series project
java.lang.IllegalArgumentException
- if newName
or newDate
is
null
public TS(TS ts)
TS
copy-constructor.
ts
- the TS
to copyMethod Detail |
---|
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
public TS createDiff(int periods)
oldName + "_d" + Math.abs(periods)
.
If periods is the same as the sub periodicity and the sub periodicity
> 1, the new name is oldName + "_dseas"
.
periods
- the number of lags of the part being subtracted from the
original series, it may also be < 0
null
if the
operation failed.public TS createLog()
oldName + "_log"
.
null
, if the
operation failed.public boolean equals(java.lang.Object o)
equals()
to provide logical comparison of two
different TS.
equals
in class java.lang.Object
o
- the object to compare
true
if name, start, all observations and type are
the same, false
otherwisepublic double[] values()
public double valueAt(int i)
i
.
i
- the index to retrieve the data from
i
is within the
range of this time series, otherwise Double.NaN
public double valueAt(TSDate date)
date
- the TSDate
for the observation, if it is
invalid, then Double.NaN
is returned
Double.NaN
public static double[][] getMergedData(TS[] tsArray)
tsArray
- an array of TS
objects
Double.NaN
if no observation is available for a
series in the array at a certain date
java.lang.IllegalArgumentException
- if one TS
is null
or if sub
periodicities are differentpublic java.lang.String name()
public int numOfObs()
public TSDate start()
TS
occurs.
public TSDateRange range()
TSDateRange
defining the beginning and the end
of this time series.
public TSProject project()
TS
belongs to.
public TSTypes type()
setTSType(com.jstatcom.ts.TSTypes)
public int hashCode()
hashCode
, because equals was overwritten. The
algorithm was taken from (Joshua Bloch, "Effective Java", Item 8)
.
hashCode
in class java.lang.Object
public void print(java.io.PrintStream p)
p
- the stream to print topublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
public void setName(java.lang.String newValue)
null
or empty. The name must begin either with '_' .
newValue
- the new name.
java.lang.IllegalArgumentException
- if newValue is null
, empty or if it does not
start with a letter or '_'public void setTSProject(TSProject newTSProject)
newTSProject
- the new projectpublic void setTSType(TSTypes newTSType)
null
,
the type is determined internally to be either deterministic or
endogenous.
newTSType
- the new type of the TS
type()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |