01: package org.garret.perst;
02:
03: /**
04: * Abstract base class for time series block.
05: * Progammer has to define its own block class derived from this class
06: * containign array of time series elements and providing getTicks()
07: * method to access this array. It is better no to initialize this array in constructor
08: * (because it will be also used when block will be loaded from the disk),
09: * but check in getTicks() method that array is null, and if so - create new array.
10: */
11: public abstract class TimeSeriesBlock extends Persistent {
12: public long timestamp;
13: public int used;
14:
15: public void writeObject(IOutputStream out) {
16: out.writeLong(timestamp);
17: out.writeInt(used);
18: }
19:
20: public void readObject(IInputStream in) {
21: timestamp = in.readLong();
22: used = in.readInt();
23: }
24:
25: /**
26: * Get time series elements stored in this block.
27: * @return preallocated array of time series element. Only <code>used</code>
28: * items of this array actually contains time series elements.
29: * But all array items should be not null and conain referen to Tick object.
30: */
31: public abstract TimeSeriesTick[] getTicks();
32: }
|