gnu.mail.providers.imap

Class IMAPFolder

public class IMAPFolder extends Folder implements UIDFolder

The folder class implementing the IMAP4rev1 mail protocol.

Version: 0.1

Author: Chris Burdess

Field Summary
protected chardelimiter
protected intmessageCount
protected intnewMessageCount
protected Stringpath
The folder path.
protected FlagspermanentFlags
protected booleansubscribed
protected inttype
The type of this folder(HOLDS_MESSAGES or HOLDS_FOLDERS).
protected longuidValidity
Constructor Summary
protected IMAPFolder(Store store, String path)
Constructor.
protected IMAPFolder(Store store, String path, char delimiter)
Constructor.
protected IMAPFolder(Store store, String path, int type, char delimiter)
Constructor.
Method Summary
voidappendMessages(Message[] messages)
Appends the specified set of messages to this folder.
voidclose(boolean expunge)
Closes this folder.
booleancreate(int type)
Create this folder.
booleandelete(boolean flag)
Delete this folder.
booleanequals(Object other)
booleanexists()
Indicates whether this folder exists.
Message[]expunge()
Expunges this folder.
voidfetch(Message[] messages, FetchProfile fp)
IMAP fetch routine.
intgetDeletedMessageCount()
Returns the number of deleted messages in this folder.
FoldergetFolder(String name)
Returns a subfolder with the specified name.
StringgetFullName()
Returns the full path of this folder.
MessagegetMessage(int msgnum)
Returns the specified message number from this folder.
MessagegetMessageByUID(long uid)
intgetMessageCount()
Returns the number of messages in this folder.
intgetMessageCountByCriteria(String criteria)
Convenience method for returning the number of messages in the current folder that match the single criteria.
Message[]getMessagesByUID(long start, long end)
Message[]getMessagesByUID(long[] uids)
StringgetName()
Returns the name of this folder.
intgetNewMessageCount()
Returns the number of new messages in this folder.
FoldergetParent()
Returns the parent folder of this folder.
FlagsgetPermanentFlags()
Returns the permanent flags for this folder.
Quota[]getQuota()
Returns the quotas for this folder.
chargetSeparator()
Returns the path separator charcter.
intgetType()
Returns the type of this folder.
longgetUID(Message message)
longgetUIDValidity()
intgetUnreadMessageCount()
Returns the number of unread messages in this folder.
booleanhasNewMessages()
Indicates whether this folder contains new messages.
booleanisOpen()
Indicates whether this folder is open.
booleanisSubscribed()
Folder[]list(String pattern)
Returns the subfolders for this folder.
Folder[]listSubscribed(String pattern)
Returns the subscribed subfolders for this folder.
voidopen(int mode)
Opens this folder.
booleanrenameTo(Folder folder)
Rename this folder.
Message[]search(SearchTerm term)
IMAP search function.
Message[]search(SearchTerm term, Message[] msgs)
IMAP search function.
voidsetSubscribed(boolean flag)

Field Detail

delimiter

protected char delimiter

messageCount

protected int messageCount

newMessageCount

protected int newMessageCount

path

protected String path
The folder path.

permanentFlags

protected Flags permanentFlags

subscribed

protected boolean subscribed

type

protected int type
The type of this folder(HOLDS_MESSAGES or HOLDS_FOLDERS).

uidValidity

protected long uidValidity

Constructor Detail

IMAPFolder

protected IMAPFolder(Store store, String path)
Constructor.

IMAPFolder

protected IMAPFolder(Store store, String path, char delimiter)
Constructor.

IMAPFolder

protected IMAPFolder(Store store, String path, int type, char delimiter)
Constructor.

Method Detail

appendMessages

public void appendMessages(Message[] messages)
Appends the specified set of messages to this folder. Only MimeMessages are accepted.

close

public void close(boolean expunge)
Closes this folder.

Parameters: expunge if the folder is to be expunged before it is closed

Throws: MessagingException if a messaging error occurred

create

public boolean create(int type)
Create this folder.

delete

public boolean delete(boolean flag)
Delete this folder.

equals

public boolean equals(Object other)

exists

public boolean exists()
Indicates whether this folder exists.

Throws: MessagingException if a messaging error occurred

expunge

public Message[] expunge()
Expunges this folder. This deletes all the messages marked as deleted.

Throws: MessagingException if a messaging error occurred

fetch

public void fetch(Message[] messages, FetchProfile fp)
IMAP fetch routine. This executes the fetch for the specified message numbers and updates the messages according to the message statuses returned.

getDeletedMessageCount

public int getDeletedMessageCount()
Returns the number of deleted messages in this folder.

See Also: getDeletedMessageCount

getFolder

public Folder getFolder(String name)
Returns a subfolder with the specified name.

getFullName

public String getFullName()
Returns the full path of this folder.

getMessage

public Message getMessage(int msgnum)
Returns the specified message number from this folder. The message is only retrieved once from the server. Subsequent getMessage() calls to the same message are cached. Since POP3 does not provide a mechanism for retrieving only part of the message(headers, etc), the entire message is retrieved.

Throws: MessagingException if a messaging error occurred

getMessageByUID

public Message getMessageByUID(long uid)

getMessageCount

public int getMessageCount()
Returns the number of messages in this folder.

Throws: MessagingException if a messaging error occurred

getMessageCountByCriteria

public int getMessageCountByCriteria(String criteria)
Convenience method for returning the number of messages in the current folder that match the single criteria.

getMessagesByUID

public Message[] getMessagesByUID(long start, long end)

getMessagesByUID

public Message[] getMessagesByUID(long[] uids)

getName

public String getName()
Returns the name of this folder.

getNewMessageCount

public int getNewMessageCount()
Returns the number of new messages in this folder.

Throws: MessagingException if a messaging error occurred

getParent

public Folder getParent()
Returns the parent folder of this folder.

getPermanentFlags

public Flags getPermanentFlags()
Returns the permanent flags for this folder.

getQuota

public Quota[] getQuota()
Returns the quotas for this folder.

getSeparator

public char getSeparator()
Returns the path separator charcter.

getType

public int getType()
Returns the type of this folder.

Throws: MessagingException if a messaging error occurred

getUID

public long getUID(Message message)

getUIDValidity

public long getUIDValidity()

getUnreadMessageCount

public int getUnreadMessageCount()
Returns the number of unread messages in this folder.

See Also: getUnreadMessageCount

hasNewMessages

public boolean hasNewMessages()
Indicates whether this folder contains new messages.

Throws: MessagingException if a messaging error occurred

isOpen

public boolean isOpen()
Indicates whether this folder is open.

isSubscribed

public boolean isSubscribed()

list

public Folder[] list(String pattern)
Returns the subfolders for this folder.

listSubscribed

public Folder[] listSubscribed(String pattern)
Returns the subscribed subfolders for this folder.

open

public void open(int mode)
Opens this folder.

Throws: MessagingException if a messaging error occurred

renameTo

public boolean renameTo(Folder folder)
Rename this folder.

search

public Message[] search(SearchTerm term)
IMAP search function.

search

public Message[] search(SearchTerm term, Message[] msgs)
IMAP search function.

setSubscribed

public void setSubscribed(boolean flag)
©