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

Method toMessageSetSorted

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

Sort (a copy of) the given array of messages and then run thru the sorted array of messages, apply the given Condition on each message and generate sets of contiguous sequence-numbers for the successful messages. If a message in the given array is found to be expunged, it is ignored. ASSERT: Since

(Message[] msgs,
							    Condition cond)

Source from the content-addressed store, hash-verified

120 * @since JavaMail 1.5.4
121 */
122 public static MessageSet[] toMessageSetSorted(Message[] msgs,
123 Condition cond) {
124 /*
125 * XXX - This is quick and dirty. A more efficient strategy would be
126 * to generate an array of message numbers by applying the condition
127 * (with zero indicating the message doesn't satisfy the condition),
128 * sort it, and then convert it to a MessageSet skipping all the zeroes.
129 */
130 msgs = msgs.clone();
131 Arrays.sort(msgs,
132 new Comparator<Message>() {
133 @Override
134 public int compare(Message msg1, Message msg2) {
135 return msg1.getMessageNumber() - msg2.getMessageNumber();
136 }
137 });
138 return toMessageSet(msgs, cond);
139 }
140
141 /**
142 * Return UIDSets for the messages. Note that the UIDs

Callers 5

setFlagsMethod · 0.95
setLabelsMethod · 0.95
fetchMethod · 0.95
setFlagsMethod · 0.95
searchMethod · 0.95

Calls 3

toMessageSetMethod · 0.95
cloneMethod · 0.45
sortMethod · 0.45

Tested by

no test coverage detected