almost there
[org.ibex.mail.git] / src / org / ibex / mail / Query.java
index 45b5659..bc8495c 100644 (file)
@@ -25,8 +25,9 @@ public class Query {
     public static Query arrival(Date earliest, Date latest) { return new Query(ARRIVAL, null,0,0,0,null,null, earliest, latest); }
     public static Query header(String name, String val)     { return new Query(HEADER, null, 0, 0, 0, name, val, null, null); }
     public static Query size(int min, int max)              { return new Query(SIZE, null, min, max, 0, null, null, null, null); }
-    public static Query body(String text)                   { return new Query(BODY, null, 0, 0, 0, null, text, null, null); }
     public static Query flags(int flags)                    { return new Query(FLAGS, null, 0, 0, flags, null, null, null, null); }
+    public static Query body(String text)                   { return new Query(BODY, null, 0, 0, 0, null, text, null, null); }
+    public static Query body(String text)                   { return new Query(FULL, null, 0, 0, 0, null, text, null, null); }
 
     private Query(int type, Query[] q, int min, int max, int flags, String key, String text, Date earliest, Date latest) {
         this.type = type; this.q = q; this.min = min; this.max = max; this.flags = flags; this.key = key; this.text = text;
@@ -44,6 +45,7 @@ public class Query {
     public static int SIZE       = 9;
     public static int FLAGS      = 10;
     public static int BODY       = 11;
+    public static int FULL       = 12;
 
     public final int type;
     public final Query[] q;
@@ -68,7 +70,8 @@ public class Query {
             case SIZE:       return m.size >= min && m.size <= max;
             case FLAGS:      return mbox.getFlags(flags);
             case HEADER:     return m.headers.get(key) != null && ((String)m.headers.get(key)).indexOf(text) != -1;
-            case HEADER:     return m.body.indexOf(text) != -1;
+            case BODY:       return m.body.indexOf(text) != -1;
+            case FULL:       return m.body.indexOf(text) != -1 || m.allHeaders.indexOf(text) != -1;
             default:         throw new Error("this should not happen");
         }
     }