private int randomUidValidity = new Random().nextInt();
public int uidValidity() { return randomUidValidity; }
+ public int maxuid() {
+ int ret = -1;
+ for(Mailbox.Iterator it = iterator(); it.next(); ) ret = Math.max(ret, it.uid());
+ return ret;
+ }
+
/** default, inefficient implementation of Mailbox; only requires a few methods to be implemented */
public static abstract class Default extends Mailbox {
public Mailbox.Iterator iterator(Query q) { return new Mailbox.Iterator.QueryIterator(q, this); }
public void copy(Query q, Mailbox dest) { for(Mailbox.Iterator it = iterator(q); it.next();) dest.insert(it.cur(), it.getFlags()); }
public int count(Query q) { int count = 0; for(Mailbox.Iterator it = iterator(q); it.next();) count++; return count; }
- public void rename(String newName) { throw new MailException("not supported"); }
- public void destroy(boolean recursive) { throw new MailException("not supported"); }
public MailTree slash(String name, boolean create) { return null; }
public String[] children() { return new String[] { }; }
public void post(Message message) { insert(message, Flag.RECENT); }
public static interface Iterator {
public abstract Message cur();
public abstract Headers head();
+
+ // FIXME: change all code to actually use this convention!
+ /** JDBC convention: iterator starts "before the first element" */
public abstract boolean next();
+
public abstract void delete();
/** a unique identifier for this message */
/**
* Message number according to IMAP semantics.
+ * - must range from 1..numMessagesInMailbox
* - no two messages in the same mailbox may have the same imapNumber
* - sorting by uid must yield the same order as sorting them by imapNumber
- * - imapNumber may only change if uidValidity changes
- * - if uidValidity changes, imapNumbers may change or be reused
+ * - imapNumber changes when messages with lower imapNumbers are deleted
*/
public abstract int imapNumber();