JTemporal Home
Tutorial

net.sf.jtemporal.spi
Class TemporalAttributeStorageProxy

java.lang.Object
  extended by net.sf.jtemporal.spi.TemporalAttributeStorageProxy
All Implemented Interfaces:
TemporalAttributeStorage

public abstract class TemporalAttributeStorageProxy
extends java.lang.Object
implements TemporalAttributeStorage

A skeletont for building a proxy. Delegates all the calls to a given instance of TemporalAttributeStorage. You can interecept any delegate call by overriding the method.
It has been marked as abstract, even there is nothing abstract inside, since it does not make sense to use it without subclassing it.

Version:
$Id: TemporalAttributeStorageProxy.java,v 1.3 2007/05/27 08:53:44 tabeck Exp $

Constructor Summary
TemporalAttributeStorageProxy(TemporalAttributeStorage storage)
          Creates a new instance on top of an exisitng storage.
 
Method Summary
 void beginAtomicOperation()
          Tells the storage that the JTemporal client is calling a method that can result in multiples updates in the storage.
 void clear()
          Removes all the stored mappings.
 boolean containsValue(java.lang.Object value)
          Returns true if this map maps one or more Periods to the specified value.
 boolean containsValue(java.lang.Object value, Period range)
          Returns true if this map maps one or more Periods to the specified value, during the specified period.
 void endAtomicOperation()
          Tells the storage that an atomic operation has finished.
 CloseableIterator entryIterator()
          Iterates over all the entries of the storage.
 CloseableIterator entryIterator(Period p)
          Iterates over all the entries of the storage that intersects the period P.
 Period firstPeriod()
          Returns the first (lowest) period currently in this storage.
 Period firstPeriod(Period p)
          Returns the first (lowest) period currently in this storage, that intersects the given period.
 TimedObject getEntry(Instant instant)
          Returns the entry valid at the given instant, if any is found.
 TimedObject getEntryEndingAt(Instant instant)
          Returns the entry finishing exactly at the given instant, if any is found.
 TimedObject getEntryStartingAt(Instant instant)
          Returns the entry starting exactly at the given instant, if any is found.
 Period getPeriod(Instant instant)
          Returns the period that encloses the given instant, if any is found.
 java.lang.Object getValue(Instant instant)
          Returns the value to which this map maps the specified Instant.
 boolean isEmpty()
          Returns true if this storage does not contain objects.
 boolean isEmpty(Period p)
          Returns true if this storage does not contain objects intersecting the given period.
 Period lastPeriod()
          Returns the last (highest) period currently in this storage.
 Period lastPeriod(Period p)
          Returns the last (highest) period currently in this storage, that intersects the given period.
 CloseableIterator periodIterator()
          Iterates over all the periods of the storage.
 CloseableIterator periodIterator(Period p)
          Iterates over all the periods of the storage that intersects the period P.
 void put(Period p, java.lang.Object value)
          Stores a mapping (entry, tuple, row) composed by period and value.
 void removeEntry(Period p)
          Removes an entry composed by period and value previously stored.
 int removeRange(Period range)
          Removes all the entries whose period indersects the given period.
 int size()
          Returns the number of Period-value mappings in this map.
 int size(Period p)
          Returns the number of Period-value mappings in this map, for the given priod.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemporalAttributeStorageProxy

public TemporalAttributeStorageProxy(TemporalAttributeStorage storage)
Creates a new instance on top of an exisitng storage.

Parameters:
storage - the storage whose updates are interesting you.
Method Detail

lastPeriod

public Period lastPeriod()
Description copied from interface: TemporalAttributeStorage
Returns the last (highest) period currently in this storage.

Specified by:
lastPeriod in interface TemporalAttributeStorage
Returns:
the last (highest) period currently in this storage.

lastPeriod

public Period lastPeriod(Period p)
Description copied from interface: TemporalAttributeStorage
Returns the last (highest) period currently in this storage, that intersects the given period.
Note the the returned period may be larger than p.

Specified by:
lastPeriod in interface TemporalAttributeStorage
Parameters:
p - the intersecting period
Returns:
the last (highest) period currently in this storage.

firstPeriod

public Period firstPeriod()
Description copied from interface: TemporalAttributeStorage
Returns the first (lowest) period currently in this storage.

