gnu.mail.providers.imap

Class IMAPFolder


public class IMAPFolder
extends Folder

The folder class implementing the IMAP4rev1 mail protocol.
Version:
0.1
Author:
Chris Burdess

Field Summary

protected char
delimiter
protected int
messageCount
protected int
newMessageCount
protected String
path
The folder path.
protected Flags
permanentFlags
protected int
type
The type of this folder (HOLDS_MESSAGES or HOLDS_FOLDERS).

Fields inherited from class javax.mail.Folder

HOLDS_FOLDERS, HOLDS_MESSAGES, READ_ONLY, READ_WRITE, mode, store

Constructor Summary

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

Method Summary

void
appendMessages(Message[] messages)
Appends the specified set of messages to this folder.
void
close(boolean expunge)
Closes this folder.
boolean
create(int type)
Create this folder.
boolean
delete(boolean flag)
Delete this folder.
boolean
equals(Object other)
boolean
exists()
Indicates whether this folder exists.
Message[]
expunge()
Expunges this folder.
void
fetch(Message[] messages, FetchProfile fp)
IMAP fetch routine.
Folder
getFolder(String name)
Returns a subfolder with the specified name.
protected IMAPFolder
getFolder(String name, int type, char delimiter)
Returns a configured subfolder.
String
getFullName()
Returns the full path of this folder.
Message
getMessage(int msgnum)
Returns the specified message number from this folder.
int
getMessageCount()
Returns the number of messages in this folder.
String
getName()
Returns the name of this folder.
int
getNewMessageCount()
Returns the number of new messages in this folder.
Folder
getParent()
Returns the parent folder of this folder.
Flags
getPermanentFlags()
Returns the permanent flags for this folder.
char
getSeparator()
Returns the path separator charcter.
int
getType()
Returns the type of this folder.
boolean
hasNewMessages()
Indicates whether this folder contains new messages.
boolean
isOpen()
Indicates whether this folder is open.
Folder[]
list(String pattern)
Returns the subfolders for this folder.
Folder[]
listSubscribed(String pattern)
Returns the subscribed subfolders for this folder.
void
open(int mode)
Opens this folder.
boolean
renameTo(Folder folder)
Rename this folder.
Message[]
search(SearchTerm term)
IMAP search function.
Message[]
search(SearchTerm term, Message[] msgs)
IMAP search function.

Methods inherited from class javax.mail.Folder

addConnectionListener, addFolderListener, addMessageChangedListener, addMessageCountListener, appendMessages, close, copyMessages, create, delete, exists, expunge, fetch, getDeletedMessageCount, getFolder, getFullName, getMessage, getMessageCount, getMessages, getMessages, getMessages, getMode, getName, getNewMessageCount, getParent, getPermanentFlags, getSeparator, getStore, getType, getURLName, getUnreadMessageCount, hasNewMessages, isOpen, isSubscribed, list, list, listSubscribed, listSubscribed, notifyConnectionListeners, notifyFolderListeners, notifyFolderRenamedListeners, notifyMessageAddedListeners, notifyMessageChangedListeners, notifyMessageRemovedListeners, open, removeConnectionListener, removeFolderListener, removeMessageChangedListener, removeMessageCountListener, renameTo, search, search, setFlags, setFlags, setFlags, setSubscribed, toString

Field Details

delimiter

protected char delimiter

messageCount

protected int messageCount

newMessageCount

protected int newMessageCount

path

protected String path
The folder path.

permanentFlags

protected Flags permanentFlags

type

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

Constructor Details

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 Details

appendMessages

public void appendMessages(Message[] messages)
            throws MessagingException
Appends the specified set of messages to this folder. Only MimeMessages are accepted.
Overrides:
appendMessages in interface Folder

close

public void close(boolean expunge)
            throws MessagingException
Closes this folder.
Overrides:
close in interface 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)
            throws MessagingException
Create this folder.
Overrides:
create in interface Folder

delete

public boolean delete(boolean flag)
            throws MessagingException
Delete this folder.
Overrides:
delete in interface Folder

equals

public boolean equals(Object other)

exists

public boolean exists()
            throws MessagingException
Indicates whether this folder exists.
Overrides:
exists in interface Folder
Throws:
MessagingException - if a messaging error occurred

expunge

public Message[] expunge()
            throws MessagingException
Expunges this folder. This deletes all the messages marked as deleted.
Overrides:
expunge in interface Folder
Throws:
MessagingException - if a messaging error occurred

fetch

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

getFolder

public Folder getFolder(String name)
            throws MessagingException
Returns a subfolder with the specified name.
Overrides:
getFolder in interface Folder

getFolder

protected IMAPFolder getFolder(String name,
                               int type,
                               char delimiter)
            throws MessagingException
Returns a configured subfolder.

getFullName

public String getFullName()
Returns the full path of this folder.
Overrides:
getFullName in interface Folder

getMessage

public Message getMessage(int msgnum)
            throws MessagingException
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.
Overrides:
getMessage in interface Folder
Throws:
MessagingException - if a messaging error occurred

getMessageCount

public int getMessageCount()
            throws MessagingException
Returns the number of messages in this folder.
Overrides:
getMessageCount in interface Folder
Throws:
MessagingException - if a messaging error occurred

getName

public String getName()
Returns the name of this folder.
Overrides:
getName in interface Folder

getNewMessageCount

public int getNewMessageCount()
            throws MessagingException
Returns the number of new messages in this folder.
Overrides:
getNewMessageCount in interface Folder
Throws:
MessagingException - if a messaging error occurred

getParent

public Folder getParent()
            throws MessagingException
Returns the parent folder of this folder.
Overrides:
getParent in interface Folder

getPermanentFlags

public Flags getPermanentFlags()
Returns the permanent flags for this folder.
Overrides:
getPermanentFlags in interface Folder

getSeparator

public char getSeparator()
            throws MessagingException
Returns the path separator charcter.
Overrides:
getSeparator in interface Folder

getType

public int getType()
            throws MessagingException
Returns the type of this folder.
Overrides:
getType in interface Folder
Throws:
MessagingException - if a messaging error occurred

hasNewMessages

public boolean hasNewMessages()
            throws MessagingException
Indicates whether this folder contains new messages.
Overrides:
hasNewMessages in interface Folder
Throws:
MessagingException - if a messaging error occurred

isOpen

public boolean isOpen()
Indicates whether this folder is open.
Overrides:
isOpen in interface Folder

list

public Folder[] list(String pattern)
            throws MessagingException
Returns the subfolders for this folder.
Overrides:
list in interface Folder

listSubscribed

public Folder[] listSubscribed(String pattern)
            throws MessagingException
Returns the subscribed subfolders for this folder.
Overrides:
listSubscribed in interface Folder

open

public void open(int mode)
            throws MessagingException
Opens this folder.
Overrides:
open in interface Folder
Throws:
MessagingException - if a messaging error occurred

renameTo

public boolean renameTo(Folder folder)
            throws MessagingException
Rename this folder.
Overrides:
renameTo in interface Folder

search

public Message[] search(SearchTerm term)
            throws MessagingException
IMAP search function.
Overrides:
search in interface Folder

search

public Message[] search(SearchTerm term,
                        Message[] msgs)
            throws MessagingException
IMAP search function.
Overrides:
search in interface Folder

© Copyright 2003, 2004 The Free Software Foundation, All rights reserved