dk.netarkivet.harvester.datamodel
Class TimedSchedule

java.lang.Object
  extended by dk.netarkivet.harvester.datamodel.Schedule
      extended by dk.netarkivet.harvester.datamodel.TimedSchedule
All Implemented Interfaces:
Named, java.io.Serializable

public class TimedSchedule
extends Schedule

This class implements a schedule that runs over a specified period of time.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class dk.netarkivet.harvester.datamodel.Schedule
comments, edition, frequency, name, startDate
 
Constructor Summary
TimedSchedule(java.util.Date startDate, java.util.Date endDate, Frequency frequency, java.lang.String name, java.lang.String comments)
          Create a new TimedSchedule that runs over a period of time.
 
Method Summary
 boolean equals(java.lang.Object o)
          Autogenerated equals.
 java.util.Date getEndDate()
          Get the last possible time an event may be allowed.
 java.util.Date getNextEvent(java.util.Date lastEvent, int numPreviousEvents)
          Return the date at which the next event will happen.
 int hashCode()
          Autogenerated hashcode method.
 java.lang.String toString()
          Human readable represenation of this object.
 
Methods inherited from class dk.netarkivet.harvester.datamodel.Schedule
getComments, getEdition, getFirstEvent, getFrequency, getID, getInstance, getInstance, getName, getStartDate, hasID, setComments, setEdition, setID
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TimedSchedule

TimedSchedule(java.util.Date startDate,
              java.util.Date endDate,
              Frequency frequency,
              java.lang.String name,
              java.lang.String comments)
Create a new TimedSchedule that runs over a period of time.

Parameters:
startDate - The time at which the schedule starts running. This is not necessarily the time of the first event, but no events will happen before this. May be null, meaning start any time.
endDate - The time at which the schedule stops running. No events will happen after this. May be null, meaning continue forever.
frequency - How frequently the event should happen.
comments - Comments entered by the user
name - The unique name of the schedule.
Throws:
ArgumentNotValid - if frequency, name or comments is null, or name is "" or
Method Detail

equals

public boolean equals(java.lang.Object o)
Autogenerated equals.

Overrides:
equals in class Schedule
Parameters:
o - The object to compare with
Returns:
Whether objects are equal

hashCode

public int hashCode()
Autogenerated hashcode method.

Overrides:
hashCode in class Schedule
Returns:
the hashcode

getNextEvent

public java.util.Date getNextEvent(java.util.Date lastEvent,
                                   int numPreviousEvents)
Return the date at which the next event will happen. If the calculated next date is exactly equal to the end date then that value is returned. If it is after the end date, null is returned.

Specified by:
getNextEvent in class Schedule
Parameters:
lastEvent - The time at which the previous event happened. If this is null, then the method returns null. Ie once one is after the last event one is always after the last event.
numPreviousEvents - How many events have previously happened (ignored).
Returns:
The date of the next event to happen or null for no more events.
Throws:
ArgumentNotValid - if numPreviousEvents is negative

getEndDate

public java.util.Date getEndDate()
Get the last possible time an event may be allowed.

Returns:
The last date, null means no last date, continue forever.

toString

public java.lang.String toString()
Human readable represenation of this object.

Overrides:
toString in class java.lang.Object
Returns:
Human readble representation