正如 Richard 和 Bruce 所说,Notes 日历模式有据可查。如果您使用的是 N/D 8.5.3 或更早版本,则在创建日历条目时必须了解架构。但是,如果您使用的是 N/D 9.0 或更高版本,您可能会发现使用 Java NotesCalendar、NotesCalendarEntry 和 NotesCalendarNotice 接口更容易。这些新 API 需要对 iCalendar 有所了解,但使用 iCalendar 通常比完全了解 Notes 日历架构的详细信息要容易。
例如,考虑这个重复事件的 iCalendar 表示:
BEGIN:VCALENDAR
PRODID:-//Lotus Development Corporation//NONSGML Notes 9.0//EN_API_S
BEGIN:VEVENT
DTSTART:20140319T180000Z
DTEND:20140319T200000Z
TRANSP:OPAQUE
RRULE:FREQ=WEEKLY;COUNT=15;BYDAY=WE
SEQUENCE:0
CLASS:PUBLIC
SUMMARY:Track workout
LOCATION:High school track
END:VEVENT
END:VCALENDAR
此事件的第一个实例于 2014 年 3 月 19 日 18:00 UTC 开始(请参阅 DTSTART),并在 20:00 UTC 结束(请参阅 DTEND)。该活动每周三重复 15 周(参见 RRULE)。
您可以使用几行 Java 代码将此类事件添加到 Notes 数据库:
// Get the NotesCalendar object from the database
NotesCalendar notesCalendar = session.getCalendar(database);
if ( notesCalendar == null ) {
throw new Exception("Cannot open calendar.");
}
// Create the meeting on the Notes calendar
NotesCalendarEntry entry = notesCalendar.createEntry(icalendar);
在这段代码中,icalendar 只是一个包含上面显示的 iCalendar 数据的字符串,NotesCalendar 和 NotesCalendarEntry 接口来自lotus.domino 包。 createEntry 方法将事件添加到日历中。更好的是,它会自动向与会者发送邀请(当存在于 iCalendar 数据中时),并处理重复事件的复杂性。
有关更多 iCalendar 示例,请参阅iCalendar representation of an event。有关 iCalendar 规范,请参阅RFC5545。