change num() to imapNumber() and nntpNumber(), add comments about semantics
[org.ibex.mail.git] / src / org / ibex / mail / Query.java
index d308da8..14f3e09 100644 (file)
@@ -26,7 +26,8 @@ public class Query {
     public static Query or(Query q1, Query q2)      { return new Query(OR,new Query[] {q1,q2},0,0,0,null,null, null, null, null); }
     public static Query or(Query[] q)               { return new Query(OR, q, 0, 0, 0, null, null, null, null, null); }
     public static Query uid(int min, int max)       { return new Query(UID, null, min, max, 0, null, null, null, null, null); }
-    public static Query messagenum(int min,int max) { return new Query(NUM,null,min,max,0,null,null,null,null, null); }
+    public static Query imapNumber(int min,int max) { return new Query(IMAPNUM,null,min,max,0,null,null,null,null, null); }
+    public static Query nntpNumber(int min,int max) { return new Query(NNTPNUM,null,min,max,0,null,null,null,null, null); }
     public static Query sent(Date e, Date l)        { return new Query(SENT,null,0,0,0,null,null,e,l,null); }
     public static Query arrival(Date e, Date l)     { return new Query(ARRIVAL,null,0,0,0,null,null, e,l,null);}
     public static Query header(String k, String v)  { return new Query(HEADER, null, 0, 0, 0, k, v, null, null, null);}
@@ -34,7 +35,7 @@ public class Query {
     public static Query body(String text)           { return new Query(BODY, null, 0, 0, 0, null, text, null, null, null);}
     public static Query full(String text)           { return new Query(FULL, null, 0, 0, 0, null, text, null, null, null);}
     public static Query uid(int[] set)              { return new Query(UID,  null, 0 ,0 ,0, null, null, null, null, set);}
-    public static Query num(int[] set)              { return new Query(NUM,  null, 0 ,0 ,0, null, null, null, null, set);}
+    public static Query imapNumber(int[] set)       { return new Query(IMAPNUM,  null, 0 ,0 ,0, null, null, null, null, set);}
     public static Query all()                       { return new Query(ALL, null, 0, 0, 0, null, null, null, null, null); }
     public static Query deleted()                   { return new Query(DELETED, null, 0, 0, 0, null, null, null, null, null); }
     public static Query seen()                      { return new Query(SEEN, null, 0, 0, 0, null, null, null, null, null); }
@@ -42,7 +43,7 @@ public class Query {
     public static Query draft()                     { return new Query(DRAFT, null, 0, 0, 0, null, null, null, null, null); }
     public static Query answered()                  { return new Query(ANSWERED, null, 0, 0, 0, null, null, null, null, null); }
     public static Query recent()                    { return new Query(RECENT, null, 0, 0, 0, null, null, null, null, null); }
-    public static Query set(boolean uid, int[] set) { return uid ? uid(set) : num(set); }
+    //public static Query set(boolean uid, int[] set) { return uid ? uid(set) : imapNumber(set); }
 
     private Query(int type, Query[] q,int min,int max, int flags, String key, String text, Date earliest, Date latest, int[] set) {
         this.type = type; this.q = q; this.min = min; this.max = max; this.flags = flags; this.key = key; this.text = text;
@@ -59,13 +60,14 @@ public class Query {
     public static final int SIZE       = 8;
     public static final int BODY       = 9;
     public static final int FULL       = 10;
-    public static final int NUM        = 11;
+    public static final int IMAPNUM    = 11;
     public static final int DELETED    = 12;
     public static final int SEEN       = 13;
     public static final int FLAGGED    = 14;
     public static final int DRAFT      = 15;
     public static final int ANSWERED   = 16;
     public static final int RECENT     = 17;
+    public static final int NNTPNUM    = 18;
 
     public final int type;
     public final Query[] q;
@@ -89,10 +91,14 @@ public class Query {
                                     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) {
-                                 for(int i=0; i<set.length; i+=2) if (set[i] <= it.num() && set[i+1] >= it.num()) return true;
+            case IMAPNUM:    if (set != null) {
+                                 for(int i=0; i<set.length; i+=2) if (set[i] <= it.imapNumber() && set[i+1] >= it.imapNumber()) return true;
                                  return false; }
-                             else return it.num() >= min && it.num() <= max;
+                             else return it.imapNumber() >= min && it.imapNumber() <= max;
+            case NNTPNUM:    if (set != null) {
+                                 for(int i=0; i<set.length; i+=2) if (set[i] <= it.nntpNumber() && set[i+1] >= it.nntpNumber()) return true;
+                                 return false; }
+                             else return it.imapNumber() >= min && it.imapNumber() <= max;
             case SENT:       return (latest==null||it.cur().date.before(latest)) && 
                                     (earliest==null||it.cur().date.after(earliest));
             case ARRIVAL:    return (latest == null || it.cur().arrival.before(latest)) &&