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 davmail.util.StringUtil;
22
23
24
25
26 public class ExtendedFieldURI implements FieldURI {
27
28 @SuppressWarnings({"UnusedDeclaration"})
29 protected enum PropertyType {
30 ApplicationTime, ApplicationTimeArray, Binary, BinaryArray, Boolean, CLSID, CLSIDArray, Currency, CurrencyArray,
31 Double, DoubleArray, Error, Float, FloatArray, Integer, IntegerArray, Long, LongArray, Null, Object,
32 ObjectArray, Short, ShortArray, SystemTime, SystemTimeArray, String, StringArray
33 }
34
35 @SuppressWarnings({"UnusedDeclaration"})
36 protected enum DistinguishedPropertySetType {
37 Meeting, Appointment, Common, PublicStrings, Address, InternetHeaders, CalendarAssistant, UnifiedMessaging, Task
38 }
39
40
41 protected String propertyTag;
42 protected DistinguishedPropertySetType distinguishedPropertySetId;
43 protected String propertyName;
44 protected int propertyId;
45 protected final PropertyType propertyType;
46
47
48
49
50
51
52
53 public ExtendedFieldURI(int intPropertyTag, PropertyType propertyType) {
54 this.propertyTag = "0x" + Integer.toHexString(intPropertyTag);
55 this.propertyType = propertyType;
56 }
57
58
59
60
61
62
63
64
65 public ExtendedFieldURI(DistinguishedPropertySetType distinguishedPropertySetId, int propertyId, PropertyType propertyType) {
66 this.distinguishedPropertySetId = distinguishedPropertySetId;
67 this.propertyId = propertyId;
68 this.propertyType = propertyType;
69 }
70
71
72
73
74
75
76
77 public ExtendedFieldURI(DistinguishedPropertySetType distinguishedPropertySetId, String propertyName) {
78 this.distinguishedPropertySetId = distinguishedPropertySetId;
79 this.propertyName = propertyName;
80 this.propertyType = PropertyType.String;
81 }
82
83
84
85
86
87
88
89
90 public ExtendedFieldURI(DistinguishedPropertySetType distinguishedPropertySetId, String propertyName, PropertyType propertyType) {
91 this.distinguishedPropertySetId = distinguishedPropertySetId;
92 this.propertyName = propertyName;
93 this.propertyType = propertyType;
94 }
95
96 public void appendTo(StringBuilder buffer) {
97 buffer.append("<t:ExtendedFieldURI");
98 if (propertyTag != null) {
99 buffer.append(" PropertyTag=\"").append(propertyTag).append('"');
100 }
101 if (distinguishedPropertySetId != null) {
102 buffer.append(" DistinguishedPropertySetId=\"").append(distinguishedPropertySetId).append('"');
103 }
104 if (propertyName != null) {
105 buffer.append(" PropertyName=\"").append(propertyName).append('"');
106 }
107 if (propertyId != 0) {
108 buffer.append(" PropertyId=\"").append(propertyId).append('"');
109 }
110 if (propertyType != null) {
111 buffer.append(" PropertyType=\"").append(propertyType.toString()).append('"');
112 }
113 buffer.append("/>");
114 }
115
116 public void appendValue(StringBuilder buffer, String itemType, String value) {
117 if (itemType != null) {
118 appendTo(buffer);
119 buffer.append("<t:");
120 buffer.append(itemType);
121 buffer.append('>');
122 }
123 buffer.append("<t:ExtendedProperty>");
124 appendTo(buffer);
125 if (propertyType == PropertyType.StringArray) {
126 buffer.append("<t:Values>");
127 String[] values = value.split(",");
128 for (final String singleValue : values) {
129 buffer.append("<t:Value>");
130 buffer.append(StringUtil.xmlEncode(singleValue));
131 buffer.append("</t:Value>");
132
133 }
134 buffer.append("</t:Values>");
135 } else {
136 buffer.append("<t:Value>");
137 if ("0x10f3".equals(propertyTag)) {
138 buffer.append(StringUtil.xmlEncode(StringUtil.encodeUrlcompname(value)));
139 } else {
140 buffer.append(StringUtil.xmlEncode(value));
141 }
142 buffer.append("</t:Value>");
143 }
144 buffer.append("</t:ExtendedProperty>");
145 if (itemType != null) {
146 buffer.append("</t:");
147 buffer.append(itemType);
148 buffer.append('>');
149 }
150 }
151
152
153
154
155
156
157 public String getResponseName() {
158 if (propertyTag != null) {
159 return propertyTag;
160 } else if (propertyName != null) {
161 return propertyName;
162 } else {
163 return String.valueOf(propertyId);
164 }
165 }
166
167 }
168