MCPcopy Create free account
hub / github.com/M66B/FairEmail / toUIDSet

Method toUIDSet

app/src/main/java/com/sun/mail/imap/Utility.java:148–191  ·  view source on GitHub ↗

Return UIDSets for the messages. Note that the UIDs must have already been fetched for the messages. @param msgs the messages @return the UIDSet array

(Message[] msgs)

Source from the content-addressed store, hash-verified

146 * @return the UIDSet array
147 */
148 public static UIDSet[] toUIDSet(Message[] msgs) {
149 List<UIDSet> v = new ArrayList<>(1);
150 long current, next;
151
152 IMAPMessage msg;
153 for (int i = 0; i < msgs.length; i++) {
154 msg = (IMAPMessage)msgs[i];
155 if (msg.isExpunged()) // expunged message, skip it
156 continue;
157
158 current = msg.getUID();
159
160 UIDSet set = new UIDSet();
161 set.start = current;
162
163 // Look for contiguous UIDs
164 for (++i; i < msgs.length; i++) {
165 // get next message
166 msg = (IMAPMessage)msgs[i];
167
168 if (msg.isExpunged()) // expunged message, skip it
169 continue;
170 next = msg.getUID();
171
172 if (next == current+1)
173 current = next;
174 else { // break in sequence
175 // We need to reexamine this message at the top of
176 // the outer loop, so decrement 'i' to cancel the
177 // outer loop's autoincrement
178 i--;
179 break;
180 }
181 }
182 set.end = current;
183 v.add(set);
184 }
185
186 if (v.isEmpty()) // No valid messages
187 return null;
188 else {
189 return v.toArray(new UIDSet[v.size()]);
190 }
191 }
192
193 /**
194 * Make the ResyncData UIDSet available to IMAPProtocol,

Callers 5

setFlagsMethod · 0.95
copyMessagesMethod · 0.95
setFlagsMethod · 0.95
copymoveMessagesMethod · 0.95
expungeMethod · 0.95

Calls 6

isExpungedMethod · 0.95
getUIDMethod · 0.95
toArrayMethod · 0.80
sizeMethod · 0.65
addMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected