public class

IMAPFolder

extends Folder
implements ResponseHandler UIDFolder
java.lang.Object
   ↳ com.google.code.javax.mail.Folder
     ↳ com.google.code.com.sun.mail.imap.IMAPFolder
Known Direct Subclasses

Class Overview

This class implements an IMAP folder.

A closed IMAPFolder object shares a protocol connection with its IMAPStore object. When the folder is opened, it gets its own protocol connection.

Applications that need to make use of IMAP-specific features may cast a GmailFolder object to an IMAPFolder object and use the methods on this class. The getQuota and setQuota methods support the IMAP QUOTA extension. Refer to RFC 2087 for more information.

The getACL, addACL, removeACL, addRights, removeRights, listRights, and myRights methods support the IMAP ACL extension. Refer to RFC 2086 for more information.

The doCommand method and IMAPFolder.ProtocolCommand interface support use of arbitrary IMAP protocol commands.

See the com.sun.mail.imap package documentation for further information on the IMAP protocol provider.

WARNING: The APIs unique to this class should be considered EXPERIMENTAL. They may be changed in the future in ways that are incompatible with applications using the current APIs.

Summary

Nested Classes
class IMAPFolder.FetchProfileItem A fetch profile item for fetching headers. 
interface IMAPFolder.ProtocolCommand A simple interface for user-defined IMAP protocol commands. 
Constants
int ABORTING
int IDLE
int RUNNING
char UNKNOWN_SEPARATOR
[Expand]
Inherited Constants
From class com.google.code.javax.mail.Folder
From interface com.google.code.javax.mail.UIDFolder
Fields
protected String[] attributes
protected Flags availableFlags
private Status cachedStatus
private long cachedStatusTime
private boolean connectionPoolDebug
protected boolean debug
private boolean doExpungeNotification
protected boolean exists
protected String fullName
private boolean hasMessageCountListener
private int idleState
protected boolean isNamespace
protected MessageCache messageCache
protected final Object messageCacheLock
protected String name
private boolean opened
protected PrintStream out
protected Flags permanentFlags
protected IMAPProtocol protocol
private int realTotal
private boolean reallyClosed
private int recent
protected char separator
private int total
protected int type
protected Hashtable uidTable
private long uidnext
private long uidvalidity
[Expand]
Inherited Fields
From class com.google.code.javax.mail.Folder
Protected Constructors
IMAPFolder(String fullName, char separator, IMAPStore store, Boolean isNamespace)
Constructor used to create a possibly non-existent folder.
IMAPFolder(ListInfo li, IMAPStore store)
Constructor used to create an existing folder.
Public Methods
void addACL(ACL acl)
Add an access control list entry to the access control list for this folder.
synchronized void addMessageCountListener(MessageCountListener l)
Add a listener for MessageCount events on this GmailFolder.
synchronized Message[] addMessages(Message[] msgs)
Append the given messages into this folder.
void addRights(ACL acl)
Add the rights specified in the ACL to the entry for the identifier specified in the ACL.
synchronized void appendMessages(Message[] msgs)
Append the given messages into this folder.
synchronized AppendUID[] appendUIDMessages(Message[] msgs)
Append the given messages into this folder.
synchronized void close(boolean expunge)
Close this folder.
synchronized void copyMessages(Message[] msgs, Folder folder)
Copy the specified messages from this folder, to the specified destination.
synchronized boolean create(int type)
Create this folder, with the specified type.
synchronized boolean delete(boolean recurse)
Delete this folder.
Object doCommand(IMAPFolder.ProtocolCommand cmd)
Execute a user-supplied IMAP command.
Object doCommandIgnoreFailure(IMAPFolder.ProtocolCommand cmd)
Object doOptionalCommand(String err, IMAPFolder.ProtocolCommand cmd)
synchronized boolean exists()
Check whether this folder really exists on the server.
synchronized Message[] expunge(Message[] msgs)
Expunge the indicated messages, which must have been marked as DELETED.
synchronized Message[] expunge()
Expunge all messages marked as DELETED.
synchronized void fetch(Message[] msgs, FetchProfile fp)
Prefetch attributes, based on the given FetchProfile.
synchronized void forceClose()
Close this folder without waiting for the server.
ACL[] getACL()
Get the access control list entries for this folder.
synchronized String[] getAttributes()
Get the attributes that the IMAP server returns with the LIST response.
synchronized int getDeletedMessageCount()
Get the deleted message count.
synchronized Folder getFolder(String name)
Get the named subfolder.
synchronized String getFullName()
Get the fullname of this folder.
synchronized Message getMessage(int msgnum)
Get the specified message.
synchronized Message getMessageByUID(long uid)
Get the Message corresponding to the given UID.
synchronized int getMessageCount()
Get the total message count.
synchronized Message[] getMessagesByUID(long[] uids)
Get the Messages specified by the given array.
synchronized Message[] getMessagesByUID(long start, long end)
Get the Messages specified by the given range.
synchronized String getName()
Get the name of this folder.
synchronized int getNewMessageCount()
Get the new message count.
synchronized Folder getParent()
Get this folder's parent.
synchronized Flags getPermanentFlags()
Return the permanent flags supported by the server.
Quota[] getQuota()
Get the quotas for the quotaroot associated with this folder.
synchronized char getSeparator()
Get the separator character.
synchronized Message[] getSortedMessages(SortTerm[] term, SearchTerm sterm)
Sort the messages in the folder according to the sort criteria.
synchronized Message[] getSortedMessages(SortTerm[] term)
Sort the messages in the folder according to the sort criteria.
synchronized int getType()
Get the type of this folder.
synchronized long getUID(Message message)
Get the UID for the specified message.
synchronized long getUIDNext()
Returns the predicted UID that will be assigned to the next message that is appended to this folder.
synchronized long getUIDValidity()
Returns the UIDValidity for this folder.
synchronized int getUnreadMessageCount()
Get the unread message count.
void handleResponse(Response r)
The response handler.
synchronized boolean hasNewMessages()
Check whether this folder has new messages.
void idle(boolean once)
Like idle(), but if once is true, abort the IDLE command after the first notification, to allow the caller to process any notification synchronously.
void idle()
Use the IMAP IDLE command (see RFC 2177), if supported by the server, to enter idle mode so that the server can send unsolicited notifications of new messages arriving, etc.
synchronized boolean isOpen()
Check whether this connection is really open.
synchronized boolean isSubscribed()
Check whether this folder is subscribed.
Folder[] list(String pattern)
List all subfolders matching the specified pattern.
Rights[] listRights(String name)
Get all the rights that may be allowed to the given identifier.
Folder[] listSubscribed(String pattern)
List all subscribed subfolders matching the specified pattern.
Rights myRights()
Get the rights allowed to the currently authenticated user.
synchronized void open(int mode)
Open this folder in the given mode.
void removeACL(String name)
Remove any access control list entry for the given identifier from the access control list for this folder.
void removeRights(ACL acl)
Remove the rights specified in the ACL from the entry for the identifier specified in the ACL.
synchronized boolean renameTo(Folder f)
Rename this folder.
synchronized Message[] search(SearchTerm term)
Search whole folder for messages matching the given term.
synchronized Message[] search(SearchTerm term, Message[] msgs)
Search the folder for messages matching the given term.
synchronized void setFlags(Message[] msgs, Flags flag, boolean value)
Set the specified flags for the given array of messages.
synchronized void setGoogleMessageLabels(Message[] msgs, String[] labels, boolean value)
void setQuota(Quota quota)
Set the quotas for the quotaroot specified in the quota argument.
synchronized void setSubscribed(boolean subscribe)
Subscribe/Unsubscribe this folder.
Folder[] xlist(String pattern)
Protected Methods
void checkClosed()
void checkExists()
void checkOpened()
void checkRange(int msgno)
Object doProtocolCommand(IMAPFolder.ProtocolCommand cmd)
IMAPMessage getMessageBySeqNumber(int seqnum)
Get the message object for the given sequence number.
IMAPProtocol getProtocol()
Return the IMAPProtocol object for this folder.
synchronized IMAPProtocol getStoreProtocol()
Get this folder's Store's protocol connection.
void keepConnectionAlive(boolean keepStoreAlive)
Issue a noop command for the connection if the connection has not been used in more than a second.
void releaseProtocol(boolean returnToPool)
Release the protocol object.
synchronized void releaseStoreProtocol(IMAPProtocol p)
Release the store protocol object.
synchronized void throwClosedException(ConnectionException cex)
Throw the appropriate 'closed' exception.
[Expand]
Inherited Methods
From class com.google.code.javax.mail.Folder
From class java.lang.Object
From interface com.google.code.com.sun.mail.iap.ResponseHandler
From interface com.google.code.javax.mail.UIDFolder

Constants

private static final int ABORTING

Constant Value: 2 (0x00000002)

private static final int IDLE

Constant Value: 1 (0x00000001)

private static final int RUNNING

Constant Value: 0 (0x00000000)

protected static final char UNKNOWN_SEPARATOR

Constant Value: 65535 (0x0000ffff)

Fields

protected String[] attributes

protected Flags availableFlags

private Status cachedStatus

private long cachedStatusTime

private boolean connectionPoolDebug

protected boolean debug

private boolean doExpungeNotification

protected boolean exists

protected String fullName

private boolean hasMessageCountListener

private int idleState

protected boolean isNamespace

protected MessageCache messageCache

protected final Object messageCacheLock

protected String name

private boolean opened

protected PrintStream out

protected Flags permanentFlags

protected IMAPProtocol protocol

private int realTotal

private boolean reallyClosed

private int recent

protected char separator

private int total

protected int type

protected Hashtable uidTable

private long uidnext

private long uidvalidity

Protected Constructors

protected IMAPFolder (String fullName, char separator, IMAPStore store, Boolean isNamespace)

Constructor used to create a possibly non-existent folder.

Parameters
fullName Fullname of this folder
separator The default separator character for this folder's namespace
store The Store
isNamespace

protected IMAPFolder (ListInfo li, IMAPStore store)

