org.treesched
Class Interval

java.lang.Object
  extended byorg.treesched.Interval
All Implemented Interfaces:
java.io.Serializable

public class Interval
extends java.lang.Object
implements java.io.Serializable

A representation of an interval between two dates.

Author:
Rob Gordon
See Also:
Serialized Form

Constructor Summary
Interval(java.util.Date at)
          Constructor for an interval that is for ever from the date.
Interval(java.util.Date from, java.util.Date to)
          Constructor for an interval between two dates.
Interval(Interval other)
          The copy constructor.
Interval(long fromTime)
          Constructor for an interval between a date given as milliseconds and for ever.
Interval(long fromTime, long toTime)
          Constructor for an interval between two dates given as milliseconds.
 
Method Summary
 boolean equals(java.lang.Object other)
          Test if two interval are equivelent.
 java.util.Date getFromDate()
          Get the from date of the interval.
 java.util.Date getToDate()
          Get the to date of the interval.
 int hashCode()
          Crude implementation of hashCode, so intervals could be stored in HashSets.
 boolean isBefore(Interval other)
          Test if this interval is before the other interval.
 boolean isPast(Interval other)
          Test if this interval is past the other interval.
 Interval limit(Interval limit)
          Limit the interval.
 java.lang.String toString()
          Return a string representation of this interval.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Interval

public Interval(java.util.Date at)
Constructor for an interval that is for ever from the date.

Parameters:
at - the start date for the inerval.

Interval

public Interval(java.util.Date from,
                java.util.Date to)
Constructor for an interval between two dates.

Parameters:
from - The starting date.
to - The ending date.

Interval

public Interval(long fromTime)
Constructor for an interval between a date given as milliseconds and for ever.

Parameters:
fromTime - The date given in milliseconds.

Interval

public Interval(long fromTime,
                long toTime)
Constructor for an interval between two dates given as milliseconds.

Parameters:
fromTime -
toTime -

Interval

public Interval(Interval other)
The copy constructor. This is a shallow copy.

Parameters:
other - The other interval.
Method Detail

getFromDate

public java.util.Date getFromDate()
Get the from date of the interval.

Returns:
The from date.

getToDate

public java.util.Date getToDate()
Get the to date of the interval.

Returns:
The to date.

hashCode

public int hashCode()
Crude implementation of hashCode, so intervals could be stored in HashSets.


equals

public boolean equals(java.lang.Object other)
Test if two interval are equivelent.

Intervals are equivelant if there start and end times are the same.

Parameters:
other - The interval to test against.
Returns:
true if they are equal.

isBefore

public boolean isBefore(Interval other)
Test if this interval is before the other interval.

This happens when this from time is less than other from time.

 this:    ----    or   ----
 other:    ----             ----
 

Parameters:
other -
Returns:
true if this is before the other.

isPast

public boolean isPast(Interval other)
Test if this interval is past the other interval.

This happens when the this from time is greater than the other ones to time.

 this:         ----
 other:   ----
 

Returns:
true if this is past the other.

limit

public Interval limit(Interval limit)
Limit the interval.

Returns:
The new interval.

toString

public java.lang.String toString()
Return a string representation of this interval.