JTemporal Home
Tutorial

net.sf.jtemporal.spi
Interface PeriodStorage

All Known Implementing Classes:
CompactPeriodStorage

public interface PeriodStorage

A storage for periods (sorted).
This is used by some other storages, such as TemporalSet

Version:
$Id: PeriodStorage.java,v 1.1 2005/06/05 21:49:30 tabeck Exp $

Method Summary
 void clear()
          Removes all the stored periods.
 Period firstPeriod()
          Returns the first (lowest) period currently in this storage, or null if any is found.
 Period getPeriod(Instant instant)
          Returns the period valid at the specified instant.
 Period getPeriodEndingAt(Instant instant)
          Returns the period finishing exactly at the given instant, if any is found.
 Period getPeriodStartingAt(Instant instant)
          Returns the period starting exactly at the given instant, if any is found.
 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 or null if empty.
 CloseableIterator periodIterator()
          Iterates over all the periods of the entries.
 CloseableIterator periodIterator(Period period)
          Iterates over all the periods of the storage that intersects the given period.
 void put(Period p)
          Stores a period.
 void remove(Period p)
          Removes a period previously stored.
 int size()
          Returns the number of Periods in this storage.
 

Method Detail

lastPeriod

Period lastPeriod()
Returns the last (highest) period currently in this storage or null if empty.

Returns:
the last (highest) period currently in this storage or null.

firstPeriod

Period firstPeriod()
Returns the first (lowest) period currently in this storage, or null if any is found.

Returns:
the first (lowest) period currently in this storage, or null.

isEmpty

boolean isEmpty()
Returns true if this storage does not contain objects.

Returns:
true if this storage does not contain objects..

isEmpty

boolean isEmpty(Period p)
Returns true if this storage does not contain objects intersecting the given period.

Parameters:
p - the intersecting period
Returns:
true if this storage does not contain objects intersecting the given period.

getPeriod

Period getPeriod(Instant instant)
Returns the period valid at the specified instant.

Parameters:
instant - the instant whose enclosing period must be returned
Returns:
the period valid at the specified instant. Returns null if this storage does not contain a period at the specified instant.

getPeriodEndingAt

Period getPeriodEndingAt(Instant instant)
Returns the period finishing exactly at the given instant, if any is found.

Parameters:
instant - the instant the equals the entry end
Returns:
the Period ending exactly at the given instant, or null.

getPeriodStartingAt

Period getPeriodStartingAt(Instant instant)
Returns the period starting exactly at the given instant, if any is found.

Parameters:
instant - the instant the equals the entry end
Returns:
the Period starting exactly at the given instant, or null.

clear

void clear()
Removes all the stored periods.

Throws:
java.lang.RuntimeException - (or any other subclass) if the operation could not be performed.

size

int size()
Returns the number of Periods in this storage. If the storage contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:
the number of periods in this storage.

put

void put(Period p)
Stores a period.
No particular check or rich semantics is expected, this method just stores.

Parameters:
p - period to be added to the storage. Cannot be null.
Throws:
java.lang.IllegalArgumentException - if some aspect of this period prevents it from being stored.

remove

void remove(Period p)
Removes a period previously stored.

The period must match the parameter previously used to call the put(Period) method.

Parameters:
p - the period to be removed
Throws:
java.util.NoSuchElementException - if the entry is not found
java.lang.IllegalArgumentException - if p is null

periodIterator

CloseableIterator periodIterator(Period period)
Iterates over all the periods of the storage that intersects the given period.
Note that the CloseableIterator#remove() method, removes the whole period, even if the entry has a period larger then the given period.
The instances are sorted by Period.equals(Object)

Parameters:
period - the intersecting period.
Returns:
instances of TimedObject
See Also:
Period

periodIterator

CloseableIterator periodIterator()
Iterates over all the periods of the entries.

The instances are sorted by Comparable.compareTo(Object)

Returns:
instances of Period
See Also:
Period

JTemporal Home
Tutorial