public abstract class Frequency extends Object
Constructor and Description |
---|
Frequency(int numUnits,
boolean isAnytime)
Initialise a frequency with information about how many periods between events, and whether it's at a specified
time in the period.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o)
Autogenerated equals.
|
abstract Date |
getFirstEvent(Date startTime)
Given a starting time, tell us when the first event should happen.
|
static Frequency |
getNewInstance(int timeunit,
boolean anytime,
int numtimeunits,
Integer minute,
Integer hour,
Integer dayofweek,
Integer dayofmonth)
Get a new instance of Frequency.
|
abstract 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).
|
int |
getNumUnits()
Returns the number of periods between events.
|
abstract 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.
|
abstract 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.
|
abstract 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.
|
abstract Integer |
getOnMinute()
Return the exact minute 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.
|
boolean |
isAnytime()
Returns whether this frequency allows events to happen any time of day, rather than at a specific time.
|
abstract int |
ordinal()
Return an integer that can be used to identify the kind of frequency.
|
public Frequency(int numUnits, boolean isAnytime)
The actual length of the period is defined by subclasses
numUnits
- Number of periods between eventsisAnytime
- Whether it's at a specified time in the periodArgumentNotValid
- if numUnits if 0 or negativepublic abstract Date getNextEvent(Date lastEvent)
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.
These methods are used by the schedule methods for calculating when events should happen.
lastEvent
- A time from which the next event should be calculated.public abstract Date getFirstEvent(Date startTime)
This method is used by the schedule methods for calculating when events should happen.
startTime
- The earliest time the event can happen.public int getNumUnits()
public boolean isAnytime()
public int hashCode()
public abstract Integer getOnMinute()
public abstract Integer getOnHour()
public abstract Integer getOnDayOfWeek()
public abstract Integer getOnDayOfMonth()
public abstract int ordinal()
public static Frequency getNewInstance(int timeunit, boolean anytime, int numtimeunits, Integer minute, Integer hour, Integer dayofweek, Integer dayofmonth)
timeunit
- The type or frequencyanytime
- Allow events to start anytime. If false, the starting point is described precisely. If true, the
starting point will be immediately.numtimeunits
- The number of periods between eventsminute
- A given minute. Used to create hourly, daily, and monthly frequencies, if anytime is false.hour
- A given hour. Used to create hourly, daily, and monthly frequencies, if anytime is false.dayofweek
- A given day of the week. Used only to create weekly frequencies, if anytime is false.dayofmonth
- A given day of month. Used only to create monthly frequencies, if anytime is false.ArgumentNotValid
- If the given timeunit is illegal, or the values of timeunit and numtimeunits is
negative.NotImplementedException
- If we can't yet make a Frequency for a legal timeunit.Copyright © 2005–2018 The Royal Danish Library, the National Library of France and the Austrian National Library.. All rights reserved.