KickJava   Java API By Example, From Geeks To Geeks.

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


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 available--that
9  * is, either cached, or the folder is open.
10  */

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

17   public AvailableSearchTerm () {
18   }
19
20   /**
21    * Checks to see if the given Message is available either directly from
22    * the store or in cache.
23    */

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