Convert an array of UIDSets into an IMAP sequence range. @param uidset the UIDSets @return the IMAP sequence string
(UIDSet[] uidset)
| 121 | * @return the IMAP sequence string |
| 122 | */ |
| 123 | public static String toString(UIDSet[] uidset) { |
| 124 | if (uidset == null) |
| 125 | return null; |
| 126 | if (uidset.length == 0) // Empty uidset |
| 127 | return ""; |
| 128 | |
| 129 | int i = 0; // uidset index |
| 130 | StringBuilder s = new StringBuilder(); |
| 131 | int size = uidset.length; |
| 132 | long start, end; |
| 133 | |
| 134 | for (;;) { |
| 135 | start = uidset[i].start; |
| 136 | end = uidset[i].end; |
| 137 | |
| 138 | if (end > start) |
| 139 | s.append(start).append(':').append(end); |
| 140 | else // end == start means only one element |
| 141 | s.append(start); |
| 142 | |
| 143 | i++; // Next UIDSet |
| 144 | if (i >= size) // No more UIDSets |
| 145 | break; |
| 146 | else |
| 147 | s.append(','); |
| 148 | } |
| 149 | return s.toString(); |
| 150 | } |
| 151 | |
| 152 | /** |
| 153 | * Convert an array of UIDSets into a array of long UIDs. |
no test coverage detected