KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > suberic > pooka > cache > MessageCache


1 package net.suberic.pooka.cache;
2 import javax.mail.*;
3 import javax.mail.internet.*;
4 import javax.activation.DataHandler JavaDoc;
5 import net.suberic.pooka.MessageInfo;
6
7 public interface MessageCache {
8   
9   public static int NOT_CACHED = -1;
10   public static int FLAGS = 1;
11   public static int HEADERS = 5;
12   public static int FLAGS_AND_HEADERS = 10;
13   public static int CONTENT = 20;
14   public static int MESSAGE = 30;
15   
16   /**
17    * Returns the datahandler for the given message uid.
18    */

19   public DataHandler JavaDoc getDataHandler(long uid, long uidValidity) throws MessagingException;
20   
21   /**
22    * Returns the datahandler for the given message uid.
23    */

24   public DataHandler JavaDoc getDataHandler(long uid, long uidValidity, boolean saveToCache) throws MessagingException;
25   
26   /**
27    * Returns a non-mutable Message representation of the given Message.
28    */

29   public MimeMessage getMessageRepresentation(long uid, long uidValidity) throws MessagingException;
30
31   /**
32    * Returns a non-mutable Message representation of the given Message.
33    */

34   public MimeMessage getMessageRepresentation(long uid, long uidValidity, boolean saveToCache) throws MessagingException;
35
36   /**
37    * Adds the given Flags to the message with the given uid.
38    *
39    * This affects both the client cache as well as the message on the
40    * server, if the server is available.
41    */

42   public void addFlag(long uid, long uidValidity, Flags flag) throws MessagingException;
43   
44   /**
45    * Removes the given Flags from the message with the given uid.
46    *
47    * This affects both the client cache as well as the message on the
48    * server, if the server is available.
49    */

50   public void removeFlag(long uid, long uidValidity, Flags flag) throws MessagingException;
51   
52   /**
53    * Returns the InternetHeaders object for the given uid.
54    */

55   public InternetHeaders getHeaders(long uid, long uidValidity) throws MessagingException;
56
57   /**
58    * Returns the Flags object for the given uid.
59    */

60   public Flags getFlags(long uid, long uidValidity) throws MessagingException;
61
62   /**
63    * Adds a message to the cache. Note that status is only used to
64    * determine whether or not the entire message is cached, or just
65    * the headers and flags.
66    *
67    * This does not affect the server, nor does it affect message
68    * count on the client.
69    */

70   public boolean cacheMessage(MimeMessage m, long uid, long uidValidity, int status) throws MessagingException;
71
72   /**
73    * Adds a message to the cache. Note that status is only used to
74    * determine whether or not the entire message is cached, or just
75    * the headers and flags.
76    *
77    * This does not affect the server, nor does it affect message
78    * count on the client.
79    */

80   public boolean cacheMessage(MimeMessage m, long uid, long uidValidity, int status, boolean writeMsgFile) throws MessagingException;
81
82   /**
83    * Removes a message from the cache only. This has no effect on the
84    * server.
85    */

86   public boolean invalidateCache(long uid, int status);
87
88   /**
89    * Invalidates all of the messages in the uids array in the cache.
90    */

91   public boolean invalidateCache(long[] uids, int status);
92
93   /**
94    * Invalidates the entire cache.
95    */

96   public void invalidateCache();
97
98   /**
99    * Adds the messages to the given folder. Returns the uids for the
100    * message.
101    *
102    * This method changes both the client cache as well as the server, if
103    * the server is available.
104    */

105   public long[] appendMessages(MessageInfo[] msgs) throws MessagingException;
106
107   /**
108    * Removes all messages marked as 'DELETED' from the given folder.
109    *
110    * Note that if any message fails to be removed, then the ones
111    * that have succeeded should be returned in the long[].
112    *
113    * This method changes both the client cache as well as the server, if
114    * the server is available.
115    */

116   public void expungeMessages() throws MessagingException;
117
118   /**
119    * This returns the uid's of the message which exist in updatedUids, but
120    * not in the current list of messsages.
121    */

122   public long[] getAddedMessages(long[] updatedUids, long uidValidity) throws StaleCacheException;
123
124   /**
125    * This returns the uid's of the message which exist in the current
126    * list of messages, but no longer exist in the updatedUids.
127    */

128   public long[] getRemovedMessages(long[] updatedUids, long uidValidity) throws StaleCacheException;
129   
130   /**
131    * This returns the message id's of all the currently cached messages.
132    * Note that only the headers and flags of the message need to be
133    * cached for a message to be considered in the cache.
134    */

135   public long[] getMessageUids();
136   
137   /**
138    * This returns the number of messages in the cache.
139    */

140   public int getMessageCount() throws MessagingException;
141   
142   /**
143    * This returns the number of unread messages in the cache.
144    */

145   public int getUnreadMessageCount() throws MessagingException;
146   
147   /**
148    * Returns the current UIDValidity of the cache.
149    */

150   public long getUIDValidity();
151   
152   /**
153    * Updates the UIDValidity of the cache to a new value. Should only
154    * be used after a call to invalidateCache().
155    */

156   public void setUIDValidity(long newValidity);
157   
158   /**
159    * Writes any offline changes made back to the server.
160    */

161   public void writeChangesToServer(Folder f) throws MessagingException;
162
163   /**
164    * Gets the size for the given message, if available.
165    */

166   public int getSize(long uid);
167
168   /**
169    * Returns whether a given uid exists fully in the cache or not.
170    */

171   public boolean isFullyCached(long uid);
172
173   /**
174    * Returns the status of the given uid.
175    */

176   public int getCacheStatus(long uid) throws MessagingException;
177
178   /**
179    * Searches all of the cached messages and returns those which match
180    * the given SearchTerm.
181    */

182   public MessageInfo[] search(javax.mail.search.SearchTerm JavaDoc term) throws
183     javax.mail.MessagingException JavaDoc;
184
185   /**
186    * Writes the list of cached messages.
187    */

188   public void writeMsgFile();
189 }
190
Popular Tags