public abstract class Schedule extends Object implements Serializable, Named
A schedule is a combination of a frequency, defining how often this schedule and at which points in time will trigger an event , plus information about when to start and when to stop triggering events.
Methods are provided to check when the first event should happen, and to calculate the next events from the previous event time.
Modifier and Type | Field and Description |
---|---|
protected String |
comments
Any comments added by the user.
|
protected Frequency |
frequency
Frequency of runs, possibly with a time it should happen at.
|
protected String |
name
Human readable name for the schedule.
|
protected Date |
startDate
first run of job: date, time (hour:min:sec).
|
Modifier | Constructor and Description |
---|---|
protected |
Schedule(Date startDate,
Frequency frequency,
String name,
String comments)
Create a new schedule starting at a specific time and going on for an undefined time.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o)
Autogenerated equals.
|
String |
getComments()
Returns any user-entered comments about this schedule.
|
long |
getEdition()
Get the edition number.
|
Date |
getFirstEvent(Date now)
Return the date at which the first event will happen.
|
Frequency |
getFrequency()
Get the frequency defining how often and when this schedule should be run.
|
static Schedule |
getInstance(Date startDate,
Date endDate,
Frequency freq,
String name,
String comments)
Get a new Schedule instance for a schedule that runs over a certain period.
|
static Schedule |
getInstance(Date startDate,
int repeats,
Frequency freq,
String name,
String comments)
Get a new Schedule instance for a schedule that runs a certain number of times.
|
String |
getName()
Get the name of this schedule.
|
abstract Date |
getNextEvent(Date lastEvent,
int numPreviousEvents)
Return the date at which the next event will happen.
|
Date |
getStartDate()
Get the first possible date this schedule is allowed to run.
|
int |
hashCode()
Autogenerated hashcode method.
|
void |
setComments(String comments)
Set the comments for the schedule.
|
void |
setEdition(long theEdition)
Set the edition number.
|
protected Date startDate
protected Schedule(Date startDate, Frequency frequency, String name, String comments)
startDate
- Time at which the schedule starts happening (though not necessarily the time of the first
event). May be null, meaning at any time.frequency
- How frequently the events should happenname
- The unique name of this schedule.comments
- Comments entered by the userArgumentNotValid
- if frequency, name or comments is null, or name is ""public static Schedule getInstance(Date startDate, Date endDate, Frequency freq, String name, String comments)
startDate
- The first date an event is allowed to happen. May be null, meaning at any time.endDate
- The last date an event is allowed to happen. May be null meaning continue forever.freq
- How frequently the events should happen.name
- The name of this schedule.comments
- Comments entered by the userArgumentNotValid
- if frequency, name or comments is null, or name is ""public static Schedule getInstance(Date startDate, int repeats, Frequency freq, String name, String comments)
startDate
- The first date an event is allowed to happen. May be null, meaning at any time.repeats
- How many events should happen on this schedule.freq
- How frequently the events should happen.name
- The name of this schedule.comments
- Comments entered by the userArgumentNotValid
- if frequency, name or comments is null, or name is "" or repeats is 0 or negativepublic Date getFirstEvent(Date now)
now
- The first time it can happen. Will be normalized to only second precision, milliseconds are set to 0.ArgumentNotValid
- if now is nullpublic abstract Date getNextEvent(Date lastEvent, int numPreviousEvents)
lastEvent
- The time at which the previous event happened.numPreviousEvents
- How many events have previously happened.ArgumentNotValid
- if numPreviousEvents is negativepublic Date getStartDate()
public Frequency getFrequency()
public int hashCode()
public String getComments()
getComments
in interface Named
public void setComments(String comments)
comments
- The new commentspublic long getEdition()
public void setEdition(long theEdition)
theEdition
- The new editionCopyright © 2005–2015 The Royal Danish Library, the Danish State and University Library, the National Library of France and the Austrian National Library.. All rights reserved.