⇒ Index (Frames) |  ⇒ Index (No Frames) |  ⇒ Package |  ⇒ Package Tree |  ⇒ Full Tree 
javax.mail

Class Store

java.lang.Object
|
+--javax.mail.Service
   |
   +--javax.mail.Store

Known Direct Subclasses:
IMAPStore, MaildirStore, MboxStore, NNTPStore, POP3Store


public abstract class Store
extends Service

An abstract class that models a message store and its access protocol, for storing and retrieving messages. Subclasses provide actual implementations.

Note that Store extends the Service class, which provides many common methods for naming stores, connecting to stores, and listening to connection events.

Author:

Constructor Summary

Store(Session session, URLName url)

Constructor.

Method Summary

void

addFolderListener(FolderListener l)

Add a listener for Folder events on any Folder object obtained from this Store.

void

addStoreListener(StoreListener l)

Add a listener for StoreEvents on this Store.

Folder

getDefaultFolder()

Returns a Folder object that represents the 'root' of the default namespace presented to the user by the Store.

Folder

getFolder(String name)

Return the Folder object corresponding to the given name.

Folder

getFolder(URLName url)

Return a closed Folder object, corresponding to the given URLName.

Folder[]

getPersonalNamespaces()

Return a set of folders representing the personal namespaces for the current user.

Folder[]

getSharedNamespaces()

Return a set of folders representing the shared namespaces.

Folder[]

getUserNamespaces(String user)

Return a set of folders representing the namespaces for user.

void

notifyFolderListeners(int type, Folder folder)

Notify all FolderListeners.

void

notifyFolderRenamedListeners(Folder oldFolder, Folder newFolder)

Notify all FolderListeners about the renaming of a folder.

void

notifyStoreListeners(int type, String message)

Notify all StoreListeners.

void

removeFolderListener(FolderListener l)

Remove a listener for Folder events.

void

removeStoreListener(StoreListener l)

Remove a listener for Store events.

Constructor Details

Store

protected Store(Session session, URLName url)

Constructor.

Parameters:
session - Session object for this Store.
url - URLName object to be used for this Store

Method Details

addFolderListener

public void addFolderListener(FolderListener l)

Add a listener for Folder events on any Folder object obtained from this Store. FolderEvents are delivered to FolderListeners on the affected Folder as well as to FolderListeners on the containing Store.

Parameters:
l

addStoreListener

public void addStoreListener(StoreListener l)

Add a listener for StoreEvents on this Store.

Parameters:
l

getDefaultFolder

public Folder getDefaultFolder()

Returns a Folder object that represents the 'root' of the default namespace presented to the user by the Store.

Throws:
- if this Store is not connected.

getFolder

public Folder getFolder(String name)

Return the Folder object corresponding to the given name. Note that a Folder object is returned even if the named folder does not physically exist on the Store. The exists() method on the folder object indicates whether this folder really exists.

Folder objects are not cached by the Store, so invoking this method on the same name multiple times will return that many distinct Folder objects.

Parameters:
name - The name of the Folder.
Throws:
- if this Store is not connected.

getFolder

public Folder getFolder(URLName url)

Return a closed Folder object, corresponding to the given URLName. The store specified in the given URLName should refer to this Store object.

Implementations of this method may obtain the name of the actual folder using the getFile() method on URLName, and use that name to create the folder.

Parameters:
url - URLName that denotes a folder
Throws:
- if this Store is not connected.

getPersonalNamespaces

public Folder[] getPersonalNamespaces()

Return a set of folders representing the personal namespaces for the current user. A personal namespace is a set of names that is considered within the personal scope of the authenticated user. Typically, only the authenticated user has access to mail folders in their personal namespace. If an INBOX exists for a user, it must appear within the user's personal namespace. In the typical case, there should be only one personal namespace for each user in each Store.

This implementation returns an array with a single entry containing the return value of the getDefaultFolder method. Subclasses should override this method to return appropriate information.


getSharedNamespaces

public Folder[] getSharedNamespaces()

Return a set of folders representing the shared namespaces. A shared namespace is a namespace that consists of mail folders that are intended to be shared amongst users and do not exist within a user's personal namespace.

This implementation returns an empty array. Subclasses should override this method to return appropriate information.


getUserNamespaces

public Folder[] getUserNamespaces(String user)

Return a set of folders representing the namespaces for user. The namespaces returned represent the personal namespaces for the user. To access mail folders in the other user's namespace, the currently authenticated user must be explicitly granted access rights. For example, it is common for a manager to grant to their secretary access rights to their mail folders.

This implementation returns an empty array. Subclasses should override this method to return appropriate information.

Parameters:
user

notifyFolderListeners

protected void notifyFolderListeners(int type, Folder folder)

Notify all FolderListeners. Store implementations are expected to use this method to broadcast Folder events.

Parameters:
type
folder

notifyFolderRenamedListeners

protected void notifyFolderRenamedListeners(Folder oldFolder, Folder newFolder)

Notify all FolderListeners about the renaming of a folder. Store implementations are expected to use this method to broadcast Folder events indicating the renaming of folders.

Parameters:
oldFolder
newFolder

notifyStoreListeners

protected void notifyStoreListeners(int type, String message)

Notify all StoreListeners. Store implementations are expected to use this method to broadcast StoreEvents.

Parameters:
type
message

removeFolderListener

public void removeFolderListener(FolderListener l)

Remove a listener for Folder events.

Parameters:
l

removeStoreListener

public void removeStoreListener(StoreListener l)

Remove a listener for Store events.

Parameters:
l