private void readBatch() throws MailboxException { MessageRange range; switch (type) { default: case ALL: // In case of all, we start on cursor and don't specify a to range = MessageRange.from(cursor); break; case FROM: range = MessageRange.from(cursor); break; case ONE: range = MessageRange.one(cursor); break; case RANGE: range = MessageRange.range(cursor, to); break; } next = mapper.findInMailbox(mailbox, range, ftype, batchSize); if (!next.hasNext()) { done = true; } }