net.sf.borg.model
Class Repeat

java.lang.Object
  extended by net.sf.borg.model.Repeat

public class Repeat
extends Object

A helper class for calculating all things about repeating appointments. It is mainly an iterator that can take repeat parameters for an appointment and iterate through the repeats


Field Summary
static String BIWEEKLY
           
static String DAILY
           
static String DAYLIST
           
static String MONTHLY
           
static String MONTHLY_DAY
           
static String MWF
           
static String NDAYS
           
static String ONCE
           
static String TTH
           
static String WEEKDAYS
           
static String WEEKENDS
           
static String WEEKLY
           
static String YEARLY
           
 
Constructor Summary
Repeat(Calendar start, String frequency)
          Instantiates a new repeat object
 
Method Summary
static int calculateRepeatNumber(Calendar current, Appointment appt)
          Calculate the number of a repeat given the date and the appointment
static int calculateTimes(Appointment appt)
          calculate the repeat times value for an appointment based on the until date or the repeat times
(package private)  Calendar current()
          get the current date of this iterator
static String freqString(String uistring, Integer ndays, boolean rptnum, Collection<Integer> daylist)
          generate the encoded frequency string that is stored in the appointment - that encodes frequency, daylist, and repeat number flag
static String freqToEnglish(String fr)
          convert the translated frequency string to the internal string
static Collection<Integer> getDaylist(String f)
          Gets the daylist from the encoded appointment string
static String getFreq(String f)
          Gets the frequency from the encoded appointment string
static String getFreqString(int i)
          get the translated string for a frequency
static String getFreqString(String fr)
          get the translated string for a frequency
static int getNDays(String f)
          Gets the n days from the encoded appointment string
static boolean getRptNum(String f)
          Gets the repeat number flag from the encoded appointment string
static boolean isCompatible(Calendar date, String freq, Collection<Integer> daylist)
          Checks to see if a particular day is valid for certain strict repeat types
(package private)  boolean isRepeating()
           
static boolean isRepeating(Appointment ap)
          Checks if an appointment repeats
(package private)  Calendar next()
          iterate to the next repeat date.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TTH

public static final String TTH
See Also:
Constant Field Values

MWF

public static final String MWF
See Also:
Constant Field Values

WEEKENDS

public static final String WEEKENDS
See Also:
Constant Field Values

WEEKDAYS

public static final String WEEKDAYS
See Also:
Constant Field Values

YEARLY

public static final String YEARLY
See Also:
Constant Field Values

MONTHLY_DAY

public static final String MONTHLY_DAY
See Also:
Constant Field Values

MONTHLY

public static final String MONTHLY
See Also:
Constant Field Values

BIWEEKLY

public static final String BIWEEKLY
See Also:
Constant Field Values

WEEKLY

public static final String WEEKLY
See Also:
Constant Field Values

DAILY

public static final String DAILY
See Also:
Constant Field Values

NDAYS

public static final String NDAYS
See Also:
Constant Field Values

DAYLIST

public static final String DAYLIST
See Also:
Constant Field Values

ONCE

public static final String ONCE
See Also:
Constant Field Values
Constructor Detail

Repeat

Repeat(Calendar start,
       String frequency)
Instantiates a new repeat object

Parameters:
start - the start date of the repeat (the appointment date)
frequency - the frequency string from the appointment
Method Detail

isCompatible

public static boolean isCompatible(Calendar date,
                                   String freq,
                                   Collection<Integer> daylist)
Checks to see if a particular day is valid for certain strict repeat types

Parameters:
date - the date
freq - the frequency
daylist - the daylist (for repeat with a list of days)
Returns:
true, if the daye is compatible with the repeat frequency

getFreqString

public static String getFreqString(int i)
get the translated string for a frequency

Parameters:
i - the index of the frequency
Returns:
the translation

getFreqString

public static String getFreqString(String fr)
get the translated string for a frequency

Parameters:
fr - the internal frequency string
Returns:
the translation

freqToEnglish

public static String freqToEnglish(String fr)
convert the translated frequency string to the internal string

Parameters:
fr - the trnalsated frequency
Returns:
the internal frequency string

freqString

public static String freqString(String uistring,
                                Integer ndays,
                                boolean rptnum,
                                Collection<Integer> daylist)
generate the encoded frequency string that is stored in the appointment - that encodes frequency, daylist, and repeat number flag

Parameters:
uistring - the translated frequency string from the ui
ndays - the ndays field from the UI for NDAYS repeating
rptnum - the "show repeat number" flag
daylist - the daylist for DAYLIST repeating
Returns:
the string

getFreq

public static String getFreq(String f)
Gets the frequency from the encoded appointment string

Parameters:
f - the frequency string from the appointment
Returns:
the frequency

getRptNum

public static boolean getRptNum(String f)
Gets the repeat number flag from the encoded appointment string

Parameters:
f - the frequency string from the appointment
Returns:
the repeat number flag

getDaylist

public static Collection<Integer> getDaylist(String f)
Gets the daylist from the encoded appointment string

Parameters:
f - the frequency string from the appointment
Returns:
the daylist

getNDays

public static int getNDays(String f)
Gets the n days from the encoded appointment string

Parameters:
f - the encoded appointment string
Returns:
the n days value

isRepeating

final boolean isRepeating()
Returns:
true, if this object represents a repeating item

isRepeating

public static boolean isRepeating(Appointment ap)
Checks if an appointment repeats

Parameters:
ap - the appointment
Returns:
true, if the appointment is repeating

current

final Calendar current()
get the current date of this iterator

Returns:
the current date

calculateRepeatNumber

public static final int calculateRepeatNumber(Calendar current,
                                              Appointment appt)
Calculate the number of a repeat given the date and the appointment

Parameters:
current - the date
appt - the appointment
Returns:
the number of the repeat (starting with 1)

next

final Calendar next()
iterate to the next repeat date.

Returns:
the next repeat date

calculateTimes

public static int calculateTimes(Appointment appt)
calculate the repeat times value for an appointment based on the until date or the repeat times

Parameters:
appt - the appointment
Returns:
repeat times


Generated September 24 2010 by mbb using Apache Ant version 1.7.1 compiled on June 27 2008 and Java version 1.6.0_20 from Sun Microsystems Inc. on Linux i386 2.6.24-28-generic