EventRecurrencepublic class EventRecurrence extends Object
Fields Summary |
---|
public static final int | SECONDLY | public static final int | MINUTELY | public static final int | HOURLY | public static final int | DAILY | public static final int | WEEKLY | public static final int | MONTHLY | public static final int | YEARLY | public static final int | SU | public static final int | MO | public static final int | TU | public static final int | WE | public static final int | TH | public static final int | FR | public static final int | SA | public android.text.format.Time | startDate | public int | freq | public String | until | public int | count | public int | interval | public int | wkst | public int[] | bysecond | public int | bysecondCount | public int[] | byminute | public int | byminuteCount | public int[] | byhour | public int | byhourCount | public int[] | byday | public int[] | bydayNum | public int | bydayCount | public int[] | bymonthday | public int | bymonthdayCount | public int[] | byyearday | public int | byyeardayCount | public int[] | byweekno | public int | byweeknoCount | public int[] | bymonth | public int | bymonthCount | public int[] | bysetpos | public int | bysetposCount |
Constructors Summary |
---|
public EventRecurrence()
wkst = MO;
|
Methods Summary |
---|
private void | appendByDay(java.lang.StringBuilder s, int i)
int n = this.bydayNum[i];
if (n != 0) {
s.append(n);
}
String str = day2String(this.byday[i]);
s.append(str);
| private static void | appendNumbers(java.lang.StringBuilder s, java.lang.String label, int count, int[] values)
if (count > 0) {
s.append(label);
count--;
for (int i=0; i<count; i++) {
s.append(values[i]);
s.append(",");
}
s.append(values[count]);
}
| public static int | calendarDay2Day(int day)Converts one of the Calendar.SUNDAY constants to the SU, MO, etc.
constants. btw, I think we should switch to those here too, to
get rid of this function, if possible.
switch (day)
{
case Calendar.SUNDAY:
return SU;
case Calendar.MONDAY:
return MO;
case Calendar.TUESDAY:
return TU;
case Calendar.WEDNESDAY:
return WE;
case Calendar.THURSDAY:
return TH;
case Calendar.FRIDAY:
return FR;
case Calendar.SATURDAY:
return SA;
default:
throw new RuntimeException("bad day of week: " + day);
}
| public static int | day2CalendarDay(int day)Converts one of the SU, MO, etc. constants to the Calendar.SUNDAY
constants. btw, I think we should switch to those here too, to
get rid of this function, if possible.
switch (day)
{
case SU:
return Calendar.SUNDAY;
case MO:
return Calendar.MONDAY;
case TU:
return Calendar.TUESDAY;
case WE:
return Calendar.WEDNESDAY;
case TH:
return Calendar.THURSDAY;
case FR:
return Calendar.FRIDAY;
case SA:
return Calendar.SATURDAY;
default:
throw new RuntimeException("bad day of week: " + day);
}
| private static java.lang.String | day2String(int day)Converts one of the internal day constants (SU, MO, etc.) to the
two-letter string representing that constant.
switch (day) {
case SU:
return "SU";
case MO:
return "MO";
case TU:
return "TU";
case WE:
return "WE";
case TH:
return "TH";
case FR:
return "FR";
case SA:
return "SA";
default:
throw new IllegalArgumentException("bad day argument: " + day);
}
| public static int | day2TimeDay(int day)
switch (day)
{
case SU:
return Time.SUNDAY;
case MO:
return Time.MONDAY;
case TU:
return Time.TUESDAY;
case WE:
return Time.WEDNESDAY;
case TH:
return Time.THURSDAY;
case FR:
return Time.FRIDAY;
case SA:
return Time.SATURDAY;
default:
throw new RuntimeException("bad day of week: " + day);
}
| private java.lang.String | dayToString(android.content.res.Resources r, int day)
switch (day) {
case SU: return r.getString(com.android.internal.R.string.sunday);
case MO: return r.getString(com.android.internal.R.string.monday);
case TU: return r.getString(com.android.internal.R.string.tuesday);
case WE: return r.getString(com.android.internal.R.string.wednesday);
case TH: return r.getString(com.android.internal.R.string.thursday);
case FR: return r.getString(com.android.internal.R.string.friday);
case SA: return r.getString(com.android.internal.R.string.saturday);
default: throw new IllegalArgumentException("bad day argument: " + day);
}
| public java.lang.String | getRepeatString()
Resources r = Resources.getSystem();
// TODO Implement "Until" portion of string, as well as custom settings
switch (this.freq) {
case DAILY:
return r.getString(com.android.internal.R.string.daily);
case WEEKLY: {
if (repeatsOnEveryWeekDay()) {
return r.getString(com.android.internal.R.string.every_weekday);
} else {
String format = r.getString(com.android.internal.R.string.weekly);
StringBuilder days = new StringBuilder();
// Do one less iteration in the loop so the last element is added out of the
// loop. This is done so the comma is not placed after the last item.
int count = this.bydayCount - 1;
if (count >= 0) {
for (int i = 0 ; i < count ; i++) {
days.append(dayToString(r, this.byday[i]));
days.append(",");
}
days.append(dayToString(r, this.byday[count]));
return String.format(format, days.toString());
}
// There is no "BYDAY" specifier, so use the day of the
// first event. For this to work, the setStartDate()
// method must have been used by the caller to set the
// date of the first event in the recurrence.
if (startDate == null) {
return null;
}
int day = timeDay2Day(startDate.weekDay);
return String.format(format, dayToString(r, day));
}
}
case MONTHLY: {
return r.getString(com.android.internal.R.string.monthly);
}
case YEARLY:
return r.getString(com.android.internal.R.string.yearly);
}
return null;
| public native void | parse(java.lang.String recur)Parse an iCalendar/RFC2445 recur type according to Section 4.3.10.
| public boolean | repeatsMonthlyOnDayCount()
if (this.freq != MONTHLY) {
return false;
}
if (bydayCount != 1 || bymonthdayCount != 0) {
return false;
}
return true;
| public boolean | repeatsOnEveryWeekDay()
if (this.freq != WEEKLY) {
return false;
}
int count = this.bydayCount;
if (count != 5) {
return false;
}
for (int i = 0 ; i < count ; i++) {
int day = byday[i];
if (day == SU || day == SA) {
return false;
}
}
return true;
| public void | setStartDate(android.text.format.Time date)
startDate = date;
| public static int | timeDay2Day(int day)
switch (day)
{
case Time.SUNDAY:
return SU;
case Time.MONDAY:
return MO;
case Time.TUESDAY:
return TU;
case Time.WEDNESDAY:
return WE;
case Time.THURSDAY:
return TH;
case Time.FRIDAY:
return FR;
case Time.SATURDAY:
return SA;
default:
throw new RuntimeException("bad day of week: " + day);
}
| public java.lang.String | toString()
StringBuilder s = new StringBuilder();
s.append("FREQ=");
switch (this.freq)
{
case SECONDLY:
s.append("SECONDLY");
break;
case MINUTELY:
s.append("MINUTELY");
break;
case HOURLY:
s.append("HOURLY");
break;
case DAILY:
s.append("DAILY");
break;
case WEEKLY:
s.append("WEEKLY");
break;
case MONTHLY:
s.append("MONTHLY");
break;
case YEARLY:
s.append("YEARLY");
break;
}
if (!TextUtils.isEmpty(this.until)) {
s.append(";UNTIL=");
s.append(until);
}
if (this.count != 0) {
s.append(";COUNT=");
s.append(this.count);
}
if (this.interval != 0) {
s.append(";INTERVAL=");
s.append(this.interval);
}
if (this.wkst != 0) {
s.append(";WKST=");
s.append(day2String(this.wkst));
}
appendNumbers(s, ";BYSECOND=", this.bysecondCount, this.bysecond);
appendNumbers(s, ";BYMINUTE=", this.byminuteCount, this.byminute);
appendNumbers(s, ";BYSECOND=", this.byhourCount, this.byhour);
// day
int count = this.bydayCount;
if (count > 0) {
s.append(";BYDAY=");
count--;
for (int i=0; i<count; i++) {
appendByDay(s, i);
s.append(",");
}
appendByDay(s, count);
}
appendNumbers(s, ";BYMONTHDAY=", this.bymonthdayCount, this.bymonthday);
appendNumbers(s, ";BYYEARDAY=", this.byyeardayCount, this.byyearday);
appendNumbers(s, ";BYWEEKNO=", this.byweeknoCount, this.byweekno);
appendNumbers(s, ";BYMONTH=", this.bymonthCount, this.bymonth);
appendNumbers(s, ";BYSETPOS=", this.bysetposCount, this.bysetpos);
return s.toString();
|
|