Class Period

java.lang.Object
  extended byPeriod

public class Period
extends java.lang.Object

The Period class represents a consecutive period of time.


Constructor Summary
Period(java.util.Date begin, java.util.Date end)
          Creates a Period representing the time between the two given instants.
 
Method Summary
 boolean cover(Period p)
          Test if this period contains another period.
 java.util.Date getBegin()
          Return the beginning of the period.
 java.util.Date getEnd()
          Return the end of the period.
 Period intersect(Period p)
          Calculate the intersection of this period with another period.
 boolean overlapWith(Period p)
          Test if this Period overlaps with the given Period.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Period

public Period(java.util.Date begin,
              java.util.Date end)
       throws TDOMException
Creates a Period representing the time between the two given instants.

Parameters:
begin - The beginning instant of the period. The beginning instant is part of the period.
end - The ending instant of the period. The ending instant is not part of the period.
Throws:
TDOMException - Throw TDOMException with exception code INVALID_TIME_EXTENT if the beginning time is after or equal to the ending time.
Method Detail

getBegin

public java.util.Date getBegin()
Return the beginning of the period.

Returns:
A Date denoting the beginning of the period.

getEnd

public java.util.Date getEnd()
Return the end of the period.

Returns:
A Date denoting the end of the period.

overlapWith

public boolean overlapWith(Period p)
Test if this Period overlaps with the given Period.

Parameters:
p - Another Period to test.
Returns:
true if two periods overlap and false otherwise.

cover

public boolean cover(Period p)
Test if this period contains another period.

Parameters:
p - Another period to be tested if it's in this period.
Returns:
true if this period contains the given period and false otherwise.

intersect

public Period intersect(Period p)
Calculate the intersection of this period with another period.

Parameters:
p - Another Period with which the intersection is asked.
Returns:
If two periods overlap, return a Period representing the intersected part, otherwise return null.