KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > folder > IMailbox


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
10
//The Original Code is "The Columba Project"
11
//
12
//The Initial Developers of the Original Code are Frederik Dietz and Timo
13
// Stich.
14
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
15
//
16
//All Rights Reserved.
17

18 package org.columba.mail.folder;
19
20 import java.io.File JavaDoc;
21 import java.io.IOException JavaDoc;
22 import java.io.InputStream JavaDoc;
23
24 import org.columba.api.command.IStatusObservable;
25 import org.columba.core.filter.IFilterList;
26 import org.columba.core.filter.IFilter;
27 import org.columba.mail.message.IHeaderList;
28 import org.columba.ristretto.message.Attributes;
29 import org.columba.ristretto.message.Flags;
30 import org.columba.ristretto.message.Header;
31 import org.columba.ristretto.message.MailboxInfo;
32 import org.columba.ristretto.message.MimeTree;
33
34 /**
35  * Every mailbox which actually containss message should implement this
36  * interface.
37  * <p>
38  * Note, that this also means to subclass {@link Folder}.
39  *
40  * @author fdietz
41  */

42 public interface IMailbox extends IMailFolder {
43
44     /**
45      * Get the {@link MailboxInfo} of this mailbox
46      *
47      * @return
48      * @throws IOException
49      */

50     public IMailboxInfo getMessageFolderInfo();
51
52     /**
53      * Removes all messages which are marked as expunged
54      *
55      * @throws Exception
56      */

57     public void expungeFolder() throws Exception JavaDoc;
58
59     /**
60      * Checks if message with uid exists in this folder.
61      *
62      * @param uid
63      * UID of message
64      * @return boolean true, if message exists. False, otherwise.
65      * @throws Exception
66      */

67     public boolean exists(Object JavaDoc uid) throws Exception JavaDoc;
68
69     /**
70      * Return list of headers.
71      *
72      * @return HeaderList list of headers
73      * @throws Exception
74      */

75     public IHeaderList getHeaderList() throws Exception JavaDoc;
76
77     /**
78      * Mark messages as read/flagged/expunged/etc.
79      *
80      * See <code>MarkMessageCommand</code> for more information especially concerning
81      * the variant value.
82      *
83      * @param uid
84      * array of UIDs
85      * @param variant
86      * variant can be a value between 0 and 6
87      * @throws Exception
88      */

89     public abstract void markMessage(Object JavaDoc[] uids, int variant)
90             throws Exception JavaDoc;
91
92     /**
93      * Return mimepart structure. See <class>MimePartTree </class> for more
94      * details.
95      *
96      * @param uid
97      * UID of message
98      * @return MimePartTree return mimepart structure
99      * @throws Exception
100      */

101     public MimeTree getMimePartTree(Object JavaDoc uid) throws Exception JavaDoc;
102
103     /**
104      * Copy messages identified by UID to this folder.
105      * <p>
106      * This method is necessary for optimization reasons.
107      * <p>
108      * Think about using local and remote folders. If we would have only methods
109      * to add/remove messages this wouldn't be very efficient when moving
110      * messages between for example IMAP folders on the same server. We would
111      * have to download a complete message to remove it and then upload it again
112      * to add it to the destination folder.
113      * <p>
114      * Using the innercopy method the IMAP server can use its COPY command to
115      * move the message on the server-side.
116      *
117      * @param destFolder
118      * the destination folder of the copy operation
119      * @param uids
120      * an array of UID's identifying the messages
121      * @throws Exception
122      */

123     public void innerCopy(IMailbox destFolder, Object JavaDoc[] uids) throws Exception JavaDoc;
124
125     /**
126      * Adds a message to this Mailbox
127      *
128      * @param in
129      * The message InputStream
130      * @return The new uid of the added message or null if not defined
131      * @throws Exception
132      */

133     public Object JavaDoc addMessage(InputStream JavaDoc in) throws Exception JavaDoc;
134
135     /**
136      * Adds a message to this Mailbox
137      *
138      * @param in
139      * The message InputStream
140      * @param attributes
141      * The attributes of the message
142      * @param flags
143      * the flags of the message
144      * @return The new uid of the added message or null if not defined
145      * @throws Exception
146      */

147     public Object JavaDoc addMessage(InputStream JavaDoc in, Attributes attributes, Flags flags)
148             throws Exception JavaDoc;
149
150     /**
151      * Gets all specified headerfields. An example headerfield might be
152      * "Subject" or "From" (take care of lower/uppercaseletters).
153      * <p>
154      * Note, that you should use getAttributes() for fetching the internal
155      * headerfields (for example: columba.subject, columba.flags.seen, etc.).
156      * <p>
157      * This method first tries to find the requested header in the header cache
158      * (@see CachedFolder). If the headerfield is not cached, the message source
159      * is parsed.
160      *
161      * @param uid
162      * The uid of the desired message
163      * @param keys
164      * The keys like defined in e.g. RFC2822
165      * @return A {@link Header}containing the headerfields if they were present
166      * @throws Exception
167      */

168     public Header getHeaderFields(Object JavaDoc uid, String JavaDoc[] keys) throws Exception JavaDoc;
169
170     /**
171      * Gets the InputStream from the body of the mimepart. This excludes the
172      * header. If the stream was encoded with QuotedPrintable or Base64 decoding
173      * is already done.
174      *
175      * @param uid
176      * The UID of the message
177      * @param address
178      * The address of the mimepart
179      * @return
180      * @throws Exception
181      */

182     public InputStream JavaDoc getMimePartBodyStream(Object JavaDoc uid, Integer JavaDoc[] address)
183             throws Exception JavaDoc;
184
185     /**
186      * Gets the InputStream from the complete mimepart. This includes the
187      * header.
188      *
189      * @param uid
190      * The UID of the message
191      * @param address
192      * address The address of the mimepart
193      * @return
194      * @throws Exception
195      */

196     public InputStream JavaDoc getMimePartSourceStream(Object JavaDoc uid, Integer JavaDoc[] address)
197             throws Exception JavaDoc;
198
199     /**
200      * Gets the InputStream of the complete messagesource.
201      *
202      * @param uid
203      * The UID of the message
204      * @return
205      * @throws Exception
206      */

207     public InputStream JavaDoc getMessageSourceStream(Object JavaDoc uid) throws Exception JavaDoc;
208
209     /**
210      * Gets the Flags of the message.
211      *
212      * @param uid
213      * The UID of the message
214      * @return
215      * @throws Exception
216      */

217     public Flags getFlags(Object JavaDoc uid) throws Exception JavaDoc;
218
219     /**
220      * Gets a attribute from the message
221      *
222      * @param uid
223      * The UID of the message
224      * @param key
225      * The name of the attribute (e.g. "columba.subject",
226      * "columba.size")
227      * @return
228      * @throws Exception
229      */

230     public Object JavaDoc getAttribute(Object JavaDoc uid, String JavaDoc key) throws Exception JavaDoc;
231
232     /**
233      * Gets the attributes from the message
234      *
235      * @param uid
236      * The UID of the message
237      * @return
238      * @throws Exception
239      */

240     public Attributes getAttributes(Object JavaDoc uid) throws Exception JavaDoc;
241
242     /**
243      * Set attribute for message with UID.
244      *
245      * @param uid
246      * UID of message
247      * @param key
248      * name of attribute (e.g."columba.subject");
249      * @param value
250      * value of attribute
251      * @throws Exception
252      */

253     public void setAttribute(Object JavaDoc uid, String JavaDoc key, Object JavaDoc value)
254             throws Exception JavaDoc;
255
256     
257     public void removeMessage(Object JavaDoc uid) throws Exception JavaDoc;
258     
259     /**
260      * Return array of uids this folder contains.
261      *
262      * @return Object[] array of all UIDs this folder contains
263      */

264     public Object JavaDoc[] getUids() throws Exception JavaDoc;
265
266     /**
267      * Get all email headers.
268      *
269      * @param uid
270      * message uid
271      * @return complete email headers
272      * @throws Exception
273      */

274     public Header getAllHeaderFields(Object JavaDoc uid) throws Exception JavaDoc;
275
276     public Object JavaDoc[] searchMessages(IFilter filter) throws Exception JavaDoc;
277
278     public Object JavaDoc[] searchMessages(IFilter filter, Object JavaDoc[] uids)
279             throws Exception JavaDoc;
280
281     /**
282      * Is this mailbox read-only?
283      *
284      * @return
285      *
286      */

287     public boolean isReadOnly();
288
289     IStatusObservable getObservable();
290
291     Object JavaDoc getLastSelection();
292
293     void setLastSelection(Object JavaDoc lastSel);
294
295     IFilterList getFilterList();
296
297     public File JavaDoc getDirectoryFile();
298
299     public boolean isInboxFolder();
300
301     public boolean isTrashFolder();
302 }
303
Popular Tags