org.ofbiz.service.calendar
Class RecurrenceRule

java.lang.Object
  extended by org.ofbiz.service.calendar.RecurrenceRule

public class RecurrenceRule
extends java.lang.Object

Recurrence Rule Object


Field Summary
protected  java.util.List byDayList
           
protected  java.util.List byHourList
           
protected  java.util.List byMinuteList
           
protected  java.util.List byMonthDayList
           
protected  java.util.List byMonthList
           
protected  java.util.List bySecondList
           
protected  java.util.List bySetPosList
           
protected  java.util.List byWeekNoList
           
protected  java.util.List byYearDayList
           
static int DAILY
          Frequency DAILY
static int HOURLY
          Frequency HOURLY
static int MAX_HR
           
static int MAX_MIN
           
static int MAX_MTH
           
static int MAX_MTH_DAY
           
static int MAX_SEC
           
static int MAX_WEEK_NO
           
static int MAX_YEAR_DAY
           
static int MIN_HR
           
static int MIN_MIN
           
static int MIN_MTH
           
static int MIN_MTH_DAY
           
static int MIN_SEC
           
static int MIN_WEEK_NO
           
static int MIN_YEAR_DAY
           
static int MINUTELY
          Frequency MINUTELY
static java.lang.String module
           
static int MONTHLY
          Frequency MONTHLY
protected  GenericValue rule
           
static int SECONDLY
          Frequency SECONDLY
static int WEEKLY
          Frequency WEEKLY
static int YEARLY
          Frequency YEARLY
 
Constructor Summary
RecurrenceRule(GenericValue rule)
          Creates a new RecurrenceRule object from a RecurrenceInfo entity.
 
Method Summary
 long getCount()
          Get the number of times this recurrence will run (-1 until end time).
 long getEndTime()
          Gets the end time of the recurrence rule or 0 if none.
 int getFrequency()
          Returns the frequency of this recurrence.
 java.lang.String getFrequencyName()
          Returns the frequency name of the recurrence.
 long getInterval()
          Returns the interval of the frequency.
 int getIntervalInt()
          Returns the interval of the frequency as an int.
 void init()
          Initializes the rules for this RecurrenceInfo object.
 boolean isValid(java.util.Date startDate, java.util.Date date)
          Tests the date to see if it falls within the rules
 boolean isValid(long startTime, long dateTime)
          Tests the date to see if it falls within the rules
static RecurrenceRule makeRule(GenericDelegator delegator, int frequency, int interval, int count)
           
static RecurrenceRule makeRule(GenericDelegator delegator, int frequency, int interval, int count, long endTime)
           
static RecurrenceRule makeRule(GenericDelegator delegator, int frequency, int interval, long endTime)
           
 long next(long startTime, long fromTime, long currentCount)
          Returns the next recurrence of this rule.
 java.lang.String primaryKey()
           
 void remove()
          Removes this rule from the persistant store.
 long validCurrent(long startTime, long checkTime, long currentCount)
          Gets the current recurrence (current for the checkTime) of this rule and returns it if it is valid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

module

public static final java.lang.String module

MIN_SEC

public static final int MIN_SEC
See Also:
Constant Field Values

MAX_SEC

public static final int MAX_SEC
See Also:
Constant Field Values

MIN_MIN

public static final int MIN_MIN
See Also:
Constant Field Values

MAX_MIN

public static final int MAX_MIN
See Also:
Constant Field Values

MIN_HR

public static final int MIN_HR
See Also:
Constant Field Values

MAX_HR

public static final int MAX_HR
See Also:
Constant Field Values

MIN_MTH_DAY

public static final int MIN_MTH_DAY
See Also:
Constant Field Values

MAX_MTH_DAY

public static final int MAX_MTH_DAY
See Also:
Constant Field Values

MIN_YEAR_DAY

public static final int MIN_YEAR_DAY
See Also:
Constant Field Values

MAX_YEAR_DAY

public static final int MAX_YEAR_DAY
See Also:
Constant Field Values

MIN_WEEK_NO

public static final int MIN_WEEK_NO
See Also:
Constant Field Values

MAX_WEEK_NO

public static final int MAX_WEEK_NO
See Also:
Constant Field Values

MIN_MTH

public static final int MIN_MTH
See Also:
Constant Field Values

MAX_MTH

public static final int MAX_MTH
See Also:
Constant Field Values

SECONDLY

public static final int SECONDLY
Frequency SECONDLY

