graylist/whitelist updates
[org.ibex.mail.git] / src / org / ibex / mail / Query.java
index 0e26897..d308da8 100644 (file)
@@ -1,6 +1,11 @@
+// Copyright 2000-2005 the Contributors, as shown in the revision logs.
+// Licensed under the Apache Public Source License 2.0 ("the License").
+// You may not use this file except in compliance with the License.
+
 package org.ibex.mail;
 import java.util.*;
 import org.ibex.mail.target.*;
+import org.ibex.util.*;
 
 /**
  *  [immutable] This class encapsulates a query against a mailbox.
@@ -80,7 +85,8 @@ public class Query {
             case OR:         for(int i=0; i<q.length; i++) if (q[i].match(it)) return true; return false;
             case AND:        for(int i=0; i<q.length; i++) if (!q[i].match(it)) return false; return true;
             case UID:        if (set != null) {
-                                 for(int i=0; i<set.length; i+=2) if (set[i] <= it.uid() && set[i+1] >= it.uid()) return true;
+                                 for(int i=0; i<set.length; i+=2)
+                                    if (set[i] <= it.uid() && set[i+1] >= it.uid()) return true;
                                  return false; }
                              else return it.uid() >= min && it.uid() <= max;
             case NUM:        if (set != null) {
@@ -91,18 +97,21 @@ public class Query {
                                     (earliest==null||it.cur().date.after(earliest));
             case ARRIVAL:    return (latest == null || it.cur().arrival.before(latest)) &&
                                     (earliest == null || it.cur().arrival.after(earliest));
-            case SIZE:       return it.cur().rfc822size() >= min && it.cur().rfc822size() <= max;
             case HEADER:     return it.cur().headers.get(key) != null &&
                                  ((String)it.cur().headers.get(key)).toLowerCase().indexOf(text.toLowerCase()) != -1;
-            case BODY:       return it.cur().body.toLowerCase().indexOf(text.toLowerCase()) != -1;
-            case FULL:       return it.cur().body.toLowerCase().indexOf(text.toLowerCase()) != -1 ||
-                                 it.cur().allHeaders.indexOf(text) != -1;
             case DELETED:    return it.deleted();
             case SEEN:       return it.seen();
             case FLAGGED:    return it.flagged();
             case DRAFT:      return it.draft();
             case ANSWERED:   return it.answered();
             case RECENT:     return it.recent();
+
+            // FIXME: super inefficient
+            case BODY:       throw new RuntimeException("BODY searches are not supported because they are slow");
+            case FULL:       throw new RuntimeException("FULL searches are not supported because they are slow");
+            case SIZE:       throw new RuntimeException("SIZE searches are not supported because Adam is lame");
+                //return it.cur().size() >= min && it.cur().size() <= max;
+
             default:         throw new Error("this should not happen");
         }
     }