|
JTemporal Home Tutorial |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.jtemporal.CachedTimeSeries<V>
V
- the type of the valuepublic class CachedTimeSeries<V>
Caches an external TimeSeries (for ex. to hand code a database access).
Each time this collection is queried, if the value for the given instant is unknown,
the MissingInstantHandler is invoked. Then, the handler has the choice whether
to retrieve just the missing value, or other values, or other objects as well
to reduce call granularity (prefetch).
Internally a LightLRUCache is used to cache reads. Writes are not cached, if you
want to cache them, you should do it at the ChangeHandler level.
If you already have a persistence framework, you will eventually use this class on
top of that, in order to control and customize prefetching.
This class is NOT thread-safe.
LightLRUCache
Nested Class Summary | |
---|---|
static interface |
CachedTimeSeries.ChangeHandler<V>
Applies the changes on the underlying data source. |
static interface |
CachedTimeSeries.MissingElementHandler<V>
Reacts on missing elements. |
Constructor Summary | |
---|---|
CachedTimeSeries(int size,
CachedTimeSeries.MissingElementHandler<V> reader)
Creates a READ-ONLY CachedTimeSeries. |
|
CachedTimeSeries(int size,
CachedTimeSeries.MissingElementHandler<V> reader,
CachedTimeSeries.ChangeHandler<V> writer)
Creates a normal instance of CachedTimeSeries |
Method Summary | |
---|---|
void |
clearCache()
Clears the underlying cache. |
boolean |
containsInstant(Instant i)
Returns true if this TimeSeries contains a mapping for the specified Instant. |
V |
get(Instant i)
Gets the value currently associated to the i instant. |
V |
put(Instant i,
V value)
Creates a new entry in this timeseries. |
void |
putInCache(Instant i,
V value)
Writes in the cache only, without triggering the CachedTimeSeries.ChangeHandler. |
V |
remove(Instant i)
Removes an entry from this timeseries. |
void |
remove(Period p)
Remove a whole period from the timeseries (optional implementation). |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public CachedTimeSeries(int size, CachedTimeSeries.MissingElementHandler<V> reader)
size
- the size of the cache (number of entries)reader
- handles physical read requestspublic CachedTimeSeries(int size, CachedTimeSeries.MissingElementHandler<V> reader, CachedTimeSeries.ChangeHandler<V> writer)
size
- size the size of the cache (number of entries)reader
- handles physical read requestswriter
- handles write requestsMethod Detail |
---|
public V put(Instant i, V value)
TimeSeries
put
in interface TimeSeries<V>
i
- the instant whom the value must be associated to. Must be not null.value
- the value. Must be not null.
public void putInCache(Instant i, V value)
i
- the key of the entryvalue
- the value to be associated to the given instant,
or null
, if no value exists at the given instant.public V get(Instant i)
TimeSeries
get
in interface ReadableTemporalAttribute<V>
get
in interface TimeSeries<V>
i
- instant to query
public V remove(Instant i)
TimeSeries
remove
in interface TimeSeries<V>
i
- the instant to be removed. Must be not null.
public void remove(Period p)
TimeSeries
remove
in interface TimeSeries<V>
p
- the period enclosing the entries to be removed.public void clearCache()
public boolean containsInstant(Instant i)
TimeSeries
containsInstant
in interface TimeSeries<V>
i
- instant whose presence in this TimeSeries is to be tested.
public java.lang.String toString()
toString
in class java.lang.Object
|
JTemporal Home Tutorial |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |