Class PeriodSet

java.lang.Object
  extended byPeriodSet

public class PeriodSet
extends java.lang.Object

The PeriodSet class actually represents temporal elements. It stores a list of non-consecutive and non-overlapping periods ordered ascendingly by time.


Constructor Summary
PeriodSet()
          Creates an empty PeriodSet.
 
Method Summary
 void addPeriod(Period p)
          Add a period to the set.
 int getLength()
          Get the number of non-overlapping periods in the set.
 Period getPeriod(int index)
          Get the indexth period in the set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PeriodSet

public PeriodSet()
Creates an empty PeriodSet.

Method Detail

getLength

public int getLength()
Get the number of non-overlapping periods in the set.

Returns:
Return the number of periods in the set.

getPeriod

public Period getPeriod(int index)
                 throws TDOMException
Get the indexth period in the set. The range of index is from 0 to the number of periods minus 1. Throw exception if the index is out of range.

Parameters:
index - of the wanted period.
Returns:
Return the indexth Period.
Throws:
TDOMException - Throw TDOMException with exception code INVALID_INDEX if the index is out of range.

addPeriod

public void addPeriod(Period p)
Add a period to the set. The added period is merged with the periods already in the set if they overlap or they become consecutive.

Parameters:
p - The period to be added.