Constructor used to create an existing folder.

Parameters
li
store

Public Methods

public void addACL (ACL acl)

Add an access control list entry to the access control list for this folder.

Parameters
acl The access control list entry to add
Throws
MessagingException if the server doesn't support the ACL extension

public synchronized void addMessageCountListener (MessageCountListener l)

Add a listener for MessageCount events on this GmailFolder.

The implementation provided here adds this listener to an internal list of MessageCountListeners.

Parameters
l The Listener for MessageCount events

public synchronized Message[] addMessages (Message[] msgs)

Append the given messages into this folder. Return array of Message objects representing the messages in the destination folder. Note that the folder must be open. Each element of the returned array corresponds to an element of the msgs array. A null element means the server didn't return UID information for the appended message.

Depends on the APPENDUID response code defined by the UIDPLUS extension - RFC 2359.

Parameters
msgs

public void addRights (ACL acl)

Add the rights specified in the ACL to the entry for the identifier specified in the ACL. If an entry for the identifier doesn't already exist, add one.

Parameters
acl The identifer and rights to add
Throws
MessagingException if the server doesn't support the ACL extension

public synchronized void appendMessages (Message[] msgs)

Append the given messages into this folder.

Parameters
msgs Array of Messages to be appended

public synchronized AppendUID[] appendUIDMessages (Message[] msgs)

Append the given messages into this folder. Return array of AppendUID objects containing UIDs of these messages in the destination folder. Each element of the returned array corresponds to an element of the msgs array. A null element means the server didn't return UID information for the appended message.

Depends on the APPENDUID response code defined by the UIDPLUS extension - RFC 2359.

Parameters
msgs

public synchronized void close (boolean expunge)

Close this folder.

Parameters
expunge Expunges all deleted messages if this flag is true

public synchronized void copyMessages (Message[] msgs, Folder folder)

Copy the specified messages from this folder, to the specified destination.

Parameters
msgs The array of message objects
folder The folder to copy the messages to

public synchronized boolean create (int type)

Create this folder, with the specified type.

Parameters
type The type of this folder.
Returns
  • true if the creation succeeds, else false.

public synchronized boolean delete (boolean recurse)

Delete this folder.

Parameters
recurse
Returns
  • true if the GmailFolder is deleted successfully

public Object doCommand (IMAPFolder.ProtocolCommand cmd)

Execute a user-supplied IMAP command. The command is executed in the appropriate context with the necessary locks held and using the appropriate IMAPProtocol object.

This method returns whatever the ProtocolCommand object's doCommand method returns. If the doCommand method throws a ConnectionException it is translated into a StoreClosedException or FolderClosedException as appropriate. If the doCommand method throws a ProtocolException it is translated into a MessagingException.

The following example shows how to execute the IMAP NOOP command. Executing more complex IMAP commands requires intimate knowledge of the com.sun.mail.iap and com.sun.mail.imap.protocol packages, best acquired by reading the source code.

 import com.google.code.com.sun.mail.iap.*;
 import com.google.code.com.sun.mail.imap.*;
 import com.google.code.com.sun.mail.imap.protocol.*;

 ...

 IMAPFolder f = (IMAPFolder)folder;
 Object val = f.doCommand(new IMAPFolder.ProtocolCommand() {
	public Object doCommand(IMAPProtocol p)
			throws ProtocolException {
	    p.simpleCommand("NOOP", null);
	    return null;
	}
 });
 

