public class Quantizer extends Object
The basic idea is to align timestamp. This is done by splitting up time in quantized time frames. The size of these time frames is defined by time and unit.
This class provides some helper methods to calculate timestamp based on parameters provided in the constructor.
The Quantizer can also be initialized with a maximum number of time frames (count).
Constructor and Description |
---|
Quantizer(long time,
TimeUnit unit) |
Quantizer(long time,
TimeUnit unit,
int count) |
Modifier and Type | Method and Description |
---|---|
Date |
getEnd(Date timestamp)
Get the end timestamp of a time frame
|
Date |
getEndOfPeriod(Date now) |
Date |
getNext(Date start)
Get the timestamp following a quantized timestamp
|
Date |
getPrevious(Date start)
Get the timestamp preceeding a quantized timestamp
|
Date |
getStart(Date timestamp)
Quantize to starting point before or at given timestamp
|
Date |
getValidStart(Date timestamp)
Get a quantized start timestamp if the timestamp is in the valid period
of the quantizer
This method calculates a quantized timestamp pointing at the start of the time frame the timestamp is in. |
protected Date |
getValidStart(Date timestamp,
Date now) |
String |
toString() |
public Quantizer(long time, TimeUnit unit)
public Quantizer(long time, TimeUnit unit, int count)
public Date getValidStart(Date timestamp)
null
.timestamp
- an un-quantized timestampnull
if the
timestamp is out of rangepublic Date getStart(Date timestamp)
timestamp
- the given timestamp (not quantized)null
if given timestamp
was nullpublic Date getNext(Date start)
start
- an already quantized timestamppublic Date getPrevious(Date start)
start
- an already quantized timestamppublic Date getEnd(Date timestamp)
timestamp
- an already quantized timestampCopyright © 2016 Eclipse NeoSCADA Project. All rights reserved.