T
- the value typepublic abstract class AbstractTimeSeries<T> extends Object implements TimeAddressable<T>
RegularTimeSeries
and SparseTimeSeries
.Constructor and Description |
---|
AbstractTimeSeries()
The parameterless constructor always throws an UnsupportedOperationException.
|
AbstractTimeSeries(Class<T> type,
TimeDomain domain,
T missingValue)
Construct a time series with the given time domain, data type, and missing value.
|
Modifier and Type | Method and Description |
---|---|
protected int |
accept(TimeAddressable<T> updates,
UpdateReviewer<T> reviewer)
Return the number of updates rejected by the reviewer.
|
TimeAddressable<T> |
copy()
Return a copy of the time series.
|
T |
get(long t)
Return the value at the given numerical time index.
|
abstract TimeAddressable<T> |
get(long first,
long last)
Return a new time series corresponding to the range between two numerical time indexes.
|
T |
get(TimeIndex t)
Return the value identified by the given time index.
|
Observation<T> |
getFirst(TimeIndex t)
Return the observation at or after the given time.
|
long |
getFirstIndex()
Return the numerical time index of the first element, or -1 when there is no data.
|
Observation<T> |
getLast(TimeIndex t)
Return the observation at or before the given time.
|
long |
getLastIndex()
Return the numerical time index of the last element, or -1 when there is no data.
|
T |
getMissingValue()
Return the object representing missing values.
|
Range |
getRange()
Return the range of the time series.
|
int |
getSize()
Return the number of values.
|
TimeDomain |
getTimeDomain()
Return the time domain of the time series.
|
Class<T> |
getType()
Return the type of he observations.
|
protected abstract void |
internalClear()
Remove all values from the time series.
|
protected abstract T |
internalGet(long time)
Get the value identified by the given numerical time index.
|
protected abstract Collection<T> |
internalGetData()
Return all values as a
Collection . |
protected abstract Observation<T> |
internalGetFirst(long index)
Return the observation at or after the given numerical time index.
|
protected abstract long |
internalGetFirstIndex()
Return the numerical time index of the first element.
|
protected abstract Observation<T> |
internalGetLast(long time)
Return the observation at or before the given numerical time index.
|
protected abstract long |
internalGetLastIndex()
Return the numerical time index of the last element.
|
protected abstract int |
internalGetSize()
Return the used size of the data structure where values are stored.
|
protected abstract void |
internalPut(long time,
T value)
Put the value into the series at the given numerical time index.
|
protected abstract void |
internalRemove(long time)
Remove the value at the given numerical time index.
|
protected abstract void |
internalSetBounds(long first,
long last)
Shrink the range to the one given by the two numerical time indexes.
|
boolean |
isMissing(T value)
Return true if the given value is missing.
|
static <X> TimeAddressable<X> |
make(Class<X> type,
TimeDomain domain,
boolean forceSparse)
Construct a time series of the type and domain specified.
|
protected T |
normalizeMissingValue(T value)
Replace all objects equal to the missing value with the "official"
missing value object.
|
void |
put(long index,
T value)
Put a value identified by a numerical time index into the time series.
|
void |
put(long index,
T[] values)
Put an array of values identified with the numerical time index of its
first element into the time series.
|
void |
put(TimeAddressable<T> values,
UpdateReviewer<T> reviewer)
Conditionally put all values from another time series into this time series.
|
void |
put(TimeIndex t,
T value)
Put a value identified by a time index into the time series.
|
void |
put(TimeIndex t,
T[] values)
Put an array of values identified with time index of its first element
into the time series.
|
void |
remove(TimeIndex t)
Remove the value identified by the time index.
|
boolean |
setRange(Range range)
Set the range to the intersection of the current range with the given range.
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
asIndexable, get, getValueCount, isIndexable, iterator, makeEmptyCopy
forEach, spliterator
public AbstractTimeSeries()
public AbstractTimeSeries(Class<T> type, TimeDomain domain, T missingValue)
type
- data type of observationsdomain
- a non-null time domainmissingValue
- the object to use for representing missing valuespublic static <X> TimeAddressable<X> make(Class<X> type, TimeDomain domain, boolean forceSparse)
forceParse
is true, or when the domain resolution is less than a day,
the time series returned is addressable (sparse), else it is indexable
(regular).X
- corresponds to the value typetype
- non-null value typedomain
- a non-null time domainforceSparse
- if true, always return a sparse time seriespublic boolean isMissing(T value)
TimeAddressable
isMissing
in interface TimeAddressable<T>
public TimeAddressable<T> copy() throws T2Exception
TimeAddressable
copy
in interface TimeAddressable<T>
T2Exception
public T get(long t) throws T2Exception
TimeAddressable
get
in interface TimeAddressable<T>
t
- a numberT2Exception
public abstract TimeAddressable<T> get(long first, long last) throws T2Exception
TimeAddressable
get
in interface TimeAddressable<T>
first
- a numerical time index giving the lower bound of the wanted rangelast
- a numerical time index giving the upper bound of the wanted rangeT2Exception
public T get(TimeIndex t) throws T2Exception
TimeAddressable
get
in interface TimeAddressable<T>
t
- a non-null time indexT2Exception
public Class<T> getType()
TimeAddressable
getType
in interface TimeAddressable<T>
public TimeDomain getTimeDomain()
TimeAddressable
getTimeDomain
in interface TimeAddressable<T>
public Range getRange()
TimeAddressable
getRange
in interface TimeAddressable<T>
public long getFirstIndex()
TimeAddressable
TimeIndex
, use TimeAddressable.getRange()
.getFirstIndex
in interface TimeAddressable<T>
public long getLastIndex()
TimeAddressable
TimeIndex
, use TimeAddressable.getRange()
.getLastIndex
in interface TimeAddressable<T>
public Observation<T> getLast(TimeIndex t) throws T2Exception
TimeAddressable
getLast
in interface TimeAddressable<T>
t
- a time indexT2Exception
public Observation<T> getFirst(TimeIndex t) throws T2Exception
TimeAddressable
getFirst
in interface TimeAddressable<T>
t
- a time indexT2Exception
public int getSize()
TimeAddressable
getSize
in interface TimeAddressable<T>
public void put(long index, T value) throws T2Exception
TimeAddressable
put
in interface TimeAddressable<T>
index
- a numerical time indexvalue
- a valueT2Exception
public void put(long index, T[] values) throws T2Exception
TimeAddressable
put
in interface TimeAddressable<T>
index
- a numerical time indexvalues
- a non-null array of valuesT2Exception
public void put(TimeAddressable<T> values, UpdateReviewer<T> reviewer) throws T2Exception
TimeAddressable
Important note. When the implementation of the values time series
does not explicitly represent missing values (see SparseTimeSeries
for example),
this method cannot be relied upon for "deleting" values of the target.
put
in interface TimeAddressable<T>
values
- a non-null time seriesreviewer
- a reviewerT2Exception
public void put(TimeIndex t, T value) throws T2Exception
TimeAddressable
put
in interface TimeAddressable<T>
t
- a non-null time indexvalue
- a valueT2Exception
public void put(TimeIndex t, T[] values) throws T2Exception
TimeAddressable
put
in interface TimeAddressable<T>
t
- a non-null time indexvalues
- a non-null array of valuesT2Exception
public void remove(TimeIndex t) throws T2Exception
TimeAddressable
remove
in interface TimeAddressable<T>
t
- a non-null time indexT2Exception
public boolean setRange(Range range) throws T2Exception
TimeAddressable
setRange
in interface TimeAddressable<T>
range
- the new range will be the intersection of the current range with this oneT2Exception
public T getMissingValue()
TimeAddressable
getMissingValue
in interface TimeAddressable<T>
protected T normalizeMissingValue(T value) throws T2Exception
Null values are illegal and produce an exception, unless they represent missing values.
value
- the value to normalizeT2Exception
protected int accept(TimeAddressable<T> updates, UpdateReviewer<T> reviewer) throws T2Exception
updates
- a non-null time series of updatesreviewer
- a non-null reviewerT2Exception
protected abstract long internalGetFirstIndex()
protected abstract long internalGetLastIndex()
protected abstract Observation<T> internalGetFirst(long index) throws T2Exception
Observation
, only a special rule for this method).index
- a numberT2Exception
protected abstract Observation<T> internalGetLast(long time) throws T2Exception
Observation
, only a special rule for this method).time
- a numerical time indexT2Exception
protected abstract void internalClear()
protected abstract T internalGet(long time) throws T2Exception
time
- a numerical time indexT2Exception
protected abstract int internalGetSize()
protected abstract void internalPut(long time, T value) throws T2Exception
The method silently ignores missing values added out of range. Adding missing values at the boundary shrinks the range.
time
- a numerical time indexvalue
- a valueT2Exception
protected abstract void internalRemove(long time) throws T2Exception
time
- a numerical time indexT2Exception
protected abstract void internalSetBounds(long first, long last) throws T2Exception
first
- a numerical time index giving the lower bound of the new rangelast
- a numerical time index giving the upper bound of the new rangeT2Exception
protected abstract Collection<T> internalGetData()
Collection
.Copyright © 2017. All rights reserved.