|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.jstatcom.ts.TSDateRange
public final class TSDateRange
Holds a range for possible TSDate objects defined as
[lowerBound, upperBound] and provides checks against it. The
class can be used by classes that allow to specify a date that needs to be
validated.
This class is immutable by design, see (Joshua Bloch, "Effective Java", Item 13) .
TSDate| Constructor Summary | |
|---|---|
TSDateRange()
Creates a default range starting from the default TSDate
with 100 observations. |
|
TSDateRange(TSDate t1,
int numberOfObs)
Creates TSDateRange from specified start date and number
of observations. |
|
TSDateRange(TSDate t1,
TSDate t2)
Creates TSDateRange from specified start date and end
date. |
|
| Method Summary | |
|---|---|
TSDateRange |
addPeriodsToStart(int periods)
Gets a new TSDateRange range object with the start date
shifted by periods. |
TSDateRange |
commonRange(TSDateRange otherRange)
Returns the biggest date range that is common to this range and another range. |
double[][] |
createSeasDum(boolean centered,
boolean all)
Creates seasonal dummy series as double[][], see
createSeasDumTS(boolean, boolean). |
TS[] |
createSeasDumTS(boolean centered,
boolean all)
Creates seasonal dummy series according to the periodicity of this time series. |
double[] |
createShiftDum(TSDateRange shiftRange)
Creates a double[] that is a shift dummy for this range,
see createShiftDumTS(java.lang.String, com.jstatcom.ts.TSDateRange). |
TS |
createShiftDumTS(java.lang.String name,
TSDateRange shiftRange)
Creates a time series that is a shift dummy for this range. |
double[] |
createTrendShiftDum(TSDateRange shiftRange)
Creates a double[] that is a trend shift dummy for this
range, see createTrendShiftDumTS(java.lang.String, com.jstatcom.ts.TSDateRange). |
TS |
createTrendShiftDumTS(java.lang.String name,
TSDateRange shiftRange)
Creates a time series that is a trend shift dummy for this range. |
TSDate |
dateForIndex(int index)
Returns the date corresponding to an index respective to the range. |
java.lang.String |
encloses(TSDate date)
Checks whether a given date is within the range defined by this object. |
java.lang.String |
encloses(TSDateRange otherRange)
Checks whether a given date range is included within the range defined by this object. |
boolean |
equals(java.lang.Object o)
Overrides equals to provide logical comparison of two
different TSDateRange objects. |
java.lang.String |
format(java.lang.String description,
int space)
Gets a nicely formatted version of this date range with a description and the number of observations, for example sample range: [1960 Q3, 1982 Q4], T = 90with "sample range:" as description. |
static TSDateRange |
getMergedRange(TS[] tsArray)
Gets the merged range of all time series in the given array. |
int |
hashCode()
Overrides hashCode(), because equals was overwritten. |
int |
indexForDate(TSDate date)
Computes the index that a date has respective to the range specified by this object, starting with 0. |
int[] |
indicesForRange(TSDateRange otherRange)
Computes the indices that a date range has within the range specified by this object, starting with 0. |
TSDate |
lowerBound()
Gets reference to start date of range. |
TSDateRange |
mergedRange(TSDateRange otherRange)
Returns the merged date range that starts at the earliest start date and ends at the latest enddate. |
int |
numOfObs()
Returns number of observations represented by this range. |
int |
subPeriodicity()
Gets the sub periodicity of this date range. |
java.lang.String[] |
timeAxisStringArray()
This method returns the range represented as an array of Strings, for example {"1960 Q1", "1960 Q2", ...., "1982 Q4"}. |
java.lang.String |
toString()
Returns a string representation of the specified range. |
TSDate |
upperBound()
Gets reference the last date of the range. |
static TSDateRange |
valueOf(java.lang.String exp)
Static initializer that creates a TSDateRange from a
string representation. |
| Methods inherited from class java.lang.Object |
|---|
getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public TSDateRange()
TSDate
with 100 observations.
public TSDateRange(TSDate t1,
int numberOfObs)
TSDateRange from specified start date and number
of observations.
t1 - numberOfObs - the number of observations within the range
java.lang.IllegalArgumentException - if numberOfObs <= 0
public TSDateRange(TSDate t1,
TSDate t2)
TSDateRange from specified start date and end
date.
t1 - the TSDate to start from (inklusive)t2 - the TSDate to end with (inklusive)
java.lang.IllegalArgumentException - if upperBound is earlier than
lowerBound or sub periodicities do not match| Method Detail |
|---|
public TSDateRange addPeriodsToStart(int periods)
TSDateRange range object with the start date
shifted by periods.
periods - the number of periods to shift the start date, can be
negative, which results in an earlier start, 0 creates a copy
of this
java.lang.IllegalArgumentException - if new range would be invalidpublic TSDateRange commonRange(TSDateRange otherRange)
The function is symmetric in the sense that
x.commonRange(y).equals(y.commonRange(x)).
otherRange - the range to be checked
java.lang.IllegalArgumentException - if argument is null
public double[][] createSeasDum(boolean centered,
boolean all)
double[][], see
createSeasDumTS(boolean, boolean).
centered - the sum over all dummy elements at every time index is 0, if
this is true, then all is ignored (and
false)all - if true then sub periodicity
dummies are created, if false then
sub periodicity - 1 dummies are created
double[][],null if
sub periodicity == 1 or if not enough observations
public TS[] createSeasDumTS(boolean centered,
boolean all)
If the number of observations of this time series is less than the sub
periodicity then null is returned, because the resulting
array could contain a zero vector.
centered - the sum over all dummy elements at every time index is 0, if
this is true, then all is ignored (and
false)all - if true then sub periodicity
dummies are created, if false then
sub periodicity - 1 dummies are created
null if sub
periodicity == 1 or if not enough observationspublic double[] createShiftDum(TSDateRange shiftRange)
double[] that is a shift dummy for this range,
see createShiftDumTS(java.lang.String, com.jstatcom.ts.TSDateRange).
shiftRange - the range within this range to specify the shift
double[]
java.lang.IllegalArgumentException - if shiftRange is not a valid range for this
rangepublic double[] createTrendShiftDum(TSDateRange shiftRange)
double[] that is a trend shift dummy for this
range, see createTrendShiftDumTS(java.lang.String, com.jstatcom.ts.TSDateRange).
shiftRange - the range within this range to specify the trend shift
double[]
java.lang.IllegalArgumentException - if shiftRange is not a valid range for this
range
public TS createTrendShiftDumTS(java.lang.String name,
TSDateRange shiftRange)
name - the name of the new TSshiftRange - the range within this range to specify the trend shift
java.lang.IllegalArgumentException - if name is null or empty, or if
shiftRange is not a valid range for this range
public TS createShiftDumTS(java.lang.String name,
TSDateRange shiftRange)
name - the name of the new TSshiftRange - the range within this range to specify the shift
java.lang.IllegalArgumentException - if name is null or empty, or if
shiftRange is not a valid range for this rangepublic java.lang.String encloses(TSDate date)
date - the date to check for
public java.lang.String encloses(TSDateRange otherRange)
otherRange - the range to check for
public boolean equals(java.lang.Object o)
equals to provide logical comparison of two
different TSDateRange objects.
equals in class java.lang.Objecto - object to compare with
true if start and end dates are both equal,
false otherwise
public java.lang.String format(java.lang.String description,
int space)
sample range: [1960 Q3, 1982 Q4], T = 90description.
description - a desriptive string that will be put in frontspace - the number of spaces between description and
the rest, useful for alignment, should be greater than 0,
otherwise will be set to 0
public TSDate dateForIndex(int index)
index - can also specify value outside the range
public int indexForDate(TSDate date)
date - the TSDate to compute the index for
java.lang.IllegalArgumentException - if subPeriodicities do not match or if date is nullpublic int[] indicesForRange(TSDateRange otherRange)
otherRange - the range to compute the bounds for
java.lang.IllegalArgumentException - if sub periodicities do not match or if
otherRange is not in the defined range,
because this usually means a programming errorpublic TSDate lowerBound()
public static TSDateRange getMergedRange(TS[] tsArray)
tsArray - an array of TS objects
java.lang.IllegalArgumentException - if one TS is null or if sub
periodicities are differentpublic int numOfObs()
public int subPeriodicity()
public TSDate upperBound()
public int hashCode()
hashCode(), because equals was overwritten. The
algorithm was taken from (Joshua Bloch, "Effective Java", Item 8)
.
hashCode in class java.lang.Objectpublic TSDateRange mergedRange(TSDateRange otherRange)
The function is symmetric in the sense that
x.mergedRange(y).equals(y.mergedRange(x)).
otherRange - the range to merge with
java.lang.IllegalArgumentException - if argument is null or if sub periodicities do not matchpublic java.lang.String[] timeAxisStringArray()
{"1960 Q1", "1960 Q2", ...., "1982 Q4"}.
public java.lang.String toString()
toString in class java.lang.Objectpublic static TSDateRange valueOf(java.lang.String exp)
TSDateRange from a
string representation. The string should be constructed as
TSDate string , TSDate string, and can optionally be
enclosed with [ ], for example
[1960 Q1, 1982 Q4]
1970, 2003
1953 6/12, 1994 1/12
1/1/60 (5), 10/3/73 (5)
1960.1, 1982.4 is NOT possible,
because it is not unique. For the string representation of a
TSDate object, see the documentation of its
valueOf method.
exp - the string to parse to a TSDateRange
TSDateRange object created from exp
java.lang.IllegalArgumentException - if object could not be constructed from given string or if
exp == nullTSDate
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||