Specified by:
firstPeriod in interface TemporalAttributeStorage
Returns:
the first (lowest) period currently in this storage.

firstPeriod

public Period firstPeriod(Period p)
Description copied from interface: TemporalAttributeStorage
Returns the first (lowest) period currently in this storage, that intersects the given period.
Note the the returned period may be larger than p.

Specified by:
firstPeriod in interface TemporalAttributeStorage
Parameters:
p - the intersecting period
Returns:
the first (lowest) period currently in this storage.

isEmpty

public boolean isEmpty()
Description copied from interface: TemporalAttributeStorage
Returns true if this storage does not contain objects.

Specified by:
isEmpty in interface TemporalAttributeStorage
Returns:
true if this storage does not contain objects..

isEmpty

public boolean isEmpty(Period p)
Description copied from interface: TemporalAttributeStorage
Returns true if this storage does not contain objects intersecting the given period.

Specified by:
isEmpty in interface TemporalAttributeStorage
Parameters:
p - the intersecting period
Returns:
true if this storage does not contain objects intersecting the given period.

containsValue

public boolean containsValue(java.lang.Object value)
Description copied from interface: TemporalAttributeStorage
Returns true if this map maps one or more Periods to the specified value.

Specified by:
containsValue in interface TemporalAttributeStorage
Parameters:
value - value whose presence in this map is to be tested.
Returns:
true if this map maps one or more keys to the specified value.

containsValue

public boolean containsValue(java.lang.Object value,
                             Period range)
Description copied from interface: TemporalAttributeStorage
Returns true if this map maps one or more Periods to the specified value, during the specified period.

Specified by:
containsValue in interface TemporalAttributeStorage
Parameters:
value - value whose presence in this map is to be tested.
range - the period intersecting the value mappings
Returns:
true if this map maps one or more keys to the specified value.

getValue

public java.lang.Object getValue(Instant instant)
Description copied from interface: TemporalAttributeStorage
Returns the value to which this map maps the specified Instant. Returns null if the map contains no mapping at this Instant. It is not possible to map to a null Instant.

Specified by:
getValue in interface TemporalAttributeStorage
Parameters:
instant - instant whose associated value is to be returned
Returns:
the value to which this map maps the specified instant. returns null if this map does not contain a mapping for the specified instant.

getPeriod

public Period getPeriod(Instant instant)
Description copied from interface: TemporalAttributeStorage
Returns the period that encloses the given instant, if any is found.

Specified by:
getPeriod in interface TemporalAttributeStorage
Parameters:
instant - instant whose associated value is to be returned
Returns:
the value to which this map maps the specified instant. returns null if this map does not contain a mapping for the specified instant.

getEntry

public TimedObject getEntry(Instant instant)
Description copied from interface: TemporalAttributeStorage
Returns the entry valid at the given instant, if any is found.

Specified by:
getEntry in interface TemporalAttributeStorage
Parameters:
instant - instant whose associated value is to be returned
Returns:
the period and value to which this map maps the specified instant. returns null if this map does not contain a mapping for the specified instant.

getEntryEndingAt

public TimedObject getEntryEndingAt(Instant instant)
Description copied from interface: TemporalAttributeStorage
Returns the entry finishing exactly at the given instant, if any is found.

Specified by:
getEntryEndingAt in interface TemporalAttributeStorage
Parameters:
instant - the instant the equals the entry end
Returns:
the entry ending exactly at the given instant, or null.

getEntryStartingAt

public TimedObject getEntryStartingAt(Instant instant)
Description copied from interface: TemporalAttributeStorage
Returns the entry starting exactly at the given instant, if any is found.

Specified by:
getEntryStartingAt in interface TemporalAttributeStorage
Parameters:
instant - the instant the equals the entry end
Returns:
the entry starting exactly at the given instant, or null.

clear

public void clear()
Description copied from interface: TemporalAttributeStorage
Removes all the stored mappings.

Specified by:
clear in interface TemporalAttributeStorage

size

public int size()
Description copied from interface: TemporalAttributeStorage
Returns the number of Period-value mappings in this map. If the map contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Specified by:
size in interface TemporalAttributeStorage
Returns:
the number of Instant-value mappings in this map.

size

