EventListImplpublic class EventListImpl extends AbstractPIMList implements javax.microedition.pim.EventListClass EventListImpl implements methods of PIM interface EventList. |
Constructors Summary |
---|
EventListImpl(String name, int mode, Object handle)Constructs an Event list.
super(PIM.EVENT_LIST, name, mode, handle);
|
Methods Summary |
---|
private boolean | checkRange(int searchType, long startDate, long endDate, long eventStart, long eventEnd)Verifies search range.
switch (searchType) {
case EventList.STARTING:
return (eventStart >= startDate && eventStart <= endDate);
case EventList.ENDING:
return (eventEnd >= startDate && eventEnd <= endDate);
case EventList.OCCURRING:
return (eventStart <= endDate && eventEnd >= startDate);
default:
return false;
}
| public javax.microedition.pim.Event | createEvent()Creates a new event instance.
return new EventImpl(this);
| public int[] | getSupportedRepeatRuleFields(int frequency)Gets supported repeat rule fields.
switch (frequency) {
case RepeatRule.DAILY:
return new int[] {
RepeatRule.COUNT,
RepeatRule.INTERVAL,
RepeatRule.END
};
case RepeatRule.WEEKLY:
return new int[] {
RepeatRule.COUNT,
RepeatRule.INTERVAL,
RepeatRule.END,
RepeatRule.DAY_IN_WEEK
};
case RepeatRule.MONTHLY:
return new int[] {
RepeatRule.COUNT,
RepeatRule.INTERVAL,
RepeatRule.END,
RepeatRule.DAY_IN_WEEK,
RepeatRule.WEEK_IN_MONTH,
RepeatRule.DAY_IN_MONTH
};
case RepeatRule.YEARLY:
return new int[] {
RepeatRule.COUNT,
RepeatRule.INTERVAL,
RepeatRule.END,
RepeatRule.DAY_IN_WEEK,
RepeatRule.WEEK_IN_MONTH,
RepeatRule.DAY_IN_MONTH,
RepeatRule.MONTH_IN_YEAR,
RepeatRule.DAY_IN_YEAR
};
default:
throw new IllegalArgumentException("Unsupported frequency: "
+ frequency);
}
| public javax.microedition.pim.Event | importEvent(javax.microedition.pim.Event item)Creates new event from item template.
return new EventImpl(this, item);
| public java.util.Enumeration | items(int searchType, long startDate, long endDate, boolean initialEventOnly)Gets enumeration of Event items.
switch (searchType) {
case ENDING:
case OCCURRING:
case STARTING:
break;
default:
throw new IllegalArgumentException(
"Invalid search type: " + searchType);
}
if (startDate > endDate) {
throw new IllegalArgumentException(
"Start date must be earlier than end date");
}
Vector selectedItems = new Vector();
Vector itemKeys = new Vector();
for (Enumeration e = items(); e.hasMoreElements(); ) {
Event event = (Event) e.nextElement();
long eventStart = 0l;
long eventEnd = 0l;
// a START or END field may have at most one value
if (event.countValues(Event.START) != 0) {
eventStart = event.getDate(Event.START, 0);
if (event.countValues(Event.END) != 0) {
eventEnd = event.getDate(Event.END, 0);
} else {
// see specification of Event.END field: if
// END is not specified but START is, the event only
// occurs at the START time.
eventEnd = eventStart;
}
} else if (event.countValues(Event.END) != 0) {
// see specification of Event.START field: if
// START is not specified but END is, the event only
// occurs at the END time.
eventEnd = event.getDate(Event.END, 0);
eventStart = eventEnd;
} else {
// no start or end date
continue;
}
long duration = Math.max(0, eventEnd - eventStart);
RepeatRule repeatRule = event.getRepeat();
boolean includeItem = false;
if (repeatRule != null) {
// check all occurrences of the event
long timeSlot = eventEnd - eventStart;
Enumeration dates =
repeatRule.dates(eventStart,
Math.max(startDate - duration, 0), endDate);
while (dates.hasMoreElements()) {
Date date = (Date) dates.nextElement();
eventStart = date.getTime();
eventEnd = eventStart + timeSlot;
if (eventStart > endDate) {
// no point continuing
break;
}
includeItem =
checkRange(searchType,
startDate, endDate,
eventStart, eventEnd);
if (includeItem) {
break;
}
if (initialEventOnly) {
break;
}
}
} else {
// check the base occurrence
includeItem =
checkRange(searchType,
startDate, endDate,
eventStart, eventEnd);
}
if (includeItem) {
KeySortUtility.store(itemKeys, selectedItems,
eventStart, event);
}
}
return selectedItems.elements();
| public void | removeEvent(javax.microedition.pim.Event item)Removes event.
removeItem(item);
|
|