Here's a more complex example showing how to use the proposed IMAP SORT extension:

import com.google.code.com.sun.mail.iap.*; import com.google.code.com.sun.mail.imap.*; import com.google.code.com.sun.mail.imap.protocol.*; ... IMAPFolder f = (IMAPFolder)folder; Object val = f.doCommand(new IMAPFolder.ProtocolCommand() { public Object doCommand(IMAPProtocol p) throws ProtocolException { // Issue command Argument args = new Argument(); Argument list = new Argument(); list.writeString("SUBJECT"); args.writeArgument(list); args.writeString("UTF-8"); args.writeString("ALL"); Response[] r = p.command("SORT", args); Response response = r[r.length-1]; // Grab response Vector v = new Vector(); if (response.isOK()) { // command succesful for (int i = 0, len = r.length; i < len; i++) { if (!(r[i] instanceof IMAPResponse)) continue; IMAPResponse ir = (IMAPResponse)r[i]; if (ir.keyEquals("SORT")) { String num; while ((num = ir.readAtomString()) != null) System.out.println(num); r[i] = null; } } } // dispatch remaining untagged responses p.notifyResponseHandlers(r); p.handleResult(response); return null; } });

Parameters
cmd

public Object doCommandIgnoreFailure (IMAPFolder.ProtocolCommand cmd)

Parameters
cmd

public Object doOptionalCommand (String err, IMAPFolder.ProtocolCommand cmd)

Parameters
err
cmd

public synchronized boolean exists ()

Check whether this folder really exists on the server.

Returns
  • true if the folder exists, otherwise false

public synchronized Message[] expunge (Message[] msgs)

Expunge the indicated messages, which must have been marked as DELETED. Depends on the UIDPLUS extension - RFC 2359.

Parameters
msgs

public synchronized Message[] expunge ()

Expunge all messages marked as DELETED.

Returns
  • array of expunged Message objects

public synchronized void fetch (Message[] msgs, FetchProfile fp)

Prefetch attributes, based on the given FetchProfile.

Parameters
msgs Fetch items for these messages
fp The FetchProfile

public synchronized void forceClose ()

Close this folder without waiting for the server.

public ACL[] getACL ()

Get the access control list entries for this folder.

Returns
  • array of access control list entries
Throws
MessagingException if the server doesn't support the ACL extension

public synchronized String[] getAttributes ()

Get the attributes that the IMAP server returns with the LIST response.

public synchronized int getDeletedMessageCount ()

Get the deleted message count.

Returns
  • number of deleted messages. -1 may be returned by certain implementations if this method is invoked on a closed folder.

public synchronized Folder getFolder (String name)

Get the named subfolder.

Parameters
name Name of the GmailFolder
Returns
  • GmailFolder object

public synchronized String getFullName ()

Get the fullname of this folder.

Returns
  • full name of the GmailFolder

public synchronized Message getMessage (int msgnum)

Get the specified message.

Parameters
msgnum The message number
Returns
  • the Message object

public synchronized Message getMessageByUID (long uid)

Get the Message corresponding to the given UID. If no such message exists, null is returned.

Parameters
uid UID for the desired message
Returns
  • the Message object. null is returned if no message corresponding to this UID is obtained.

public synchronized int getMessageCount ()

Get the total message count.

Returns
  • total number of messages. -1 may be returned by certain implementations if this method is invoked on a closed folder.

public synchronized Message[] getMessagesByUID (long[] uids)

Get the Messages specified by the given array.

uids.length() elements are returned. If any UID in the array is invalid, a null entry is returned for that element.

Parameters
uids Array of UIDs
Returns
  • array of Message objects

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

Get the Messages specified by the given range.

Returns Message objects for all valid messages in this range. Returns an empty array if no messages are found.

Parameters
start Start UID
end End UID
Returns
  • array of Message objects

public synchronized String getName ()

Get the name of this folder.

Returns
  • name of the GmailFolder

public synchronized int getNewMessageCount ()

Get the new message count.

Returns
  • number of new messages. -1 may be returned by certain implementations if this method is invoked on a closed folder.

public synchronized Folder getParent ()

Get this folder's parent.

Returns
  • Parent folder

public synchronized Flags getPermanentFlags ()

Return the permanent flags supported by the server.

Returns
  • permanent flags, or null if not known

public Quota[] getQuota ()

Get the quotas for the quotaroot associated with this folder. Note that many folders may have the same quotaroot. Quotas are controlled on the basis of a quotaroot, not (necessarily) a folder. The relationship between folders and quotaroots depends on the IMAP server. Some servers might implement a single quotaroot for all folders owned by a user. Other servers might implement a separate quotaroot for each folder. A single folder can even have multiple quotaroots, perhaps controlling quotas for different resources.

Returns
  • array of Quota objects for the quotaroots associated with this folder
Throws
MessagingException if the server doesn't support the QUOTA extension

public synchronized char getSeparator ()

Get the separator character.

Returns
  • Hierarchy separator character

public synchronized Message[] getSortedMessages (SortTerm[] term, SearchTerm sterm)

Sort the messages in the folder according to the sort criteria. The messages are returned in the sorted order, but the order of the messages in the folder is not changed. Only messages matching the search criteria are considered.

Parameters
term
sterm

public synchronized Message[] getSortedMessages (SortTerm[] term)

Sort the messages in the folder according to the sort criteria. The messages are returned in the sorted order, but the order of the messages in the folder is not changed.

Parameters
term

public synchronized int getType ()

Get the type of this folder.

Returns
  • integer with appropriate bits set

public synchronized long getUID (Message message)

Get the UID for the specified message.

Parameters
message Message from this folder
Returns
  • UID for this message

public synchronized long getUIDNext ()

Returns the predicted UID that will be assigned to the next message that is appended to this folder. If the folder is closed, the STATUS command is used to retrieve this value. If the folder is open, the value returned from the SELECT or EXAMINE command is returned. Note that messages may have been appended to the folder while it was open and thus this value may be out of date.

Servers implementing RFC2060 likely won't return this value when a folder is opened. Servers implementing RFC3501 should return this value when a folder is opened.

Returns
  • the UIDNEXT value, or -1 if unknown

public synchronized long getUIDValidity ()

Returns the UIDValidity for this folder.

Returns
  • UIDValidity

public synchronized int getUnreadMessageCount ()

Get the unread message count.

Returns
  • total number of unread messages. -1 may be returned by certain implementations if this method is invoked on a closed folder.

public void handleResponse (Response r)

The response handler. This is the callback routine that is invoked by the protocol layer.

Parameters
r

public synchronized boolean hasNewMessages ()

Check whether this folder has new messages.

Returns
  • true if the Store has new Messages

public void idle (boolean once)

Like idle(), but if once is true, abort the IDLE command after the first notification, to allow the caller to process any notification synchronously.

Parameters
once
Throws
MessagingException if the server doesn't support the IDLE extension
IllegalStateException if the folder isn't open

public void idle ()

Use the IMAP IDLE command (see RFC 2177), if supported by the server, to enter idle mode so that the server can send unsolicited notifications of new messages arriving, etc. without the need for the client to constantly poll the server. Use an appropriate listener to be notified of new messages or other events. When another thread (e.g., the listener thread) needs to issue an IMAP comand for this folder, the idle mode will be terminated and this method will return. Typically the caller will invoke this method in a loop.

The mail.imap.minidletime property enforces a minimum delay before returning from this method, to ensure that other threads have a chance to issue commands before the caller invokes this method again. The default delay is 10 milliseconds.

Throws
MessagingException if the server doesn't support the IDLE extension
IllegalStateException if the folder isn't open

public synchronized boolean isOpen ()

Check whether this connection is really open.

Returns
  • true if this GmailFolder is in the 'open' state.

public synchronized boolean isSubscribed ()

Check whether this folder is subscribed.

Returns
  • true if this GmailFolder is subscribed

public Folder[] list (String pattern)

List all subfolders matching the specified pattern.

Parameters
pattern The match pattern
Returns
  • array of matching GmailFolder objects. An empty array is returned if no matching Folders exist.

public Rights[] listRights (String name)

Get all the rights that may be allowed to the given identifier. Rights are grouped per RFC 2086 and each group is returned as an element of the array. The first element of the array is the set of rights that are always granted to the identifier. Later elements are rights that may be optionally granted to the identifier.

Note that this method lists the rights that it is possible to assign to the given identifier, not the rights that are actually granted to the given identifier. For the latter, see the getACL method.

Parameters
name The identifier to list rights for
Returns
  • array of Rights objects representing possible rights for the identifier
Throws
MessagingException if the server doesn't support the ACL extension

public Folder[] listSubscribed (String pattern)

List all subscribed subfolders matching the specified pattern.

Parameters
pattern The match pattern
Returns
  • array of matching subscribed GmailFolder objects. An empty array is returned if no matching subscribed folders exist.

public Rights myRights ()

Get the rights allowed to the currently authenticated user.

Returns
  • the rights granted to the current user
Throws
MessagingException if the server doesn't support the ACL extension

public synchronized void open (int mode)

Open this folder in the given mode.

Parameters
mode Open the GmailFolder READ_ONLY or READ_WRITE

public void removeACL (String name)

Remove any access control list entry for the given identifier from the access control list for this folder.

Parameters
name The identifier for which to remove all ACL entries
Throws
MessagingException if the server doesn't support the ACL extension

public void removeRights (ACL acl)

Remove the rights specified in the ACL from the entry for the identifier specified in the ACL.

Parameters
acl The identifer and rights to remove
Throws
MessagingException if the server doesn't support the ACL extension

public synchronized boolean renameTo (Folder f)

Rename this folder.

Parameters
f A folder representing the new name for this GmailFolder
Returns
  • true if the GmailFolder is renamed successfully

public synchronized Message[] search (SearchTerm term)

Search whole folder for messages matching the given term.

Parameters
term The search criterion
Returns
  • array of matching messages

public synchronized Message[] search (SearchTerm term, Message[] msgs)

Search the folder for messages matching the given term. Returns array of matching messages. Returns an empty array if no matching messages are found.

Parameters
term The search criterion
msgs The messages to be searched
Returns
  • array of matching messages

public synchronized void setFlags (Message[] msgs, Flags flag, boolean value)

Set the specified flags for the given array of messages.

Parameters
msgs The array of message objects
flag Flags object containing the flags to be set
value Set the flags to this boolean value

public synchronized void setGoogleMessageLabels (Message[] msgs, String[] labels, boolean value)

Parameters
msgs
labels
value

public void setQuota (Quota quota)

Set the quotas for the quotaroot specified in the quota argument. Typically this will be one of the quotaroots associated with this folder, as obtained from the getQuota method, but it need not be.

Parameters
quota The quota to set
Throws
MessagingException if the server doesn't support the QUOTA extension

public synchronized void setSubscribed (boolean subscribe)

Subscribe/Unsubscribe this folder.

Parameters
subscribe True to subscribe, false to unsubscribe

public Folder[] xlist (String pattern)

Parameters
pattern

Protected Methods

protected void checkClosed ()

protected void checkExists ()

protected void checkOpened ()

protected void checkRange (int msgno)

Parameters
msgno

protected Object doProtocolCommand (IMAPFolder.ProtocolCommand cmd)

Parameters
cmd

protected IMAPMessage getMessageBySeqNumber (int seqnum)

Get the message object for the given sequence number. If none found, null is returned. ASSERT: This method must be called only when holding the messageCacheLock

Parameters
seqnum

protected IMAPProtocol getProtocol ()

Return the IMAPProtocol object for this folder.

This method will block if necessary to wait for an IDLE command to finish.

Returns
  • the IMAPProtocol object used when the folder is open

protected synchronized IMAPProtocol getStoreProtocol ()

Get this folder's Store's protocol connection. When acquiring a store protocol object, it is important to use the following steps: IMAPProtocol p = null; try { p = getStoreProtocol(); // perform the command } catch (WhateverException ex) { // handle it } finally { releaseStoreProtocol(p); }

protected void keepConnectionAlive (boolean keepStoreAlive)

Issue a noop command for the connection if the connection has not been used in more than a second. If keepStoreAlive is true, also issue a noop over the store's connection. ASSERT: This method must be called only when holding the messageCacheLock

Parameters
keepStoreAlive

protected void releaseProtocol (boolean returnToPool)

Release the protocol object. ASSERT: This method must be called only when holding the messageCacheLock

Parameters
returnToPool

protected synchronized void releaseStoreProtocol (IMAPProtocol p)

Release the store protocol object. If we borrowed a protocol object from the connection pool, give it back. If we used our own protocol object, nothing to do.

Parameters
p

protected synchronized void throwClosedException (ConnectionException cex)

Throw the appropriate 'closed' exception.

Parameters
cex