james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r731090 - in /james/protocols/imap/trunk: mailbox/src/main/java/org/apache/james/imap/mailbox/util/ processor/src/main/java/org/apache/james/imap/processor/base/ processor/src/main/java/org/apache/james/imap/processor/imap4rev1/
Date Sat, 03 Jan 2009 21:13:12 GMT
Author: rdonkin
Date: Sat Jan  3 13:13:11 2009
New Revision: 731090

URL: http://svn.apache.org/viewvc?rev=731090&view=rev
Log:
Shorten name and convert to java 1.5

Added:
    james/protocols/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
  (contents, props changed)
      - copied, changed from r731079, james/protocols/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxSessionImpl.java
Removed:
    james/protocols/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxSessionImpl.java
Modified:
    james/protocols/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/UidToMsnConverter.java
    james/protocols/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/imap4rev1/AbstractSelectionProcessor.java

Modified: james/protocols/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/UidToMsnConverter.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/UidToMsnConverter.java?rev=731090&r1=731089&r2=731090&view=diff
==============================================================================
--- james/protocols/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/UidToMsnConverter.java
(original)
+++ james/protocols/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/util/UidToMsnConverter.java
Sat Jan  3 13:13:11 2009
@@ -22,37 +22,35 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.List;
 import java.util.SortedMap;
 import java.util.TreeMap;
