|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object dk.netarkivet.harvester.datamodel.Schedule
public abstract class Schedule
This class implements a schedule that can be either repeating or timed, depending on the subclass. 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.
Field Summary | |
---|---|
protected java.lang.String |
comments
Any comments added by the user. |
(package private) long |
edition
Edition is used by the DAO to keep track of changes. |
protected Frequency |
frequency
Frequency of runs, possibly with a time it should happen at. |
protected java.lang.String |
name
Human readable name for the schedule. |
protected java.util.Date |
startDate
first run of job: date, time (hour:min:sec). |
Constructor Summary | |
---|---|
protected |
Schedule(java.util.Date startDate,
Frequency frequency,
java.lang.String name,
java.lang.String comments)
Create a new schedule starting at a specific time and going on for an undefined time. |
Method Summary | |
---|---|
boolean |
equals(java.lang.Object o)
Autogenerated equals. |
java.lang.String |
getComments()
Returns any user-entered comments about this schedule. |
long |
getEdition()
Get the edition number. |
java.util.Date |
getFirstEvent(java.util.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. |
(package private) long |
getID()
Get the ID of this schedule. |
static Schedule |
getInstance(java.util.Date startDate,
java.util.Date endDate,
Frequency freq,
java.lang.String name,
java.lang.String comments)
Get a new Schedule instance for a schedule that runs over a certain period. |
static Schedule |
getInstance(java.util.Date startDate,
int repeats,
Frequency freq,
java.lang.String name,
java.lang.String comments)
Get a new Schedule instance for a schedule that runs a certain number of times. |
java.lang.String |
getName()
Get the name of this schedule. |
abstract java.util.Date |
getNextEvent(java.util.Date lastEvent,
int numPreviousEvents)
Return the date at which the next event will happen. |
java.util.Date |
getStartDate()
Get the first possible date this schedule is allowed to run. |
int |
hashCode()
Autogenerated hashcode method. |
(package private) boolean |
hasID()
Check if this schedule has an ID set yet (doesn't happen until the DBDAO persists it). |
void |
setComments(java.lang.String comments)
Set the comments for the schedule. |
void |
setEdition(long theEdition)
Set the edition number. |
(package private) void |
setID(long id)
Set the ID of this schedule. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.String name
protected java.lang.String comments
protected java.util.Date startDate
protected Frequency frequency
long edition
Constructor Detail |
---|
protected Schedule(java.util.Date startDate, Frequency frequency, java.lang.String name, java.lang.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 user
ArgumentNotValid
- if frequency, name or comments is null, or name
is ""Method Detail |
---|
public static Schedule getInstance(java.util.Date startDate, java.util.Date endDate, Frequency freq, java.lang.String name, java.lang.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 user
ArgumentNotValid
- if frequency, name or comments is null, or name
is ""public static Schedule getInstance(java.util.Date startDate, int repeats, Frequency freq, java.lang.String name, java.lang.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 user
ArgumentNotValid
- if frequency, name or comments is null, or name
is "" or repeats is 0 or negativepublic java.util.Date getFirstEvent(java.util.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 java.util.Date getNextEvent(java.util.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 java.lang.String getName()
getName
in interface Named
public java.util.Date getStartDate()
public Frequency getFrequency()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- The object to compare with
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String getComments()
getComments
in interface Named
public void setComments(java.lang.String comments)
comments
- The new commentspublic long getEdition()
public void setEdition(long theEdition)
theEdition
- The new editionlong getID()
void setID(long id)
id
- the new ID of this scheduleboolean hasID()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |