public abstract class Store extends Service
Note that Store
extends the Service
class, which provides many common methods for naming stores,
connecting to stores, and listening to connection events.
Service
,
ConnectionEvent
,
StoreEvent
Modifier | Constructor and Description |
---|---|
protected |
Store(Session session,
URLName urlname)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
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.
|
abstract Folder |
getDefaultFolder()
Returns a Folder object that represents the 'root' of
the default namespace presented to the user by the Store.
|
abstract Folder |
getFolder(java.lang.String name)
Return the Folder object corresponding to the given name.
|
abstract 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(java.lang.String user)
Return a set of folders representing the namespaces for
user . |
protected void |
notifyFolderListeners(int type,
Folder folder)
Notify all FolderListeners.
|
protected void |
notifyFolderRenamedListeners(Folder oldF,
Folder newF)
Notify all FolderListeners about the renaming of a folder.
|
protected void |
notifyStoreListeners(int type,
java.lang.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.
|
addConnectionListener, close, connect, connect, connect, connect, finalize, getURLName, isConnected, notifyConnectionListeners, protocolConnect, queueEvent, removeConnectionListener, setConnected, setURLName, toString
public abstract Folder getDefaultFolder() throws MessagingException
java.lang.IllegalStateException
- if this Store is not connected.MessagingException
- for other failurespublic abstract Folder getFolder(java.lang.String name) throws MessagingException
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.
name
- 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.java.lang.IllegalStateException
- if this Store is not connected.MessagingException
- for other failuresFolder.exists()
,
Folder.create(int)
public abstract Folder getFolder(URLName url) throws MessagingException
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.
url
- URLName that denotes a folderjava.lang.IllegalStateException
- if this Store is not connected.MessagingException
- for other failuresURLName
public Folder[] getPersonalNamespaces() throws MessagingException
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.
java.lang.IllegalStateException
- if this Store is not connected.MessagingException
- for other failurespublic Folder[] getUserNamespaces(java.lang.String user) throws MessagingException
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.
user
- the user namejava.lang.IllegalStateException
- if this Store is not connected.MessagingException
- for other failurespublic Folder[] getSharedNamespaces() throws MessagingException
This implementation returns an empty array. Subclasses should override this method to return appropriate information.
java.lang.IllegalStateException
- if this Store is not connected.MessagingException
- for other failurespublic void addStoreListener(StoreListener l)
The default implementation provided here adds this listener to an internal list of StoreListeners.
l
- the Listener for Store eventsStoreEvent
public void removeStoreListener(StoreListener l)
The default implementation provided here removes this listener from the internal list of StoreListeners.
l
- the listeneraddStoreListener(jakarta.mail.event.StoreListener)
protected void notifyStoreListeners(int type, java.lang.String message)
The provided default implementation queues the event into an internal event queue. An event dispatcher thread dequeues events from the queue and dispatches them to the registered StoreListeners. Note that the event dispatching occurs in a separate thread, thus avoiding potential deadlock problems.
type
- the StoreEvent typemessage
- a message for the StoreEventpublic void addFolderListener(FolderListener l)
The default implementation provided here adds this listener to an internal list of FolderListeners.
l
- the Listener for Folder eventsFolderEvent
public void removeFolderListener(FolderListener l)
The default implementation provided here removes this listener from the internal list of FolderListeners.
l
- the listeneraddFolderListener(jakarta.mail.event.FolderListener)
protected void notifyFolderListeners(int type, Folder folder)
The provided default implementation queues the event into an internal event queue. An event dispatcher thread dequeues events from the queue and dispatches them to the registered FolderListeners. Note that the event dispatching occurs in a separate thread, thus avoiding potential deadlock problems.
type
- type of FolderEventfolder
- affected FoldernotifyFolderRenamedListeners(jakarta.mail.Folder, jakarta.mail.Folder)
protected void notifyFolderRenamedListeners(Folder oldF, Folder newF)
The provided default implementation queues the event into an internal event queue. An event dispatcher thread dequeues events from the queue and dispatches them to the registered FolderListeners. Note that the event dispatching occurs in a separate thread, thus avoiding potential deadlock problems.
oldF
- the folder being renamednewF
- the folder representing the new name.