-import java.util.TreeSet;
 
 import org.apache.james.imap.mailbox.MailboxListener;
 
 public class UidToMsnConverter implements MailboxListener {
-    protected SortedMap msnToUid;
+    private final SortedMap<Integer, Long> msnToUid;
 
-    protected SortedMap uidToMsn;
+    private final SortedMap<Long, Integer> uidToMsn;
 
-    protected long highestUid = 0;
+    private long highestUid = 0;
 
-    protected int highestMsn = 0;
+    private int highestMsn = 0;
 
-    public UidToMsnConverter(final Collection uids) {
-        msnToUid = new TreeMap();
-        uidToMsn = new TreeMap();
+    public UidToMsnConverter(final Collection<Long> uids) {
+        msnToUid = new TreeMap<Integer, Long>();
+        uidToMsn = new TreeMap<Long, Integer>();
         if (uids != null) {
             int msn = 1;
-            List uidsInOrder = new ArrayList(uids);
+            final List<Long> uidsInOrder = new ArrayList<Long>(uids);
             Collections.sort(uidsInOrder);
-            for (final Iterator it = uidsInOrder.iterator(); it.hasNext(); msn++) {
-                final Long uid = (Long) it.next();
+            for (final Long uid:uidsInOrder) {
                 highestUid = uid.longValue();
                 highestMsn = msn;
                 final Integer msnInteger = new Integer(msn);
                 msnToUid.put(msnInteger, uid);
                 uidToMsn.put(uid, msnInteger);
+                msn++;
             }
         }
     }
@@ -61,7 +59,7 @@
         if (msn == -1) {
             return -1;
         }
-        Long uid = (Long) msnToUid.get(new Integer(msn));
+        Long uid = msnToUid.get(new Integer(msn));
         if (uid != null) {
             return uid.longValue();
         } else {
@@ -83,7 +81,7 @@
 
     }
 
-    protected synchronized void add(int msn, long uid) {
+    private synchronized void add(int msn, long uid) {
         if (uid > highestUid) {
             highestUid = uid;
         }
@@ -93,61 +91,25 @@
         uidToMsn.put(uidLong, msnInteger);
     }
 
-    public synchronized void expunge(long uid) {
-        int msn = getMsn(uid);
+    public synchronized void expunge(final long uid) {
+        final int msn = getMsn(uid);
         remove(msn, uid);
-        List renumberMsns = new ArrayList(msnToUid
+        final List<Integer> renumberMsns = new ArrayList<Integer>(msnToUid
                 .tailMap(new Integer(msn + 1)).keySet());
-        for (Iterator iter = renumberMsns.iterator(); iter.hasNext();) {
-            int aMsn = ((Integer) iter.next()).intValue();
+        for (final Integer msnInteger: renumberMsns) {
+            int aMsn = msnInteger.intValue();
             long aUid = getUid(aMsn);
             remove(aMsn, aUid);
             add(aMsn - 1, aUid);
         }
         highestMsn--;
-        assertValidity();
     }
 
-    protected void remove(int msn, long uid) {
+    private void remove(int msn, long uid) {
         uidToMsn.remove(new Long(uid));
         msnToUid.remove(new Integer(msn));
     }
 
-    synchronized void assertValidity() {
-        Integer[] msns = (Integer[]) msnToUid.keySet().toArray(new Integer[0]);
-        for (int i = 0; i < msns.length; i++) {
-            if (msns[i].intValue() != (i + 1)) {
-                throw new AssertionError("Msn at position " + (i + 1) + " was "
-                        + msns[i].intValue());
-            }
-        }
-        if (msns.length > 0) {
-            if (msns[msns.length - 1].intValue() != highestMsn) {
-                throw new AssertionError("highestMsn " + highestMsn
-                        + " msns[msns.length-1] " + msns[msns.length - 1]);
-            }
-        } else {
-            if (highestMsn != 0) {
-                throw new AssertionError(
-                        "highestMsn in empty map has to be 0 but is"
-                                + highestMsn);
-            }
-        }
-        if (!msnToUid.keySet().equals(new TreeSet(uidToMsn.values()))) {
-            System.out.println(msnToUid.keySet());
-            System.out.println(uidToMsn.values());
-            throw new AssertionError(
-                    "msnToUid.keySet() does not equal uidToMsn.values()");
-        }
-        if (!uidToMsn.keySet().equals(new TreeSet(msnToUid.values()))) {
-            System.out.println(uidToMsn.keySet());
-            System.out.println(msnToUid.values());
-            throw new AssertionError(
-                    "uidToMsn.keySet() does not equal msnToUid.values()");
-        }
-
-    }
-
     public synchronized void add(long uid) {
         if (!uidToMsn.containsKey(new Long(uid))) {
             highestMsn++;
@@ -155,10 +117,6 @@
         }
     }
 
-    int size() {
-        return uidToMsn.size();
-    }
-
     /**
      * @see org.apache.james.imap.mailbox.MailboxListener#event(org.apache.james.imap.mailbox.MailboxListener.Event)
      */

Copied: james/protocols/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
(from r731079, james/protocols/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxSessionImpl.java)
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java?p2=james/protocols/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java&p1=james/protocols/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxSessionImpl.java&r1=731079&r2=731090&rev=731090&view=diff
==============================================================================
--- james/protocols/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxSessionImpl.java
(original)
+++ james/protocols/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
Sat Jan  3 13:13:11 2009
@@ -34,7 +34,7 @@
 import org.apache.james.imap.mailbox.util.UidToMsnConverter;
 
 // TODO: deal with deleted or renamed mailboxes
-public class SelectedMailboxSessionImpl extends AbstractLogEnabled implements
+public class SelectedMailboxImpl extends AbstractLogEnabled implements
         SelectedMailbox {
 
     private final Mailbox mailbox;
@@ -49,8 +49,8 @@
 
     private final String name;
 
-    public SelectedMailboxSessionImpl(Mailbox mailbox, List uids,
-            MailboxSession mailboxSession, final String name) throws MailboxException {
+    public SelectedMailboxImpl(final Mailbox mailbox, final List<Long> uids,
+            final MailboxSession mailboxSession, final String name) throws MailboxException
{
         this.mailbox = mailbox;
         recentUids = new TreeSet<Long>();
         recentUidRemoved = false;

Propchange: james/protocols/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: james/protocols/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/imap4rev1/AbstractSelectionProcessor.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/imap4rev1/AbstractSelectionProcessor.java?rev=731090&r1=731089&r2=731090&view=diff
==============================================================================
--- james/protocols/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/imap4rev1/AbstractSelectionProcessor.java
(original)
+++ james/protocols/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/imap4rev1/AbstractSelectionProcessor.java
Sat Jan  3 13:13:11 2009
@@ -48,7 +48,7 @@
 import org.apache.james.imap.message.response.imap4rev1.FlagsResponse;
 import org.apache.james.imap.message.response.imap4rev1.RecentResponse;
 import org.apache.james.imap.processor.base.ImapSessionUtils;
-import org.apache.james.imap.processor.base.SelectedMailboxSessionImpl;
+import org.apache.james.imap.processor.base.SelectedMailboxImpl;
 
 abstract class AbstractSelectionProcessor extends AbstractMailboxProcessor {
 
@@ -197,12 +197,12 @@
         final SelectedMailbox sessionMailbox;
         final Iterator it = mailbox.getMessages(MessageRangeImpl.all(),
                 FetchGroupImpl.MINIMAL, mailboxSession);
-        final List uids = new ArrayList();
+        final List<Long> uids = new ArrayList<Long>();
         while (it.hasNext()) {
             final MessageResult result = (MessageResult) it.next();
             uids.add(new Long(result.getUid()));
         }
-        sessionMailbox = new SelectedMailboxSessionImpl(mailbox, uids,
+        sessionMailbox = new SelectedMailboxImpl(mailbox, uids,
                 mailboxSession, name);
         session.selected(sessionMailbox);
         session.setAttribute(



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message