|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.mail.Folder
public abstract class Folder
An abstract representation of a folder in a mail system; subclasses would implement Folders for each supported protocol.
Depending on protocol and implementation, folders may contain other folders, messages, or both as indicated by theHOLDS_FOLDERS
and HOLDS_MESSAGES
flags.
If the immplementation supports hierarchical folders, the format of folder names is
implementation dependent; however, components of the name are separated by the
delimiter character returned by getSeparator()
.
The case-insensitive folder name "INBOX" is reserved to refer to the primary folder
for the current user on the current server; not all stores will provide an INBOX
and it may not be available at all times.
Field Summary | |
---|---|
static int |
HOLDS_FOLDERS
Flag that indicates that a folder can contain other folders. |
static int |
HOLDS_MESSAGES
Flag that indicates that a folder can contain messages. |
protected int |
mode
The current mode of this folder. |
static int |
READ_ONLY
Flag indicating that this folder cannot be modified. |
static int |
READ_WRITE
Flag indictaing that this folder can be modified. |
protected Store |
store
The store that this folder is part of. |
Constructor Summary | |
---|---|
protected |
Folder(Store store)
Constructor that initializes the Store. |
Method Summary | |
---|---|
void |
addConnectionListener(ConnectionListener listener)
|
void |
addFolderListener(FolderListener listener)
|
void |
addMessageChangedListener(MessageChangedListener listener)
|
void |
addMessageCountListener(MessageCountListener listener)
|
abstract void |
appendMessages(Message[] messages)
Append the supplied messages to this folder. |
abstract void |
close(boolean expunge)
Close this folder; it must already be open. |
void |
copyMessages(Message[] messages,
Folder folder)
Copy the specified messages to another folder. |
abstract boolean |
create(int type)
Create a new folder capable of containing subfoldera and/or messages as determined by the type parameter. |
abstract boolean |
delete(boolean recurse)
Delete this folder and possibly any subfolders. |
abstract boolean |
exists()
Check to see if this folder physically exists in the store. |
abstract Message[] |
expunge()
Permanently delete all supplied messages that have the DELETED flag set from the Store. |
void |
fetch(Message[] messages,
FetchProfile profile)
Hint to the store to prefetch information on the supplied messaged. |
protected void |
finalize()
Unregisters all listeners. |
int |
getDeletedMessageCount()
Return the numbew of messages in this folder that have the Flag.DELETED flag set. |
abstract Folder |
getFolder(String name)
Get the Folder determined by the supplied name; if the name is relative then it is interpreted relative to this folder. |
abstract String |
getFullName()
Return the full absolute name of this folder. |
abstract Message |
getMessage(int index)
Retrieve the message with the specified index in this Folder; messages indices start at 1 not zero. |
abstract int |
getMessageCount()
Return the number of messages this folder contains. |
Message[] |
getMessages()
Retrieve all messages. |
Message[] |
getMessages(int[] ids)
Retrieve messages with the specified indices. |
Message[] |
getMessages(int start,
int end)
Retrieve messages with index between start and end inclusive |
int |
getMode()
Return the mode of this folder ass passed to open(int) , or -1 if
the folder is closed. |
abstract String |
getName()
Return the name of this folder. |
int |
getNewMessageCount()
Return the numbew of messages in this folder that have the Flag.RECENT flag set. |
abstract Folder |
getParent()
Return the parent for this folder; if the folder is at the root of a heirarchy this returns null. |
abstract Flags |
getPermanentFlags()
Get the flags supported by this folder. |
abstract char |
getSeparator()
Return the character used by this folder's Store to separate path components. |
Store |
getStore()
Return the store that this folder is part of. |
abstract int |
getType()
Return the type of this folder, indicating whether it can contain subfolders, messages, or both. |
int |
getUnreadMessageCount()
Return the numbew of messages in this folder that do not have the Flag.SEEN flag set. |
URLName |
getURLName()
Return the URLName for this folder, which includes the location of the store. |
abstract boolean |
hasNewMessages()
Check to see if this Folder conatins messages with the Flag.RECENT flag set. |
abstract boolean |
isOpen()
Indicates that the folder has been opened. |
boolean |
isSubscribed()
Determine if the user is subscribed to this Folder. |
Folder[] |
list()
Convenience method that invokes list(String) with the pattern "%". |
abstract Folder[] |
list(String pattern)
Return a list of folders from this Folder's namespace that match the supplied pattern. |
Folder[] |
listSubscribed()
Convenience method that invokes listSubscribed(String) with the pattern "%". |
Folder[] |
listSubscribed(String pattern)
Return a list of folders to which the user is subscribed and which match the supplied pattern. |
protected void |
notifyConnectionListeners(int type)
|
protected void |
notifyFolderListeners(int type)
|
protected void |
notifyFolderRenamedListeners(Folder newFolder)
|
protected void |
notifyMessageAddedListeners(Message[] messages)
|
protected void |
notifyMessageChangedListeners(int type,
Message message)
|
protected void |
notifyMessageRemovedListeners(boolean removed,
Message[] messages)
|
abstract void |
open(int mode)
Open this folder; the folder must be able to contain messages and must currently be closed. |
void |
removeConnectionListener(ConnectionListener listener)
|
void |
removeFolderListener(FolderListener listener)
|
void |
removeMessageChangedListener(MessageChangedListener listener)
|
void |
removeMessageCountListener(MessageCountListener listener)
|
abstract boolean |
renameTo(Folder newName)
Rename this folder; the folder must be closed. |
Message[] |
search(SearchTerm term)
Search this folder for messages matching the supplied search criteria. |
Message[] |
search(SearchTerm term,
Message[] messages)
Search the supplied messages for those that match the supplied criteria; messages must belong to this folder. |
void |
setFlags(int[] ids,
Flags flags,
boolean value)
Set flags on a set of messages to the supplied value. |
void |
setFlags(int start,
int end,
Flags flags,
boolean value)
Set flags on a range of messages to the supplied value. |
void |
setFlags(Message[] messages,
Flags flags,
boolean value)
Set flags on the messages to the supplied value; all messages must belong to this folder. |
void |
setSubscribed(boolean subscribed)
Set the user's subscription to this folder. |
String |
toString()
Returns the full name of this folder; if null, returns the value from the superclass. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int HOLDS_MESSAGES
public static final int HOLDS_FOLDERS
public static final int READ_ONLY
public static final int READ_WRITE
protected Store store
protected int mode
READ_ONLY
or READ_WRITE
;
otherwise is set to -1.
Constructor Detail |
---|
protected Folder(Store store)
store
- the store that this folder is part ofMethod Detail |
---|
public abstract String getName()
public abstract String getFullName()
public URLName getURLName() throws MessagingException
MessagingException
public Store getStore()
public abstract Folder getParent() throws MessagingException
MessagingException
public abstract boolean exists() throws MessagingException
MessagingException
- if there was a problem accessing the storepublic abstract Folder[] list(String pattern) throws MessagingException
pattern
- the pattern to search for
MessagingException
- if there was a problem accessing the storepublic Folder[] listSubscribed(String pattern) throws MessagingException
list(String)
method.
pattern
- the pattern to search for
MessagingException
- if there was a problem accessing the storepublic Folder[] list() throws MessagingException
list(String)
with the pattern "%".
MessagingException
- if there was a problem accessing the storepublic Folder[] listSubscribed() throws MessagingException
listSubscribed(String)
with the pattern "%".
MessagingException
- if there was a problem accessing the storepublic abstract char getSeparator() throws MessagingException
MessagingException
- if there was a problem accessing the storepublic abstract int getType() throws MessagingException
MessagingException
- if there was a problem accessing the storeHOLDS_FOLDERS
,
HOLDS_MESSAGES
public abstract boolean create(int type) throws MessagingException
CREATED FolderEvent
is sent to all FolderListeners registered with this Folder or with the Store.
type
- the type, indicating if this folder should contain subfolders, messages or both
MessagingException
- if there was a problem accessing the storepublic boolean isSubscribed()
public void setSubscribed(boolean subscribed) throws MessagingException
subscribed
- whether to subscribe to this Folder
MessagingException
- if there was a problem accessing the store
MethodNotSupportedException
- if the Store does not support subscriptionpublic abstract boolean hasNewMessages() throws MessagingException
Flag.RECENT
flag set.
This can be used when the folder is closed to perform a light-weight check for new mail;
to perform an incremental check for new mail the folder must be opened.
MessagingException
- if there was a problem accessing the storepublic abstract Folder getFolder(String name) throws MessagingException
name
- the name of the folder to return
MessagingException
- if there was a problem accessing the storepublic abstract boolean delete(boolean recurse) throws MessagingException
FolderEvent.DELETED
events are sent as appropriate.
If recurse is false, then the behaviour depends on the folder type and store
implementation as followd:
FolderEvent.DELETED
event is sent.FolderEvent.DELETED
event is sent; if the folder is not
empty then the delete fails and this method returns false.FolderEvent.DELETED
event is sent; if the folder does
contain subfolders then the implementation may choose from the following three
behaviors:
FolderEvent.DELETED
event, and then return true to indicate the delete was performed. Note this does
not delete the folder itself and the exists()
operation for this folder
will return true
recurse
- whether subfolders should be recursively deleted as well
MessagingException
- if there was a problem accessing the storepublic abstract boolean renameTo(Folder newName) throws MessagingException
FolderEvent.RENAMED
event is sent to
all listeners registered with this folder or with the store.
newName
- the new name for this folder
MessagingException
- if there was a problem accessing the storepublic abstract void open(int mode) throws MessagingException
ConnectionEvent.OPENED
event is sent to listeners registered
with this Folder.
Whether the Store allows multiple connections or if it allows multiple
writers is implementation defined.
mode
- READ_ONLY or READ_WRITE
MessagingException
- if there was a problem accessing the storepublic abstract void close(boolean expunge) throws MessagingException
ConnectionEvent.CLOSED
event is sent to all listeners registered
with this folder.
expunge
- whether to expunge all deleted messages
MessagingException
- if there was a problem accessing the store; the folder is still closedpublic abstract boolean isOpen()
public int getMode()
open(int)
, or -1 if
the folder is closed.
public abstract Flags getPermanentFlags()
Flags
public abstract int getMessageCount() throws MessagingException
MessagingException
- if there was a problem accessing the storepublic int getNewMessageCount() throws MessagingException
Flag.RECENT
flag set.
If this operation is invoked on a closed folder, the implementation
may choose to return -1 to avoid the expense of opening the folder.
The default implmentation of this method iterates over all messages
in the folder; subclasses should override if possible to provide a more
efficient implementation.
MessagingException
- if there was a problem accessing the storepublic int getUnreadMessageCount() throws MessagingException
Flag.SEEN
flag set.
If this operation is invoked on a closed folder, the implementation
may choose to return -1 to avoid the expense of opening the folder.
The default implmentation of this method iterates over all messages
in the folder; subclasses should override if possible to provide a more
efficient implementation.
MessagingException
- if there was a problem accessing the storepublic int getDeletedMessageCount() throws MessagingException
Flag.DELETED
flag set.
If this operation is invoked on a closed folder, the implementation
may choose to return -1 to avoid the expense of opening the folder.
The default implmentation of this method iterates over all messages
in the folder; subclasses should override if possible to provide a more
efficient implementation.
MessagingException
- if there was a problem accessing the storepublic abstract Message getMessage(int index) throws MessagingException
Message
objects should be used as
references instead.
index
- the index of the message to fetch
MessagingException
- if there was a problem accessing the storepublic Message[] getMessages(int start, int end) throws MessagingException
start
- index of first messageend
- index of last message
MessagingException
- if there was a problem accessing the storepublic Message[] getMessages(int[] ids) throws MessagingException
ids
- the indices of the messages to fetch
MessagingException
- if there was a problem accessing the storepublic Message[] getMessages() throws MessagingException
MessagingException
- if there was a problem accessing the storepublic abstract void appendMessages(Message[] messages) throws MessagingException
MessageCountEvent
is sent
to all listeners registered with this folder when all messages have been appended.
If the array contains a previously expunged message, it must be re-appended to the Store
and implementations must not abort this operation.
messages
- the messages to append
MessagingException
- if there was a problem accessing the storepublic void fetch(Message[] messages, FetchProfile profile) throws MessagingException
messages
- messages for which information should be fetchedprofile
- the information to fetch
MessagingException
- if there was a problem accessing the storeFetchProfile
public void setFlags(Message[] messages, Flags flags, boolean value) throws MessagingException
Message.setFlags(Flags, boolean)
for each supplied messages.
messages
- whose flags should be setflags
- the set of flags to modifyvalue
- the value the flags should be set to
MessagingException
- if there was a problem accessing the storepublic void setFlags(int start, int end, Flags flags, boolean value) throws MessagingException
Message.setFlags(Flags, boolean)
.
start
- first message end setend
- last message end setflags
- the set of flags end modifyvalue
- the value the flags should be set end
MessagingException
- if there was a problem accessing the storepublic void setFlags(int[] ids, Flags flags, boolean value) throws MessagingException
Message.setFlags(Flags, boolean)
.
ids
- the indexes of the messages to setflags
- the set of flags end modifyvalue
- the value the flags should be set end
MessagingException
- if there was a problem accessing the storepublic void copyMessages(Message[] messages, Folder folder) throws MessagingException
appendMessages(Message[])
.
messages
- the messages to copyfolder
- the folder to copy to
MessagingException
- if there was a problem accessing the storepublic abstract Message[] expunge() throws MessagingException
MessageCountEvent
event is sent to all listeners with this folder. The expunge
may cause the indices of all messaged that remain in the folder to change.
MessagingException
- if there was a problem accessing the storepublic Message[] search(SearchTerm term) throws MessagingException
search(term, getMessages())
applying the search over all messages in the folder; subclasses may provide
a more efficient mechanism.
- Parameters:
term
- the search criteria
- Returns:
- an array containing messages that match the criteria
- Throws:
MessagingException
- if there was a problem accessing the store
public Message[] search(SearchTerm term, Message[] messages) throws MessagingException
Message.match(javax.mail.search.SearchTerm)
method returns true;
subclasses may provide a more efficient implementation.
term
- the search criteriamessages
- the messages to search
MessagingException
- if there was a problem accessing the storepublic void addConnectionListener(ConnectionListener listener)
public void removeConnectionListener(ConnectionListener listener)
protected void notifyConnectionListeners(int type)
public void addFolderListener(FolderListener listener)
public void removeFolderListener(FolderListener listener)
protected void notifyFolderListeners(int type)
protected void notifyFolderRenamedListeners(Folder newFolder)
public void addMessageCountListener(MessageCountListener listener)
public void removeMessageCountListener(MessageCountListener listener)
protected void notifyMessageAddedListeners(Message[] messages)
protected void notifyMessageRemovedListeners(boolean removed, Message[] messages)
public void addMessageChangedListener(MessageChangedListener listener)
public void removeMessageChangedListener(MessageChangedListener listener)
protected void notifyMessageChangedListeners(int type, Message message)
protected void finalize() throws Throwable
finalize
in class Object
Throwable
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |