简体   繁体   English

iCal4j解析来自ICS的会议请求

[英]iCal4j parse meeting request from ICS

I want to parse ics files received from an Exchange using iCal4j to create a VEvent for local processing, and modify them to create a new time proposal ( COUNTER method) for sending them back to the Exchange. 我想使用iCal4j解析从Exchange接收到的ics文件,以创建用于本地处理的VEvent ,并对其进行修改以创建新的时间建议( COUNTER方法),以将其发送回Exchange。 The problem is that I was only able to build Calendar objects (see the code below), no VEvent . 问题是我只能构建Calendar对象(请参见下面的代码),而不能VEvent

File file = new File(PATH);
CalendarBuilder builder = new CalendarBuilder();
net.fortuna.ical4j.model.Calendar cal = null;
try {
    FileInputStream fis = new FileInputStream(file);
    cal = builder.build(fis);
} catch (Exception e) {
    e.printStackTrace();
}

Most probably, I would be able to create the replies from scratch, but if I could create them from the invite directly, I guess the result would be more likely to work. 最有可能的是,我可以从头开始创建答复,但是如果我可以直接从邀请中创建答复,我想结果很可能会起作用。 Also, I really would like to avoid parsing the files manually and hack around with string matching and things like that. 另外,我真的很想避免手动解析文件,而避免使用字符串匹配之类的东西。

It seems that the solution is rather simple, it is just not detailed in the examples of iCal4j, where I was looking for help. 看来解决方案相当简单,只是在我正在寻求帮助的iCal4j示例中未作详细介绍。 (Sorry, I am a novice programmer). (对不起,我是新手程序员)。 But after looking into the API reference of iCal4j , I found the following: 但是在查看了iCal4jAPI参考之后 ,我发现了以下内容:

If you parse an ics file to a Calendar object, it will have only a few Properties , like METHOD , PRODID and VERSION in our case. 如果将ics文件解析为Calendar对象,则在本例中它将只有几个Properties ,例如METHODPRODIDVERSION But it might (and most probably will) have some Components too, like VEvent , VTodo , etc, which is the actual content of the ics file. 但是它也可能(而且很可能会)有一些组件 ,例如VEventVTodo等,这是ics文件的实际内容。 You can get the Components' list with 您可以通过以下方式获取组件列表

ComponentList cl = cal.getComponents();

For us, parsing, modifying and sending them will be much easier than creating them from scratch. 对于我们来说,解析,修改和发送它们比从头开始创建它们要容易得多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM