Top Description Inners Fields Constructors Methods
com.sun.mail.imap

public Class IMAPStore

extends Store
implements QuotaAwareStore, ResponseHandler
Class Inheritance
All Implemented Interfaces
com.sun.mail.iap.ResponseHandler, javax.mail.QuotaAwareStore
Known Direct Subclasses
com.sun.mail.imap.IMAPSSLStore
Imports
java.lang.reflect.*, java.util.Vector, .StringTokenizer, .Locale, .Properties, .Map, .HashMap, .ArrayList, .List, java.io.IOException, java.net.InetAddress, .UnknownHostException, java.util.logging.Level, javax.mail.*, javax.mail.event.*, com.sun.mail.iap.*, com.sun.mail.imap.protocol.*, com.sun.mail.util.PropUtil, .MailLogger, .SocketConnectException, .MailConnectException

This class provides access to an IMAP message store.

Applications that need to make use of IMAP-specific features may cast a Store object to an IMAPStore 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 id method supports the IMAP ID extension; see RFC 2971. The fields ID_NAME, ID_VERSION, etc. represent the suggested field names in RFC 2971 section 3.3 and may be used as keys in the Map containing client values or server values.

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.

Authors
John Mani, Bill Shannon, Jim Glennon

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
private final int
protected String
private final int
private boolean
private volatile boolean
private final Object
private boolean
private boolean
protected final int
private boolean
private boolean
private boolean
private boolean
private boolean
private boolean
private volatile Constructor<?>
private volatile Constructor<?>
private volatile boolean
private boolean
private String
protected String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
private boolean
protected final boolean
protected MailLogger
private boolean
private final int
protected final String
private Namespaces
private ResponseHandler
nonStoreResponseHandler

A special response handler for connections that are being used to perform operations on behalf of an object other than the Store.

protected String
private boolean
private final IMAPStore.ConnectionPool
private volatile int
protected String
private boolean
public static final int
RESPONSE

A special event type for a StoreEvent to indicate an IMAP response, if the mail.imap.enableimapevents property is set.

private String[]
protected String
private final int
private boolean
protected String
private boolean

Constructor Summary

AccessConstructor and Description
public
IMAPStore(Session
the Session
session
,
URLName
the URLName of this store
url
)

Constructor that takes a Session object and a URLName that represents a specific IMAP server.

protected
IMAPStore(Session
the Session
session
,
URLName
the URLName of this store
url
,
String
the protocol name for this store
name
,
boolean
use SSL?
isSSL
)

Constructor used by this class and by IMAPSSLStore subclass.

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean
allowReadOnlySelect()

If a SELECT succeeds, but indicates that the folder is READ-ONLY, and the user asked to open the folder READ_WRITE, do we allow the open to succeed?

private void
authenticate(IMAPProtocol
the IMAPProtocol object
p
,
String
the authorization ID
authzid
,
String
the user name
user
,
String
the password
password
)

Authenticate using one of the non-SASL mechanisms.

private void
private synchronized void
cleanup()

Cleanup before dying.

public synchronized void
close()

Overrides javax.mail.Service.close.

Implements java.lang.AutoCloseable.close.

Close this Store.
private void
closeAllFolders(boolean force)

Close all open Folders.

private void
emptyConnectionPool(boolean force)

Empty the connection pool.

protected void
finalize()

Overrides javax.mail.Service.finalize.

Stop the event dispatcher thread so the queue can be garbage collected.
pack-priv int
getAppendBufferSize()

Get the maximum size of a message to buffer for append.

pack-priv MailLogger
getConnectionPoolLogger()

Return the connection pool logger.

public synchronized Folder
getDefaultFolder()

Implements abstract javax.mail.Store.getDefaultFolder.

Get the default folder, representing the root of this user's namespace.
pack-priv int
getFetchBlockSize()

Get the block size to use for fetch requests on this Store.

public synchronized Folder
getFolder(String
The name of the Folder. In some Stores, name can be an absolute path if it starts with the hierarchy delimiter. Else it is interpreted relative to the 'root' of this namespace.
name
)

Implements abstract javax.mail.Store.getFolder.

Get named folder.
public synchronized Folder
getFolder(URLName
URLName that denotes a folder
url
)

Implements abstract javax.mail.Store.getFolder.

Get named folder.
pack-priv IMAPProtocol
getFolderStoreProtocol()

Get a store protocol object for use by a folder.

pack-priv boolean
getMessageCacheDebug()

Report whether message cache debugging is enabled.

pack-priv int
getMinIdleTime()

Get the minimum amount of time to delay when returning from idle.

private synchronized Namespaces
pack-priv boolean
getPeek()

Get the default "peek" value.

public Folder[]
getPersonalNamespaces()

Overrides javax.mail.Store.getPersonalNamespaces.

Using the IMAP NAMESPACE command (RFC 2342), return a set of folders representing the Personal namespaces.
pack-priv IMAPProtocol
public String

Returns:

the user name
getProxyAuthUser
()

Get the user name to be used with the PROXYAUTH command.

public synchronized Quota[]

Returns:

array of Quota objects
getQuota
(String
the name of the quota root
root
)

Implements javax.mail.QuotaAwareStore.getQuota.

Get the quotas for the named quota root.
pack-priv Session
getSession()

Hides javax.mail.Service.getSession.

Get a reference to the session.
public Folder[]
getSharedNamespaces()

Overrides javax.mail.Store.getSharedNamespaces.

Using the IMAP NAMESPACE command (RFC 2342), return a set of folders representing the Shared namespaces.
pack-priv int
getStatusCacheTimeout()

Get the number of milliseconds to cache STATUS response.

private IMAPProtocol
getStoreProtocol()

Get this Store's protocol connection.

public Folder[]
getUserNamespaces(String
the user name
user
)

Overrides javax.mail.Store.getUserNamespaces.

Using the IMAP NAMESPACE command (RFC 2342), return a set of folders representing the User's namespaces.
public void
pack-priv void
handleResponseCode(Response r)

Handle notifications and alerts.

public synchronized boolean

Returns:

true if the server supports this capability
hasCapability
(String
the capability string
capability
)

Return true if the specified capability string is in the list of capabilities the server announced.

pack-priv boolean
hasSeparateStoreConnection()

Report whether the separateStoreConnection is set.

public synchronized Map<String, String>

Returns:

a Map of keys and values identifying the server
id
(Map<String, String>
a Map of keys and values identifying the client
clientParams
)

Send the IMAP ID command (if supported by the server) and return the result from the server.

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 without the need for the client to constantly poll the server.

pack-priv boolean
ignoreBodyStructureSize()

Ignore the size reported in the BODYSTRUCTURE when fetching data?

public synchronized boolean
isConnected()

Overrides javax.mail.Service.isConnected.

Check whether this store is connected.
pack-priv boolean
isConnectionPoolFull()

Report whether the connection pool is full.

public synchronized boolean

Returns:

true if using SSL
isSSL
()

Does this IMAPStore use SSL when connecting to the server?

private void
private Folder[]
protected IMAPFolder

Returns:

the new IMAPFolder object
newIMAPFolder
(String
the full name of the folder
fullName
,
char
the separator character for the folder hierarchy
separator
,
Boolean
does this name represent a namespace?
isNamespace
)

Create an IMAPFolder object.

protected IMAPFolder

Returns:

the new IMAPFolder object
newIMAPFolder
(String
the full name of the folder
fullName
,
char
the separator character for the folder hierarchy
separator
)

Create an IMAPFolder object.

protected IMAPFolder

Returns:

the new IMAPFolder object
newIMAPFolder
(ListInfo
the ListInfo for the folder
li
)

Create an IMAPFolder object.

protected IMAPProtocol

Returns:

the new IMAPProtocol object
newIMAPProtocol
(String
the host name
host
,
int
the port number
port
)

Create an IMAPProtocol object connected to the host and port.

protected void
preLogin(IMAPProtocol
the IMAPProtocol connection
p
)

This method is called after the connection is made and TLS is started (if needed), but before any authentication is attempted.

protected synchronized boolean
protocolConnect(String
the name of the host to connect to
host
,
int
the port to use (-1 means use default port)
pport
,
String
the name of the user to login as
user
,
String
the user's password
password
)

Overrides javax.mail.Service.protocolConnect.

Implementation of protocolConnect().
private void
pack-priv void
releaseFolderStoreProtocol(IMAPProtocol protocol)

Release a store protocol object that was being used by a folder.

pack-priv void
releaseProtocol(IMAPFolder folder, IMAPProtocol protocol)

Release the protocol object back to the connection pool.

private void
releaseStoreProtocol(IMAPProtocol protocol)

Release the store connection.

public synchronized void
setPassword(String
the password for the store
password
)

Set the password that will be used for subsequent connections after this Store is first connected (for example, when creating a connection to open a Folder).

public void
setProxyAuthUser(String
the user name to set
user
)

Set the user name to be used with the PROXYAUTH command.

public synchronized void
setQuota(Quota
the quota to set
quota
)

Implements javax.mail.QuotaAwareStore.setQuota.

Set the quotas for the quota root specified in the quota argument.
public synchronized void
setUsername(String
the user name for the store
user
)

Set the user name that will be used for subsequent connections after this Store is first connected (for example, when creating a connection to open a Folder).

pack-priv boolean
throwSearchException()

Throw a SearchException if the search expression is too complex?

private void
timeoutConnections()

Check to see if it's time to shrink the connection pool.

private String
private String
private void
Inherited from javax.mail.Store:
addFolderListeneraddStoreListenernotifyFolderListenersnotifyFolderRenamedListenersnotifyStoreListenersremoveFolderListenerremoveStoreListener