1 /*
2 * DavMail POP/IMAP/SMTP/CalDav/LDAP Exchange Gateway
3 * Copyright (C) 2010 Mickael Guessant
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20 package davmail.exchange.ews;
21
22 import java.io.IOException;
23 import java.io.Writer;
24
25 public class OccurrenceItemId extends ItemId {
26 protected final int instanceIndex;
27
28 /**
29 * Build Item id object from item id and change key.
30 *
31 * @param recurringMasterId recurring master id
32 * @param instanceIndex occurrence index
33 */
34 public OccurrenceItemId(String recurringMasterId, int instanceIndex) {
35 super("OccurrenceItemId", recurringMasterId);
36 this.instanceIndex = instanceIndex;
37 }
38
39 /**
40 * Build Item id object from item id and change key.
41 *
42 * @param recurringMasterId recurring master id
43 * @param changeKey change key
44 * @param instanceIndex occurrence index
45 */
46 public OccurrenceItemId(String recurringMasterId, String changeKey, int instanceIndex) {
47 super("OccurrenceItemId", recurringMasterId, changeKey);
48 this.instanceIndex = instanceIndex;
49 }
50
51 /**
52 * Write item id as XML.
53 *
54 * @param writer request writer
55 * @throws IOException on error
56 */
57 public void write(Writer writer) throws IOException {
58 writer.write("<t:");
59 writer.write(name);
60 writer.write(" RecurringMasterId=\"");
61 writer.write(id);
62 if (changeKey != null) {
63 writer.write("\" ChangeKey=\"");
64 writer.write(changeKey);
65 }
66 writer.write("\" InstanceIndex=\"");
67 writer.write(String.valueOf(instanceIndex));
68 writer.write("\"/>");
69 }
70
71 }