1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package davmail.exchange.ews;
20
21 import java.io.IOException;
22 import java.io.Writer;
23
24
25
26
27 public class FieldUpdate {
28 FieldURI fieldURI;
29 String value;
30
31
32
33
34
35
36
37 public FieldUpdate(FieldURI fieldURI, String value) {
38 this.fieldURI = fieldURI;
39 this.value = value;
40 }
41
42 protected FieldUpdate() {
43
44 }
45
46
47
48
49
50
51
52
53 public void write(String itemType, Writer writer) throws IOException {
54 String action;
55
56 if (value == null || value.length() == 0) {
57 action = "Delete";
58 } else {
59 action = "Set";
60 }
61 if (itemType != null) {
62 writer.write("<t:");
63 writer.write(action);
64 writer.write(itemType);
65 writer.write("Field>");
66 }
67
68
69 if (itemType != null || (value != null && value.length() > 0)) {
70 StringBuilder buffer = new StringBuilder();
71 if (value == null || value.length() == 0) {
72 fieldURI.appendTo(buffer);
73 } else {
74 fieldURI.appendValue(buffer, itemType, value);
75 }
76 writer.write(buffer.toString());
77 }
78
79 if (itemType != null) {
80 writer.write("</t:");
81 writer.write(action);
82 writer.write(itemType);
83 writer.write("Field>");
84 }
85 }
86 }