org.oddjob.schedules
Class IntervalTo

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

public class IntervalTo
extends Object
implements ScheduleResult

An Interval that extends to, but does not include the to date.

See Also:
Serialized Form
Author:
rob

Field Summary
 
Fields inherited from interface org.oddjob.schedules.Interval
END_OF_TIME, START_OF_TIME
 
Constructor Summary
IntervalTo(Date on)
          Create a point interval.
IntervalTo(Date from, Date upTo)
          Create an interval up to the to Date.
IntervalTo(Interval interval)
          Create an copy of the given Interval.
 
Method Summary
 boolean equals(Object other)
          Test if two intervals are equivalent.
protected  Date getEndDate()
          Get the to date of the interval.
 Date getFromDate()
          Get the from date of the interval.
 Date getToDate()
          Get the upTo date which is a millisecond after the inclusive to date.
 Date getUseNext()
          For recurring schedules this property provide the date that should be used for the next call to Schedule.nextDue(ScheduleContext) by using the ScheduleContext.move(Date) method.
 int hashCode()
          Crude implementation of hashCode, so intervals could be stored in HashSets.
 boolean isBefore(org.oddjob.schedules.IntervalBase other)
          Test if this interval is before the other interval.
 boolean isPast(org.oddjob.schedules.IntervalBase other)
          Test if this interval is past the other interval.
 boolean isPoint()
          Is this interval really a point in time, not an interval.
 Interval limit(Interval limit)
          Provide an interval which is the result of this Limit being limited by the given interval.
 String toString()
          Return a string representation of this interval.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.oddjob.schedules.Interval
getFromDate
 

Constructor Detail

IntervalTo

public IntervalTo(Date on)
Create a point interval.

Parameters:
on -

IntervalTo

public IntervalTo(Date from,
                  Date upTo)
Create an interval up to the to Date. The upTo date must be at least a millisecond greater than the from date. If they are the same then use the single date constructor.

Parameters:
from -
upTo -

IntervalTo

public IntervalTo(Interval interval)
Create an copy of the given Interval.

Parameters:
interval -
Method Detail

getToDate

public Date getToDate()
Get the upTo date which is a millisecond after the inclusive to date.

Specified by:
getToDate in interface Interval
Returns:

limit

public Interval limit(Interval limit)
Provide an interval which is the result of this Limit being limited by the given interval. This interval is the outer interval and the given interval is the refinement.

Results are determined as follows.

Parameters:
other - The other interval. may be null.
Returns:
The new interval.

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.


getUseNext

public Date getUseNext()
Description copied from interface: ScheduleResult
For recurring schedules this property provide the date that should be used for the next call to Schedule.nextDue(ScheduleContext) by using the ScheduleContext.move(Date) method. For most schedules this date will be identical to the Interval.getToDate() but for some schedules such AfterSchedule this will not be the case.

Specified by:
getUseNext in interface ScheduleResult
Returns:
A date. May be null to indicate there is no other next due for this schedule..

getFromDate

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

Returns:
The from date.

getEndDate

protected Date getEndDate()
Get the to date of the interval.

Returns:
The to date.

isBefore

public boolean isBefore(org.oddjob.schedules.IntervalBase 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(org.oddjob.schedules.IntervalBase 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.

isPoint

public boolean isPoint()
Is this interval really a point in time, not an interval.

Returns:
true if it is a point in time.