See Also:
Constant Field Values

MINUTELY

public static final int MINUTELY
Frequency MINUTELY

See Also:
Constant Field Values

HOURLY

public static final int HOURLY
Frequency HOURLY

See Also:
Constant Field Values

DAILY

public static final int DAILY
Frequency DAILY

See Also:
Constant Field Values

WEEKLY

public static final int WEEKLY
Frequency WEEKLY

See Also:
Constant Field Values

MONTHLY

public static final int MONTHLY
Frequency MONTHLY

See Also:
Constant Field Values

YEARLY

public static final int YEARLY
Frequency YEARLY

See Also:
Constant Field Values

rule

protected GenericValue rule

bySecondList

protected java.util.List bySecondList

byMinuteList

protected java.util.List byMinuteList

byHourList

protected java.util.List byHourList

byDayList

protected java.util.List byDayList

byMonthDayList

protected java.util.List byMonthDayList

byYearDayList

protected java.util.List byYearDayList

byWeekNoList

protected java.util.List byWeekNoList

byMonthList

protected java.util.List byMonthList

bySetPosList

protected java.util.List bySetPosList
Constructor Detail

RecurrenceRule

public RecurrenceRule(GenericValue rule)
               throws RecurrenceRuleException
Creates a new RecurrenceRule object from a RecurrenceInfo entity.

Parameters:
rule - GenericValue object defining this rule.
Throws:
RecurrenceRuleException
Method Detail

init

public void init()
          throws RecurrenceRuleException
Initializes the rules for this RecurrenceInfo object.

Throws:
RecurrenceRuleException

getEndTime

public long getEndTime()
Gets the end time of the recurrence rule or 0 if none.

Returns:
long The timestamp of the end time for this rule or 0 for none.

getCount

public long getCount()
Get the number of times this recurrence will run (-1 until end time).

Returns:
long The number of time this recurrence will run.

getFrequencyName

public java.lang.String getFrequencyName()
Returns the frequency name of the recurrence.

Returns:
String The name of this frequency.

getFrequency

public int getFrequency()
Returns the frequency of this recurrence.

Returns:
int The reference value for the frequency

getInterval

public long getInterval()
Returns the interval of the frequency.

Returns:
long Interval value

getIntervalInt

public int getIntervalInt()
Returns the interval of the frequency as an int.

Returns:
The interval of this frequency as an integer.

next

public long next(long startTime,
                 long fromTime,
                 long currentCount)
Returns the next recurrence of this rule.

Parameters:
startTime - The time this recurrence first began.
fromTime - The time to base the next recurrence on.
currentCount - The total number of times the recurrence has run.
Returns:
long The next recurrence as a long.

validCurrent

public long validCurrent(long startTime,
                         long checkTime,
                         long currentCount)
Gets the current recurrence (current for the checkTime) of this rule and returns it if it is valid. If the current recurrence is not valid, doesn't try to find a valid one, instead returns 0.

Parameters:
startTime - The time this recurrence first began.
checkTime - The time to base the current recurrence on.
currentCount - The total number of times the recurrence has run.
Returns:
long The current recurrence as long if valid. If next recurrence is not valid, returns 0.

isValid

public boolean isValid(java.util.Date startDate,
                       java.util.Date date)
Tests the date to see if it falls within the rules

Parameters:
startDate - date object to test
Returns:
True if the date is within the rules

isValid

public boolean isValid(long startTime,
                       long dateTime)
Tests the date to see if it falls within the rules

Parameters:
startTime - date object to test
Returns:
True if the date is within the rules

remove

public void remove()
            throws RecurrenceRuleException
Removes this rule from the persistant store.

Throws:
RecurrenceRuleException

primaryKey

public java.lang.String primaryKey()

makeRule

public static RecurrenceRule makeRule(GenericDelegator delegator,
                                      int frequency,
                                      int interval,
                                      int count)
                               throws RecurrenceRuleException
Throws:
RecurrenceRuleException

makeRule

public static RecurrenceRule makeRule(GenericDelegator delegator,
                                      int frequency,
                                      int interval,
                                      long endTime)
                               throws RecurrenceRuleException
Throws:
RecurrenceRuleException

makeRule

public static RecurrenceRule makeRule(GenericDelegator delegator,
                                      int frequency,
                                      int interval,
                                      int count,
                                      long endTime)
                               throws RecurrenceRuleException
Throws:
RecurrenceRuleException