Class WeeklyFrequency
- java.lang.Object
-
- dk.netarkivet.harvester.datamodel.Frequency
-
- dk.netarkivet.harvester.datamodel.WeeklyFrequency
-
public class WeeklyFrequency extends Frequency
This class implements a frequency of a number of weeks.
-
-
Constructor Summary
Constructors Constructor Description WeeklyFrequency(int numUnits)
Create a new weekly frequency that happens every numUnits weeks, anytime.WeeklyFrequency(int numUnits, int dayOfWeek, int hour, int minute)
Create a new weekly frequency that happens every numUnits days, on the given day of week, hour, and minute.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
Autogenerated equals.int
getDayOfWeek()
If not anytime, the day in the week at which events should start.Date
getFirstEvent(Date startTime)
Given a starting time, tell us when the first event should happen.int
getHour()
If not anytime, the hour at which events should start.int
getMinute()
If not anytime, the minute at which events should start.Date
getNextEvent(Date lastEvent)
Given when the last event happened, tell us when the next event should happen (even if the new event is in the past).Integer
getOnDayOfMonth()
Return the exact day of month event should happen on, or null if this is an anyTime event or doesn't define what day of month it should happen on.Integer
getOnDayOfWeek()
Return the exact day of week event should happen on, or null if this is an anyTime event or doesn't define what day of week it should happen on.Integer
getOnHour()
Return the exact hour event should happen on, or null if this is an anyTime event or doesn't define what hour it should happen on.Integer
getOnMinute()
Return the exact minute this event should happen on, or null if this is an anyTime event or doesn't define what minute it should happen on.int
hashCode()
Autogenerated hashcode method.int
ordinal()
Return an integer that can be used to identify the kind of frequency.String
toString()
Human readable representation of this object.-
Methods inherited from class dk.netarkivet.harvester.datamodel.Frequency
getNewInstance, getNumUnits, isAnytime
-
-
-
-
Constructor Detail
-
WeeklyFrequency
public WeeklyFrequency(int numUnits)
Create a new weekly frequency that happens every numUnits weeks, anytime.- Parameters:
numUnits
- Number of weeks from event to event.- Throws:
ArgumentNotValid
- if numUnits if 0 or negative
-
WeeklyFrequency
public WeeklyFrequency(int numUnits, int dayOfWeek, int hour, int minute)
Create a new weekly frequency that happens every numUnits days, on the given day of week, hour, and minute.- Parameters:
numUnits
- Number of days from event to event.dayOfWeek
- Which day of the week this event should happen. Sunday is day 1 of the week.hour
- The hour on which the event should happen.minute
- The minute of hour on which the event should happen.- Throws:
ArgumentNotValid
- if numUnits if 0 or negative or dayOfWeek <1=SUNDAY >7=SATURDAY or hour is <0 or >23 or minutes is <0 or >59
-
-
Method Detail
-
getNextEvent
public Date getNextEvent(Date lastEvent)
Given when the last event happened, tell us when the next event should happen (even if the new event is in the past).The time of the next event is guaranteed to be later that lastEvent. For certain frequencies (e.g. once a day, any time of day), the time of the next event is derived from lastEvent, for others (e.g. once a day at 13:00) the time of the next event is the first matching time after lastEvent.
- Specified by:
getNextEvent
in classFrequency
- Parameters:
lastEvent
- A time from which the next event should be calculated.- Returns:
- At what point the event should happen next.
-
getFirstEvent
public Date getFirstEvent(Date startTime)
Given a starting time, tell us when the first event should happen.- Specified by:
getFirstEvent
in classFrequency
- Parameters:
startTime
- The earliest time the event can happen.- Returns:
- At what point the event should happen the first time.
-
getMinute
public int getMinute()
If not anytime, the minute at which events should start.- Returns:
- the minute
-
getHour
public int getHour()
If not anytime, the hour at which events should start.- Returns:
- the hour
-
getDayOfWeek
public int getDayOfWeek()
If not anytime, the day in the week at which events should start.- Returns:
- the day. Sunday=1
-
equals
public boolean equals(Object o)
Autogenerated equals.
-
hashCode
public int hashCode()
Autogenerated hashcode method.
-
getOnMinute
public Integer getOnMinute()
Return the exact minute this event should happen on, or null if this is an anyTime event or doesn't define what minute it should happen on.- Specified by:
getOnMinute
in classFrequency
- Returns:
- the exact minute this event should happen on
-
getOnHour
public Integer getOnHour()
Return the exact hour event should happen on, or null if this is an anyTime event or doesn't define what hour it should happen on.
-
getOnDayOfWeek
public Integer getOnDayOfWeek()
Return the exact day of week event should happen on, or null if this is an anyTime event or doesn't define what day of week it should happen on.- Specified by:
getOnDayOfWeek
in classFrequency
- Returns:
- the exact day of week event should happen on
-
getOnDayOfMonth
public Integer getOnDayOfMonth()
Return the exact day of month event should happen on, or null if this is an anyTime event or doesn't define what day of month it should happen on.- Specified by:
getOnDayOfMonth
in classFrequency
- Returns:
- null (always)
-
ordinal
public int ordinal()
Return an integer that can be used to identify the kind of frequency. No two subclasses should use the same integer
-
-