james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r731024 - in /james/protocols/imap/trunk: api/src/main/java/org/apache/james/api/imap/message/request/ api/src/main/java/org/apache/james/api/imap/process/ jpa/src/main/java/org/apache/james/imap/jpa/ mailbox/src/main/java/org/apache/james/...
Date Sat, 03 Jan 2009 17:01:00 GMT
Author: rdonkin
Date: Sat Jan  3 09:00:59 2009
New Revision: 731024

URL: http://svn.apache.org/viewvc?rev=731024&view=rev
Log:
Switch to Java 1.5

Modified:
    james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/request/SearchKey.java
    james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/process/SelectedImapMailbox.java
    james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/MessageSearches.java
    james/protocols/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/SearchQuery.java
    james/protocols/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxSessionImpl.java
    james/protocols/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/imap4rev1/SearchProcessor.java
    james/protocols/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/imap4rev1/SearchProcessorTest.java
    james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/MessageSearches.java

Modified: james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/request/SearchKey.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/request/SearchKey.java?rev=731024&r1=731023&r2=731024&view=diff
==============================================================================
--- james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/request/SearchKey.java
(original)
+++ james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/message/request/SearchKey.java
Sat Jan  3 09:00:59 2009
@@ -299,14 +299,14 @@
 
     // NOT
     public static SearchKey buildNot(SearchKey key) {
-        final List keys = new ArrayList();
+        final List<SearchKey> keys = new ArrayList<SearchKey>();
         keys.add(key);
         return new SearchKey(TYPE_NOT, null, keys, 0, null, null, null);
     }
 
     // OR
     public static SearchKey buildOr(SearchKey keyOne, SearchKey keyTwo) {
-        final List keys = new ArrayList();
+        final List<SearchKey> keys = new ArrayList<SearchKey>();
         keys.add(keyOne);
         keys.add(keyTwo);
         return new SearchKey(TYPE_OR, null, keys, 0, null, null, null);
@@ -319,7 +319,7 @@
      *            <code>List</code> of {@link SearchKey}'s composing this key
      * @return <code>SearchKey</code>, not null
      */
-    public static SearchKey buildAnd(final List keys) {
+    public static SearchKey buildAnd(final List<SearchKey> keys) {
         return new SearchKey(TYPE_AND, null, keys, 0, null, null, null);
     }
 
@@ -327,7 +327,7 @@
 
     private final DayMonthYear date;
 
-    private final List keys;
+    private final List<SearchKey> keys;
 
     private final long size;
 
@@ -337,7 +337,7 @@
 
     private IdRange[] sequence;
 
-    private SearchKey(final int type, final DayMonthYear date, final List keys,
+    private SearchKey(final int type, final DayMonthYear date, final List<SearchKey>
keys,
             final long number, final String name, final String value,
             IdRange[] sequence) {
         super();
@@ -397,7 +397,7 @@
      *         {@link #TYPE_OR}, {@link #TYPE_AND} or {@link #TYPE_NOT}
      *         otherwise null
      */
-    public final List getKeys() {
+    public final List<SearchKey> getKeys() {
         return keys;
     }
 

Modified: james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/process/SelectedImapMailbox.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/process/SelectedImapMailbox.java?rev=731024&r1=731023&r2=731024&view=diff
==============================================================================
--- james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/process/SelectedImapMailbox.java
(original)
+++ james/protocols/imap/trunk/api/src/main/java/org/apache/james/api/imap/process/SelectedImapMailbox.java
Sat Jan  3 09:00:59 2009
@@ -34,7 +34,7 @@
 
     public boolean removeRecent(long uid);
 
-    public long[] getRecent();
+    public Collection<Long> getRecent();
 
     public int recentCount();
 

Modified: james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/MessageSearches.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/MessageSearches.java?rev=731024&r1=731023&r2=731024&view=diff
==============================================================================
--- james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/MessageSearches.java
(original)
+++ james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/MessageSearches.java
Sat Jan  3 09:00:59 2009
@@ -136,11 +136,10 @@
             final SearchQuery.ContainsOperator operator = criterion
                     .getOperator();
             final String value = operator.getValue();
-            final int type = criterion.getType();
-            switch (type) {
-                case SearchQuery.TextCriterion.BODY:
+            switch (criterion.getType()) {
+                case BODY:
                     return bodyContains(value, message);
-                case SearchQuery.TextCriterion.FULL_MESSAGE:
+                case FULL:
                     return messageContains(value, message);
                 default:
                     throw new UnsupportedSearchException();
@@ -177,14 +176,13 @@
 
     private boolean matches(SearchQuery.ConjunctionCriterion criterion,
             Message message, final Collection recentMessageUids) throws MailboxException
{
-        final int type = criterion.getType();
         final List criteria = criterion.getCriteria();
-        switch (type) {
-            case SearchQuery.ConjunctionCriterion.NOR:
+        switch (criterion.getType()) {
+            case NOR:
                 return nor(criteria, message, recentMessageUids);
-            case SearchQuery.ConjunctionCriterion.OR:
+            case OR:
                 return or(criteria, message, recentMessageUids);
-            case SearchQuery.ConjunctionCriterion.AND:
+            case AND:
                 return and(criteria, message, recentMessageUids);
             default:
                 return false;
@@ -338,13 +336,13 @@
         } else {
             try {
                 final int isoFieldValue = toISODate(value);
-                final int type = operator.getType();
+                final SearchQuery.DateComparator type = operator.getType();
                 switch (type) {
-                    case SearchQuery.DateOperator.AFTER:
+                    case AFTER:
                         return iso < isoFieldValue;
-                    case SearchQuery.DateOperator.BEFORE:
+                    case BEFORE:
                         return iso > isoFieldValue;
-                    case SearchQuery.DateOperator.ON:
+                    case ON:
                         return iso == isoFieldValue;
                     default:
                         throw new UnsupportedSearchException();
@@ -381,13 +379,12 @@
         final SearchQuery.NumericOperator operator = criterion.getOperator();
         final int size = message.getSize();
         final long value = operator.getValue();
-        final int type = operator.getType();
-        switch (type) {
-            case SearchQuery.NumericOperator.LESS_THAN:
+        switch (operator.getType()) {
+            case LESS_THAN:
                 return size < value;
-            case SearchQuery.NumericOperator.GREATER_THAN:
+            case GREATER_THAN:
                 return size > value;
-            case SearchQuery.NumericOperator.EQUALS:
+            case EQUALS:
                 return size == value;
             default:
                 throw new UnsupportedSearchException();
@@ -408,13 +405,13 @@
         final int month = operator.getMonth();
         final int year = operator.getYear();
         final Date internalDate = message.getInternalDate();
-        final int type = operator.getType();
+        final SearchQuery.DateComparator type = operator.getType();
         switch (type) {
-            case SearchQuery.DateOperator.ON:
+            case ON:
                 return on(day, month, year, internalDate);
-            case SearchQuery.DateOperator.BEFORE:
+            case BEFORE:
                 return before(day, month, year, internalDate);
-            case SearchQuery.DateOperator.AFTER:
+            case AFTER:
                 return after(day, month, year, internalDate);
             default:
                 throw new UnsupportedSearchException();

Modified: james/protocols/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/SearchQuery.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/SearchQuery.java?rev=731024&r1=731023&r2=731024&view=diff
==============================================================================
--- james/protocols/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/SearchQuery.java
(original)
+++ james/protocols/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/SearchQuery.java
Sat Jan  3 09:00:59 2009
@@ -21,6 +21,7 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -50,8 +51,7 @@
      * @return <code>Criterion</code>, not null
      */
     public static final Criterion sizeLessThan(long value) {
-        return new SizeCriterion(new NumericOperator(value,
-                NumericOperator.LESS_THAN));
+        return new SizeCriterion(new NumericOperator(value, NumericComparator.LESS_THAN));
     }
 
     /**
@@ -63,8 +63,7 @@
      * @return <code>Criterion</code>, not null
      */
     public static final Criterion sizeGreaterThan(long value) {
-        return new SizeCriterion(new NumericOperator(value,
-                NumericOperator.GREATER_THAN));
+        return new SizeCriterion(new NumericOperator(value, NumericComparator.GREATER_THAN));
     }
 
     /**
@@ -76,8 +75,7 @@
      * @return <code>Criterion</code>, not null
      */
     public static final Criterion sizeEquals(long value) {
-        return new SizeCriterion(new NumericOperator(value,
-                NumericOperator.EQUALS));
+        return new SizeCriterion(new NumericOperator(value, NumericComparator.EQUALS));
     }
 
     /**
@@ -93,7 +91,7 @@
      * @return <code>Criterion</code>, not null
      */
     public static final Criterion internalDateAfter(int day, int month, int year) {
-        return new InternalDateCriterion(new DateOperator(DateOperator.AFTER,
+        return new InternalDateCriterion(new DateOperator(DateComparator.AFTER,
                 day, month, year));
     }
 
@@ -109,7 +107,7 @@
      * @return <code>Criterion</code>, not null
      */
     public static final Criterion internalDateOn(int day, int month, int year) {
-        return new InternalDateCriterion(new DateOperator(DateOperator.ON, day,
+        return new InternalDateCriterion(new DateOperator(DateComparator.ON, day,
                 month, year));
     }
 
@@ -127,7 +125,7 @@
      */
     public static final Criterion internalDateBefore(int day, int month,
             int year) {
-        return new InternalDateCriterion(new DateOperator(DateOperator.BEFORE,
+        return new InternalDateCriterion(new DateOperator(DateComparator.BEFORE,
                 day, month, year));
     }
 
@@ -149,7 +147,7 @@
     public static final Criterion headerDateAfter(String headerName, int day,
             int month, int year) {
         return new HeaderCriterion(headerName, new DateOperator(
-                DateOperator.AFTER, day, month, year));
+                DateComparator.AFTER, day, month, year));
     }
 
     /**
@@ -170,7 +168,7 @@
     public static final Criterion headerDateOn(String headerName, int day,
             int month, int year) {
         return new HeaderCriterion(headerName, new DateOperator(
-                DateOperator.ON, day, month, year));
+                DateComparator.ON, day, month, year));
     }
 
     /**
@@ -191,7 +189,7 @@
     public static final Criterion headerDateBefore(String headerName, int day,
             int month, int year) {
         return new HeaderCriterion(headerName, new DateOperator(
-                DateOperator.BEFORE, day, month, year));
+                DateComparator.BEFORE, day, month, year));
     }
 
     /**
@@ -234,7 +232,7 @@
      * @return <code>Criterion</code>, not null
      */
     public static final Criterion mailContains(String value) {
-        return new TextCriterion(value, TextCriterion.FULL_MESSAGE);
+        return new TextCriterion(value, Scope.FULL);
     }
 
     /**
@@ -247,7 +245,7 @@
      * @return <code>Criterion</code>, not null
      */
     public static final Criterion bodyContains(String value) {
-        return new TextCriterion(value, TextCriterion.BODY);
+        return new TextCriterion(value, Scope.BODY);
     }
 
     /**
@@ -271,10 +269,10 @@
      * @return <code>Criterion</code>, not null
      */
     public static final Criterion or(Criterion one, Criterion two) {
-        final List criteria = new ArrayList();
+        final List<Criterion> criteria = new ArrayList<Criterion>();
         criteria.add(one);
         criteria.add(two);
-        return new ConjunctionCriterion(ConjunctionCriterion.OR, criteria);
+        return new ConjunctionCriterion(Conjunction.OR, criteria);
     }
 
     /**
@@ -287,10 +285,10 @@
      * @return <code>Criterion</code>, not null
      */
     public static final Criterion and(Criterion one, Criterion two) {
-        final List criteria = new ArrayList();
+        final List<Criterion> criteria = new ArrayList<Criterion>();
         criteria.add(one);
         criteria.add(two);
-        return new ConjunctionCriterion(ConjunctionCriterion.AND, criteria);
+        return new ConjunctionCriterion(Conjunction.AND, criteria);
     }
 
     /**
@@ -300,8 +298,8 @@
      *            <code>List</code> of {@link Criterion}
      * @return <code>Criterion</code>, not null
      */
-    public static final Criterion and(List criteria) {
-        return new ConjunctionCriterion(ConjunctionCriterion.AND, criteria);
+    public static final Criterion and(List<Criterion> criteria) {
+        return new ConjunctionCriterion(Conjunction.AND, criteria);
     }
 
     /**
@@ -312,9 +310,9 @@
      * @return <code>Criterion</code>, not null
      */
     public static final Criterion not(Criterion criterion) {
-        final List criteria = new ArrayList();
+        final List<Criterion> criteria = new ArrayList<Criterion>();
         criteria.add(criterion);
-        return new ConjunctionCriterion(ConjunctionCriterion.NOR, criteria);
+        return new ConjunctionCriterion(Conjunction.NOR, criteria);
     }
 
     /**
@@ -414,7 +412,7 @@
         return AllCriterion.all();
     }
 
-    private final Set recentMessageUids = new HashSet();
+    private final Set<Long> recentMessageUids = new HashSet<Long>();
 
     private final List<Criterion> criterias = new ArrayList<Criterion>();
 
@@ -433,9 +431,17 @@
      * 
      * @return mutable <code>Set</code> of <code>Long</code> UIDS
      */
-    public Set getRecentMessageUids() {
+    public Set<Long> getRecentMessageUids() {
         return recentMessageUids;
     }
+    
+    /**
+     * Adds all the uids to the collection of recents.
+     * @param uids not null
+     */
+    public void addRecentMessageUids(final Collection<Long> uids) {
+        recentMessageUids.addAll(uids);
+    }
 
     @Override
     public String toString() {
@@ -521,7 +527,7 @@
         /**
          * @see java.lang.Object#hashCode()
          */
-        // @Override
+        @Override
         public int hashCode() {
             final int PRIME = 31;
             int result = 1;
@@ -533,7 +539,7 @@
         /**
          * @see java.lang.Object#equals(java.lang.Object)
          */
-        // @Override
+        @Override
         public boolean equals(Object obj) {
             if (this == obj)
                 return true;
@@ -568,25 +574,20 @@
     public static abstract class Criterion {
     }
 
+    public enum Conjunction {
+        AND, OR, NOR
+    }
+    
     /**
      * Conjuction applying to the contained criteria. {@link #getType} indicates
      * how the conjoined criteria should be related.
      */
     public static final class ConjunctionCriterion extends Criterion {
-        /** Logical <code>AND</code> */
-        public static final int AND = 1;
+        private final Conjunction type;
 
-        /** Logical <code>OR</code> */
-        public static final int OR = 2;
+        private final List<Criterion> criteria;
 
-        /** Logical <code>NOT</code> */
-        public static final int NOR = 3;
-
-        private final int type;
-
-        private final List criteria;
-
-        public ConjunctionCriterion(final int type, final List criteria) {
+        public ConjunctionCriterion(final Conjunction type, final List<Criterion> criteria)
{
             super();
             this.type = type;
             this.criteria = criteria;
@@ -597,36 +598,35 @@
          * 
          * @return <code>List</code> of {@link Criterion}
          */
-        public final List getCriteria() {
+        public final List<Criterion> getCriteria() {
             return criteria;
         }
 
         /**
          * Gets the type of conjunction.
          * 
-         * @return the type, either {@link #AND}, {@link #OR} or {@link NOR}
+         * @return not null
          */
-        public final int getType() {
+        public final Conjunction getType() {
             return type;
         }
 
         /**
          * @see java.lang.Object#hashCode()
          */
-        // @Override
+        @Override
         public int hashCode() {
             final int PRIME = 31;
             int result = 1;
             result = PRIME * result
                     + ((criteria == null) ? 0 : criteria.hashCode());
-            result = PRIME * result + type;
             return result;
         }
 
         /**
          * @see java.lang.Object#equals(java.lang.Object)
          */
-        // @Override
+        @Override
         public boolean equals(Object obj) {
             if (this == obj)
                 return true;
@@ -678,7 +678,7 @@
         /**
          * @see java.lang.Object#equals(java.lang.Object)
          */
-        // @Override
+        @Override
         public boolean equals(Object obj) {
             return obj instanceof AllCriterion;
         }
@@ -686,7 +686,7 @@
         /**
          * @see java.lang.Object#hashCode()
          */
-        // @Override
+        @Override
         public int hashCode() {
             return 1729;
         }
@@ -696,25 +696,24 @@
         }
     }
 
+    public enum Scope {
+        /** Only message body content */        
+        BODY,
+
+        /** Full message content including headers */
+        FULL
+    }
+    
     /**
      * Message text.
      */
     public static final class TextCriterion extends Criterion {
-        /**
-         * Only the message body content.
-         */
-        public static final int BODY = 1;
-
-        /**
-         * The full message content including headers.
-         */
-        public static final int FULL_MESSAGE = 2;
 
-        private final int type;
+        private final Scope type;
 
         private final ContainsOperator operator;
 
-        private TextCriterion(final String value, final int type) {
+        private TextCriterion(final String value, final Scope type) {
             super();
             this.operator = new ContainsOperator(value);
             this.type = type;
@@ -723,9 +722,9 @@
         /**
          * Gets the type of text to be searched.
          * 
-         * @return the type, either {@link #BODY} or {@link #FULL_MESSAGE}
+         * @return not null
          */
-        public final int getType() {
+        public final Scope getType() {
             return type;
         }
 
@@ -741,20 +740,19 @@
         /**
          * @see java.lang.Object#hashCode()
          */
-        // @Override
+        @Override
         public int hashCode() {
             final int PRIME = 31;
             int result = 1;
             result = PRIME * result
                     + ((operator == null) ? 0 : operator.hashCode());
-            result = PRIME * result + type;
             return result;
         }
 
         /**
          * @see java.lang.Object#equals(java.lang.Object)
          */
-        // @Override
+        @Override
         public boolean equals(Object obj) {
             if (this == obj)
                 return true;
@@ -828,7 +826,7 @@
         /**
          * @see java.lang.Object#hashCode()
          */
-        // @Override
+        @Override
         public int hashCode() {
             final int PRIME = 31;
             int result = 1;
@@ -842,7 +840,7 @@
         /**
          * @see java.lang.Object#equals(java.lang.Object)
          */
-        // @Override
+        @Override
         public boolean equals(Object obj) {
             if (this == obj)
                 return true;
@@ -907,7 +905,7 @@
         /**
          * @see java.lang.Object#hashCode()
          */
-        // @Override
+        @Override
         public int hashCode() {
             final int PRIME = 31;
             int result = 1;
@@ -919,7 +917,7 @@
         /**
          * @see java.lang.Object#equals(java.lang.Object)
          */
-        // @Override
+        @Override
         public boolean equals(Object obj) {
             if (this == obj)
                 return true;
@@ -977,7 +975,7 @@
         /**
          * @see java.lang.Object#hashCode()
          */
-        // @Override
+        @Override
         public int hashCode() {
             final int PRIME = 31;
             int result = 1;
@@ -989,7 +987,7 @@
         /**
          * @see java.lang.Object#equals(java.lang.Object)
          */
-        // @Override
+        @Override
         public boolean equals(Object obj) {
             if (this == obj)
                 return true;
@@ -1060,7 +1058,7 @@
         /**
          * @see java.lang.Object#hashCode()
          */
-        // @Override
+        @Override
         public int hashCode() {
             final int PRIME = 31;
             int result = 1;
@@ -1073,7 +1071,7 @@
         /**
          * @see java.lang.Object#equals(java.lang.Object)
          */
-        // @Override
+        @Override
         public boolean equals(Object obj) {
             if (this == obj)
                 return true;
@@ -1149,7 +1147,7 @@
         /**
          * @see java.lang.Object#hashCode()
          */
-        // @Override
+        @Override
         public int hashCode() {
             final int PRIME = 31;
             int result = 1;
@@ -1162,7 +1160,7 @@
         /**
          * @see java.lang.Object#equals(java.lang.Object)
          */
-        // @Override
+        @Override
         public boolean equals(Object obj) {
             if (this == obj)
                 return true;
@@ -1227,7 +1225,7 @@
         /**
          * @see java.lang.Object#hashCode()
          */
-        // @Override
+        @Override
         public int hashCode() {
             final int PRIME = 31;
             int result = 1;
@@ -1239,7 +1237,7 @@
         /**
          * @see java.lang.Object#equals(java.lang.Object)
          */
-        // @Override
+        @Override
         public boolean equals(Object obj) {
             if (this == obj)
                 return true;
@@ -1310,7 +1308,7 @@
         /**
          * @see java.lang.Object#hashCode()
          */
-        // @Override
+        @Override
         public int hashCode() {
             final int PRIME = 31;
             int result = 1;
@@ -1321,7 +1319,7 @@
         /**
          * @see java.lang.Object#equals(java.lang.Object)
          */
-        // @Override
+        @Override
         public boolean equals(Object obj) {
             if (this == obj)
                 return true;
@@ -1369,7 +1367,7 @@
         /**
          * @see java.lang.Object#equals(java.lang.Object)
          */
-        // @Override
+        @Override
         public boolean equals(Object obj) {
             return obj instanceof ExistsOperator;
         }
@@ -1377,7 +1375,7 @@
         /**
          * @see java.lang.Object#hashCode()
          */
-        // @Override
+        @Override
         public int hashCode() {
             return 42;
         }
@@ -1385,7 +1383,7 @@
         /**
          * @see java.lang.Object#toString()
          */
-        // @Override
+        @Override
         public String toString() {
             return "ExistsCriterion";
         }
@@ -1429,7 +1427,7 @@
         /**
          * @see java.lang.Object#hashCode()
          */
-        // @Override
+        @Override
         public int hashCode() {
             final int PRIME = 31;
             int result = 1;
@@ -1440,7 +1438,7 @@
         /**
          * @see java.lang.Object#equals(java.lang.Object)
          */
-        // @Override
+        @Override
         public boolean equals(Object obj) {
             if (this == obj)
                 return true;
@@ -1473,6 +1471,10 @@
 
     }
 
+    public enum NumericComparator {
+        EQUALS, LESS_THAN, GREATER_THAN
+    }
+    
     /**
      * Searches numberic values.
      */
@@ -1485,9 +1487,9 @@
 
         private final long value;
 
-        private final int type;
+        private final NumericComparator type;
 
-        private NumericOperator(final long value, final int type) {
+        private NumericOperator(final long value, final NumericComparator type) {
             super();
             this.value = value;
             this.type = type;
@@ -1496,10 +1498,9 @@
         /**
          * Gets the operation type
          * 
-         * @return the type either {@link #EQUALS}, {@link #LESS_THAN} or
-         *         {@link #GREATER_THAN}
+         * @return not null
          */
-        public final int getType() {
+        public final NumericComparator getType() {
             return type;
         }
 
@@ -1515,11 +1516,10 @@
         /**
          * @see java.lang.Object#hashCode()
          */
-        // @Override
+        @Override
         public int hashCode() {
             final int PRIME = 31;
             int result = 1;
-            result = PRIME * result + type;
             result = PRIME * result + (int) (value ^ (value >>> 32));
             return result;
         }
@@ -1527,7 +1527,7 @@
         /**
          * @see java.lang.Object#equals(java.lang.Object)
          */
-        // @Override
+        @Override
         public boolean equals(Object obj) {
             if (this == obj)
                 return true;
@@ -1562,6 +1562,10 @@
         }
     }
 
+    public enum DateComparator {
+        BEFORE, AFTER, ON
+    }
+    
     /**
      * Operates on a date.
      */
@@ -1572,7 +1576,7 @@
 
         public static final int ON = 3;
 
-        private final int type;
+        private final DateComparator type;
 
         private final int day;
 
@@ -1580,7 +1584,7 @@
 
         private final int year;
 
-        public DateOperator(final int type, final int day, final int month,
+        public DateOperator(final DateComparator type, final int day, final int month,
                 final int year) {
             super();
             this.type = type;
@@ -1613,7 +1617,7 @@
          * @return the type, either {@link #BEFORE}, {@link #AFTER} or
          *         {@link ON}
          */
-        public final int getType() {
+        public final DateComparator getType() {
             return type;
         }
 
@@ -1629,13 +1633,12 @@
         /**
          * @see java.lang.Object#hashCode()
          */
-        // @Override
+        @Override
         public int hashCode() {
             final int PRIME = 31;
             int result = 1;
             result = PRIME * result + day;
             result = PRIME * result + month;
-            result = PRIME * result + type;
             result = PRIME * result + year;
             return result;
         }
@@ -1643,7 +1646,7 @@
         /**
          * @see java.lang.Object#equals(java.lang.Object)
          */
-        // @Override
+        @Override
         public boolean equals(Object obj) {
             if (this == obj)
                 return true;
@@ -1709,7 +1712,7 @@
         /**
          * @see java.lang.Object#hashCode()
          */
-        // @Override
+        @Override
         public int hashCode() {
             return range.length;
         }
@@ -1717,7 +1720,7 @@
         /**
          * @see java.lang.Object#equals(java.lang.Object)
          */
-        // @Override
+        @Override
         public boolean equals(Object obj) {
             if (this == obj)
                 return true;

Modified: 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/SelectedMailboxSessionImpl.java?rev=731024&r1=731023&r2=731024&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/SelectedMailboxSessionImpl.java
Sat Jan  3 09:00:59 2009
@@ -19,6 +19,7 @@
 
 package org.apache.james.imap.processor.base;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.Set;
@@ -105,14 +106,9 @@
         return result;
     }
 
-    public long[] getRecent() {
+    public Collection<Long> getRecent() {
         checkExpungedRecents();
-        final long[] results = new long[recentUids.size()];
-        int count = 0;
-        for (final Long uid: recentUids) {
-            results[count++] = uid.longValue();
-        }
-        return results;
+        return new ArrayList<Long>(recentUids);
     }
 
     public int recentCount() {

Modified: james/protocols/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/imap4rev1/SearchProcessor.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/imap4rev1/SearchProcessor.java?rev=731024&r1=731023&r2=731024&view=diff
==============================================================================
--- james/protocols/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/imap4rev1/SearchProcessor.java
(original)
+++ james/protocols/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/imap4rev1/SearchProcessor.java
Sat Jan  3 09:00:59 2009
@@ -104,7 +104,7 @@
         final Iterator it = mailbox.search(query, fetchGroup, ImapSessionUtils
                 .getMailboxSession(session));
 
-        final Collection results = new TreeSet();
+        final Collection<Long> results = new TreeSet<Long>();
         while (it.hasNext()) {
             final MessageResult result = (MessageResult) it.next();
             final Long number;
@@ -123,11 +123,7 @@
         final SearchQuery result = new SearchQuery();
         final SelectedImapMailbox selected = session.getSelected();
         if (selected != null) {
-            final long[] recent = selected.getRecent();
-            for (int i = 0; i < recent.length; i++) {
-                long uid = recent[i];
-                result.getRecentMessageUids().add(new Long(uid));
-            }
+            result.addRecentMessageUids(selected.getRecent());
         }
         final SearchQuery.Criterion criterion = toCriterion(key, session);
         result.andCriteria(criterion);
@@ -265,27 +261,26 @@
         return SearchQuery.uid(ranges);
     }
 
-    private Criterion or(List keys, final ImapSession session) {
-        final SearchKey keyOne = (SearchKey) keys.get(0);
-        final SearchKey keyTwo = (SearchKey) keys.get(1);
+    private Criterion or(List<SearchKey> keys, final ImapSession session) {
+        final SearchKey keyOne = keys.get(0);
+        final SearchKey keyTwo = keys.get(1);
         final Criterion criterionOne = toCriterion(keyOne, session);
         final Criterion criterionTwo = toCriterion(keyTwo, session);
         final Criterion result = SearchQuery.or(criterionOne, criterionTwo);
         return result;
     }
 
-    private Criterion not(List keys, final ImapSession session) {
-        final SearchKey key = (SearchKey) keys.get(0);
+    private Criterion not(List<SearchKey> keys, final ImapSession session) {
+        final SearchKey key = keys.get(0);
         final Criterion criterion = toCriterion(key, session);
         final Criterion result = SearchQuery.not(criterion);
         return result;
     }
 
-    private Criterion and(List keys, final ImapSession session) {
+    private Criterion and(List<SearchKey> keys, final ImapSession session) {
         final int size = keys.size();
-        final List criteria = new ArrayList(size);
-        for (Iterator iter = keys.iterator(); iter.hasNext();) {
-            final SearchKey key = (SearchKey) iter.next();
+        final List<Criterion> criteria = new ArrayList<Criterion>(size);
+        for (final SearchKey key:keys) {
             final Criterion criterion = toCriterion(key, session);
             criteria.add(criterion);
         }

Modified: james/protocols/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/imap4rev1/SearchProcessorTest.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/imap4rev1/SearchProcessorTest.java?rev=731024&r1=731023&r2=731024&view=diff
==============================================================================
--- james/protocols/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/imap4rev1/SearchProcessorTest.java
(original)
+++ james/protocols/imap/trunk/processor/src/test/java/org/apache/james/imap/processor/imap4rev1/SearchProcessorTest.java
Sat Jan  3 09:00:59 2009
@@ -42,6 +42,7 @@
 import org.apache.james.imap.mailbox.MailboxManagerProvider;
 import org.apache.james.imap.mailbox.MailboxSession;
 import org.apache.james.imap.mailbox.SearchQuery;
+import org.apache.james.imap.mailbox.SearchQuery.Criterion;
 import org.apache.james.imap.mailbox.util.FetchGroupImpl;
 import org.apache.james.imap.message.request.imap4rev1.SearchRequest;
 import org.apache.james.imap.message.response.imap4rev1.server.SearchResponse;
@@ -145,7 +146,7 @@
         session.expects(atLeastOnce()).method("getSelected").will(
                 returnValue(selectedMailbox.proxy()));
         selectedMailbox.expects(once()).method("getRecent").will(
-                returnValue(EMPTY));
+                returnValue(new ArrayList<Long>()));
         check(SearchKey.buildSequenceSet(ids), SearchQuery.uid(ranges));
     }
 
@@ -177,7 +178,7 @@
         session.expects(atLeastOnce()).method("getSelected").will(
                 returnValue(selectedMailbox.proxy()));
         selectedMailbox.expects(once()).method("getRecent").will(
-                returnValue(EMPTY));
+                returnValue(new ArrayList<Long>()));
         check(SearchKey.buildSequenceSet(ids), SearchQuery.uid(ranges));
     }
 
@@ -191,7 +192,7 @@
         selectedMailbox.expects(once()).method("uid").with(eq(5)).will(
                 returnValue(1729L));
         selectedMailbox.expects(once()).method("getRecent").will(
-                returnValue(EMPTY));
+                returnValue(new ArrayList<Long>()));
         allowUnsolicitedResponses(selectedMailbox);
         session.expects(atLeastOnce()).method("getSelected").will(
                 returnValue(selectedMailbox.proxy()));
@@ -206,7 +207,7 @@
         selectedMailbox.expects(exactly(2)).method("uid").with(eq(1)).will(
                 returnValue(42L));
         selectedMailbox.expects(once()).method("getRecent").will(
-                returnValue(EMPTY));
+                returnValue(new ArrayList<Long>()));
         allowUnsolicitedResponses(selectedMailbox);
         session.expects(atLeastOnce()).method("getSelected").will(
                 returnValue(selectedMailbox.proxy()));
@@ -309,11 +310,11 @@
 
     public void testAND() throws Exception {
         session.expects(atLeastOnce()).method("getSelected").will(returnValue(null));
-        List keys = new ArrayList();
+        List<SearchKey> keys = new ArrayList<SearchKey>();
         keys.add(SearchKey.buildOn(DAY_MONTH_YEAR));
         keys.add(SearchKey.buildOld());
         keys.add(SearchKey.buildLarger(SIZE));
-        List criteria = new ArrayList();
+        List<Criterion> criteria = new ArrayList<Criterion>();
         criteria.add(SearchQuery.internalDateOn(DAY, MONTH, YEAR));
         criteria.add(SearchQuery.flagIsUnSet(Flag.RECENT));
         criteria.add(SearchQuery.sizeGreaterThan(SIZE));

Modified: james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/MessageSearches.java
URL: http://svn.apache.org/viewvc/james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/MessageSearches.java?rev=731024&r1=731023&r2=731024&view=diff
==============================================================================
--- james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/MessageSearches.java
(original)
+++ james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/MessageSearches.java
Sat Jan  3 09:00:59 2009
@@ -137,11 +137,10 @@
             final SearchQuery.ContainsOperator operator = criterion
                     .getOperator();
             final String value = operator.getValue();
-            final int type = criterion.getType();
-            switch (type) {
-                case SearchQuery.TextCriterion.BODY:
+            switch (criterion.getType()) {
+                case BODY:
                     return bodyContains(value, row);
-                case SearchQuery.TextCriterion.FULL_MESSAGE:
+                case FULL:
                     return messageContains(value, row);
                 default:
                     throw new UnsupportedSearchException();
@@ -179,14 +178,13 @@
     private boolean matches(SearchQuery.ConjunctionCriterion criterion,
             MessageRow row, final Collection recentMessageUids)
             throws TorqueException {
-        final int type = criterion.getType();
         final List criteria = criterion.getCriteria();
-        switch (type) {
-            case SearchQuery.ConjunctionCriterion.NOR:
+        switch (criterion.getType()) {
+            case NOR:
                 return nor(criteria, row, recentMessageUids);
-            case SearchQuery.ConjunctionCriterion.OR:
+            case OR:
                 return or(criteria, row, recentMessageUids);
-            case SearchQuery.ConjunctionCriterion.AND:
+            case AND:
                 return and(criteria, row, recentMessageUids);
             default:
                 return false;
@@ -351,13 +349,12 @@
         } else {
             try {
                 final int isoFieldValue = toISODate(value);
-                final int type = operator.getType();
-                switch (type) {
-                    case SearchQuery.DateOperator.AFTER:
+                switch (operator.getType()) {
+                    case AFTER:
                         return iso < isoFieldValue;
-                    case SearchQuery.DateOperator.BEFORE:
+                    case BEFORE:
                         return iso > isoFieldValue;
-                    case SearchQuery.DateOperator.ON:
+                    case ON:
                         return iso == isoFieldValue;
                     default:
                         throw new UnsupportedSearchException();
@@ -396,13 +393,12 @@
         final SearchQuery.NumericOperator operator = criterion.getOperator();
         final int size = row.getSize();
         final long value = operator.getValue();
-        final int type = operator.getType();
-        switch (type) {
-            case SearchQuery.NumericOperator.LESS_THAN:
+        switch (operator.getType()) {
+            case LESS_THAN:
                 return size < value;
-            case SearchQuery.NumericOperator.GREATER_THAN:
+            case GREATER_THAN:
                 return size > value;
-            case SearchQuery.NumericOperator.EQUALS:
+            case EQUALS:
                 return size == value;
             default:
                 throw new UnsupportedSearchException();
@@ -423,13 +419,12 @@
         final int month = operator.getMonth();
         final int year = operator.getYear();
         final Date internalDate = row.getInternalDate();
-        final int type = operator.getType();
-        switch (type) {
-            case SearchQuery.DateOperator.ON:
+        switch (operator.getType()) {
+            case ON:
                 return on(day, month, year, internalDate);
-            case SearchQuery.DateOperator.BEFORE:
+            case BEFORE:
                 return before(day, month, year, internalDate);
-            case SearchQuery.DateOperator.AFTER:
+            case AFTER:
                 return after(day, month, year, internalDate);
             default:
                 throw new UnsupportedSearchException();



---------------------------------------------------------------------
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