1 package org.columba.mail.folder; 2 3 import org.columba.ristretto.message.MailboxInfo; 4 5 public class ColumbaMailboxInfo implements IMailboxInfo { 6 7 private MailboxInfo mailboxInfo; 8 9 public ColumbaMailboxInfo(MailboxInfo info) { 10 this.mailboxInfo = info; 11 } 12 13 public ColumbaMailboxInfo() { 14 this.mailboxInfo = new MailboxInfo(); 15 } 16 17 public int getExists() { 18 return mailboxInfo.getExists(); 19 } 20 21 public void setExists(int v) { 22 mailboxInfo.setExists(v); 23 24 } 25 26 public void incExists() throws MailboxInfoInvalidException { 27 mailboxInfo.setExists(mailboxInfo.getExists()+1); 28 sanityCheck(); 29 } 30 31 public void decExists() throws MailboxInfoInvalidException { 32 mailboxInfo.setExists(mailboxInfo.getExists()-1); 33 sanityCheck(); 34 } 35 36 public void setRecent(int v) { 37 mailboxInfo.setRecent(v); 38 } 39 40 public int getRecent() { 41 return mailboxInfo.getRecent(); 42 } 43 44 public void incRecent() throws MailboxInfoInvalidException { 45 mailboxInfo.setRecent(mailboxInfo.getRecent()+1); 46 sanityCheck(); 47 } 48 49 public void decRecent() throws MailboxInfoInvalidException { 50 mailboxInfo.setRecent(mailboxInfo.getRecent()-1); 51 sanityCheck(); 52 } 53 54 public void setUnseen(int v) { 55 mailboxInfo.setUnseen(v); 56 } 57 58 public int getUnseen() { 59 return mailboxInfo.getUnseen(); 60 } 61 62 public void incUnseen() throws MailboxInfoInvalidException { 63 mailboxInfo.setUnseen(mailboxInfo.getUnseen()+1); 64 sanityCheck(); 65 } 66 67 public void decUnseen() throws MailboxInfoInvalidException { 68 mailboxInfo.setUnseen(mailboxInfo.getUnseen()-1); 69 sanityCheck(); 70 } 71 72 public void reset() { 73 mailboxInfo.reset(); 74 } 75 76 public void setUidNext(int v) { 77 mailboxInfo.setUidNext(v); 78 } 79 80 public void setUidValidity(int v) { 81 mailboxInfo.setUidValidity(v); 82 } 83 84 public int getUidNext() { 85 return mailboxInfo.getUidNext(); 86 } 87 88 public int getUidValidity() { 89 return mailboxInfo.getUidValidity(); 90 } 91 92 private void sanityCheck() throws MailboxInfoInvalidException { 93 if( !isSane() ) throw new MailboxInfoInvalidException(); 94 } 95 96 public boolean isSane() { 97 if( mailboxInfo.getExists() < 0) return false; 99 100 if( mailboxInfo.getRecent() < 0) return false; 101 102 if( mailboxInfo.getRecent() > mailboxInfo.getExists()) return false; 103 104 if( mailboxInfo.getUnseen() < 0) return false; 105 106 if( mailboxInfo.getUnseen() > mailboxInfo.getExists()) return false; 107 108 return true; 109 } 110 111 112 113 } 114 | Popular Tags |