dk.netarkivet.harvester.datamodel
Class MonthlyFrequency

java.lang.Object
  extended by dk.netarkivet.harvester.datamodel.Frequency
      extended by dk.netarkivet.harvester.datamodel.MonthlyFrequency

public class MonthlyFrequency
extends Frequency

This class implements a frequency of a number of months.


Constructor Summary
MonthlyFrequency(int numUnits)
          Create a new monthly frequency that happens every numUnits month, anytime.
MonthlyFrequency(int numUnits, int dayOfMonth, int hour, int minute)
          Create a new monthly frequency that happens every numUnits month, on the given day of month, hour and minute.
 
Method Summary
 boolean equals(java.lang.Object o)
          Autogenerated equals.
 int getDayOfMonth()
          If not anytime, the day in the month at which events should start.
 java.util.Date getFirstEvent(java.util.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.
 java.util.Date getNextEvent(java.util.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).
 java.lang.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.
 java.lang.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.
 java.lang.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.
 java.lang.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.
 int ordinal()
          Return an integer that can be used to identify the kind of frequency.
 java.lang.String toString()
          Human readable representation of this object.
 
Methods inherited from class dk.netarkivet.harvester.datamodel.Frequency
getNewInstance, getNumUnits, isAnytime
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MonthlyFrequency

public MonthlyFrequency(int numUnits)
Create a new monthly frequency that happens every numUnits month, anytime.

Parameters:
numUnits - Number of days from event to event.
Throws:
ArgumentNotValid - if numUnits if 0 or negative

MonthlyFrequency

public MonthlyFrequency(int numUnits,
                        int dayOfMonth,
                        int hour,
                        int minute)
Create a new monthly frequency that happens every numUnits month, on the given day of month, hour and minute.

Parameters:
numUnits - Number of days from event to event.
dayOfMonth - The day of the month the event should happen. The month starts on day 1.
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 dayOfMonth <1 or >31 or hour is <0 or >23 or minutes is <0 or >59
Method Detail

getNextEvent

public java.util.Date getNextEvent(java.util.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 class Frequency
Parameters:
lastEvent - A time from which the next event should be calculated.
Returns:
At what point the event should happen next.

getFirstEvent

public java.util.Date getFirstEvent(java.util.Date startTime)
Given a starting time, tell us when the first event should happen.

Specified by:
getFirstEvent in class Frequency
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

getDayOfMonth

public int getDayOfMonth()
If not anytime, the day in the month at which events should start.

Returns:
the day

equals

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

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

hashCode

public int hashCode()
Autogenerated hashcode method.

Overrides:
hashCode in class Frequency
Returns:
the hashcode

getOnMinute

public java.lang.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.

Specified by:
getOnMinute in class Frequency
Returns:
the exact minute event should happen on

getOnHour

public java.lang.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.

Specified by:
getOnHour in class Frequency
Returns:
the exact hour event should happen on

getOnDayOfWeek

public java.lang.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 class Frequency
Returns:
the exact day of week event should happen on

getOnDayOfMonth

public java.lang.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 class Frequency
Returns:
the exact day of month event should happen on

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

Specified by:
ordinal in class Frequency
Returns:
an integer that can be used to identify the kind of frequency

toString

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

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