org.oddjob.schedules
Class SimpleInterval

java.lang.Object
  extended by org.oddjob.schedules.SimpleInterval
All Implemented Interfaces:
Serializable, Interval

public class SimpleInterval
extends Object
implements Interval, Serializable

A Simple implementation of an {@link Interval).

See Also:
Serialized Form
Author:
rob

Field Summary
 
Fields inherited from interface org.oddjob.schedules.Interval
END_OF_TIME, START_OF_TIME
 
Constructor Summary
SimpleInterval(Date on)
           
SimpleInterval(Date from, Date to)
          Constructor for an interval between two dates.
SimpleInterval(Interval other)
          The copy constructor.
SimpleInterval(long fromTime, long toTime)
          Constructor for an interval between two dates given as milliseconds.
 
Method Summary
 boolean equals(Object other)
          Test if two intervals are equivalent.
 Date getFromDate()
          The date the interval is from which includes this date.
 Date getToDate()
          The date the interval is up to but excluding.
 int hashCode()
          Crude implementation of hashCode, so intervals could be stored in HashSets.
 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

SimpleInterval

public SimpleInterval(Date on)
Parameters:
on -

SimpleInterval

public SimpleInterval(Date from,
                      Date to)
Constructor for an interval between two dates.

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

SimpleInterval

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

Parameters:
fromTime -
toTime -

SimpleInterval

public SimpleInterval(Interval other)
The copy constructor.

Parameters:
other - The other interval.
Method Detail

getFromDate

public Date getFromDate()
Description copied from interface: Interval
The date the interval is from which includes this date.

Specified by:
getFromDate in interface Interval
Returns:
Never null and alway less than the to date.

getToDate

public Date getToDate()
Description copied from interface: Interval
The date the interval is up to but excluding.

Specified by:
getToDate in interface Interval
Returns:
A date. Never and always greater than the from date.

hashCode

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

Overrides:
hashCode in class Object

equals

public boolean equals(Object other)
Test if two intervals are equivalent.

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

Overrides:
equals in class Object
Parameters:
other - The interval to test against.
Returns:
true if they are equal.

toString

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

Overrides:
toString in class Object