001: package org.columba.calendar.model;
002:
003: import java.util.Calendar;
004: import java.util.List;
005:
006: import org.columba.calendar.model.api.IRecurrence;
007: import org.columba.calendar.model.api.IWeekDay;
008:
009: public class Recurrence implements IRecurrence {
010:
011: private int type;
012: private int endType;
013: private int endMaxOccurrences;
014: private Calendar endDate;
015: private int interval;
016: private List<IWeekDay> weekDays;
017:
018: public Recurrence(int type) {
019: this .type = type;
020: }
021:
022: public Recurrence(int type, int endType, int endMaxOccurrences,
023: Calendar endDate, int interval, List<IWeekDay> weekdays) {
024: this .type = type;
025: this .endType = endType;
026: this .endDate = endDate;
027: this .endMaxOccurrences = endMaxOccurrences;
028: this .interval = interval;
029: this .weekDays = weekdays;
030: }
031:
032: public Calendar getEndDate() {
033: return endDate;
034: }
035:
036: public int getEndMaxOccurrences() {
037: return endMaxOccurrences;
038: }
039:
040: public int getEndType() {
041: return endType;
042: }
043:
044: public int getInterval() {
045: return interval;
046: }
047:
048: public int getType() {
049: return type;
050: }
051:
052: public List getWeekDays() {
053: return weekDays;
054: }
055:
056: public void setEndDate(Calendar endDate) {
057: this .endDate = endDate;
058: }
059:
060: public void setEndMaxOccurrences(int max) {
061: this .endMaxOccurrences = max;
062: }
063:
064: public void setEndType(int type) {
065: this .endType = type;
066: }
067:
068: public void setInterval(int interval) {
069: this .interval = interval;
070: }
071:
072: public void setType(int type) {
073: this .type = type;
074: }
075:
076: public void setWeekDays(List<IWeekDay> days) {
077: this .weekDays = days;
078: }
079:
080: public static int toFrequency(int recurrenceType2) {
081: switch (recurrenceType2) {
082: case RECURRENCE_WEEKLY:
083: return java.util.Calendar.WEEK_OF_YEAR;
084: case RECURRENCE_DAILY:
085: return java.util.Calendar.DAY_OF_YEAR;
086: case RECURRENCE_ANNUALLY:
087: return java.util.Calendar.YEAR;
088: case RECURRENCE_MONTHLY:
089: return java.util.Calendar.MONTH;
090: }
091: return -1;
092: }
093:
094: public static int fromFrequency(int recurrenceType2) {
095: switch (recurrenceType2) {
096: case java.util.Calendar.WEEK_OF_YEAR:
097: return RECURRENCE_WEEKLY;
098: case java.util.Calendar.DAY_OF_YEAR:
099: return RECURRENCE_DAILY;
100: case java.util.Calendar.YEAR:
101: return RECURRENCE_ANNUALLY;
102: case java.util.Calendar.MONTH:
103: return RECURRENCE_MONTHLY;
104: }
105: return RECURRENCE_NONE;
106: }
107:
108: }
|