KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > suberic > pooka > filter > CachedSearchTerm


1 package net.suberic.pooka.filter;
2 import javax.mail.*;
3 import javax.mail.search.*;
4 import net.suberic.pooka.*;
5 import net.suberic.pooka.cache.*;
6
7 /**
8  * This is a SearchTerm which checks for messages that are not cached.
9  */

10 public class CachedSearchTerm extends SearchTerm {
11
12   /**
13    * Creates the given CachedSearchTerm. Note that you have to
14    * have a FolderInfo to check for the cache.
15    */

16   public CachedSearchTerm () {
17   }
18
19   /**
20    * Checks to see if the given Message is cached or not.
21    */

22   public boolean match(Message m) {
23     if (m instanceof CachingMimeMessage) {
24       CachingMimeMessage cmm = (CachingMimeMessage) m;
25       long uid = cmm.getUID();
26       CachingFolderInfo folder = (CachingFolderInfo) cmm.getParent();
27       return (folder.isCached(uid));
28     } else {
29       return false;
30     }
31   }
32 }
33
Popular Tags