public int size(Period p)
Description copied from interface: TemporalAttributeStorage
Returns the number of Period-value mappings in this map, for the given priod. If the map contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Specified by:
size in interface TemporalAttributeStorage
Parameters:
p - the intersecting period
Returns:
the number of Instant-value mappings in this map.

beginAtomicOperation

public void beginAtomicOperation()
Description copied from interface: TemporalAttributeStorage
Tells the storage that the JTemporal client is calling a method that can result in multiples updates in the storage.
This is not exactly a transaction.
If the storage supports transactions, this method suggests to perform all the following operations inside the same transaction.
For example, this method is called by TemporalAttributeImpl at the beginning of the put(Period, Object) method, then TemporalAttributeImpl calls some times the put and remove methods, then finally it calls TemporalAttributeStorage.endAtomicOperation().
If your storage supports nested transactions, this is the inner one. Non persistent implemetations just return with no action.
Must not throw any exception (including unchecked exceptions).

Specified by:
beginAtomicOperation in interface TemporalAttributeStorage
See Also:
TemporalAttributeStorage.endAtomicOperation()

endAtomicOperation

public void endAtomicOperation()
Description copied from interface: TemporalAttributeStorage
Tells the storage that an atomic operation has finished. If the storage supports transactions, it should commit if a transaction has been started by TemporalAttributeStorage.beginAtomicOperation().
Non persistent implemetations just return with no action.
Must not throw any exception (including unchecked exceptions).

Specified by:
endAtomicOperation in interface TemporalAttributeStorage
See Also:
TemporalAttributeStorage.beginAtomicOperation()

put

public void put(Period p,
                java.lang.Object value)
Description copied from interface: TemporalAttributeStorage
Stores a mapping (entry, tuple, row) composed by period and value.
No particular check or rich semantics is expected, this method just stores.

Specified by:
put in interface TemporalAttributeStorage
Parameters:
p - period with which the specified value is associated. Cannot be null.
value - value to be associated with the specified key. Cannot be null.

removeEntry

public void removeEntry(Period p)
Description copied from interface: TemporalAttributeStorage
Removes an entry composed by period and value previously stored.

Specified by:
removeEntry in interface TemporalAttributeStorage
Parameters:
p - period whose mapping is to be removed from the storage. It must exactly match the key of an existing entry.

removeRange

public int removeRange(Period range)
Description copied from interface: TemporalAttributeStorage
Removes all the entries whose period indersects the given period.

Specified by:
removeRange in interface TemporalAttributeStorage
Parameters:
range - the period specifying that range whose interecting entries are to be deleted.
Returns:
the number of deleted entries (or Integer.MAX_VALUE if bigger than that).

entryIterator

public CloseableIterator entryIterator()
Description copied from interface: TemporalAttributeStorage
Iterates over all the entries of the storage.
The instances are sorted by Period.equals(Object)

Specified by:
entryIterator in interface TemporalAttributeStorage
Returns:
instances of TimedObject
See Also:
TimedObject

entryIterator

public CloseableIterator entryIterator(Period p)
Description copied from interface: TemporalAttributeStorage
Iterates over all the entries of the storage that intersects the period P.
Note that the CloseableIterator#remove() method, removes the whole entry, even if the entry has a period lager then the period p.
The instances are sorted by Period.equals(Object)

Specified by:
entryIterator in interface TemporalAttributeStorage
Parameters:
p - the intersecting period.
Returns:
instances of TimedObject
See Also:
TimedObject

periodIterator

public CloseableIterator periodIterator()
Description copied from interface: TemporalAttributeStorage
Iterates over all the periods of the storage.
The instances are sorted by Period.equals(Object)

Specified by:
periodIterator in interface TemporalAttributeStorage
Returns:
instances of Period
See Also:
Period

periodIterator

public CloseableIterator periodIterator(Period p)
Description copied from interface: TemporalAttributeStorage
Iterates over all the periods of the storage that intersects the period P.
Note that the CloseableIterator#remove() method, removes the whole entry, even if the entry has a period lager then the period p.
The instances are sorted by Period.equals(Object)

Specified by:
periodIterator in interface TemporalAttributeStorage
Parameters:
p - the intersecting period.
Returns:
instances of Period
See Also:
Period

JTemporal Home
Tutorial