Package gnu.mail.providers.imap
Class IMAPFolder
- java.lang.Object
-
- javax.mail.Folder
-
- gnu.mail.providers.imap.IMAPFolder
-
- All Implemented Interfaces:
UIDFolder
public class IMAPFolder extends Folder implements UIDFolder
The folder class implementing the IMAP4rev1 mail protocol.- Author:
- Chris Burdess
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface javax.mail.UIDFolder
UIDFolder.FetchProfileItem
-
-
Field Summary
Fields Modifier and Type Field Description protected chardelimiterprotected intmessageCountprotected intnewMessageCountprotected java.lang.StringpathThe folder path.protected FlagspermanentFlagsprotected booleansubscribedprotected inttypeThe type of this folder (HOLDS_MESSAGES or HOLDS_FOLDERS).protected longuidValidity-
Fields inherited from class javax.mail.Folder
HOLDS_FOLDERS, HOLDS_MESSAGES, mode, READ_ONLY, READ_WRITE, store
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedIMAPFolder(Store store, java.lang.String path)Constructor.protectedIMAPFolder(Store store, java.lang.String path, char delimiter)Constructor.protectedIMAPFolder(Store store, java.lang.String path, int type, char delimiter)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddACL(ACL ace)Deprecated.this API will probably change incompatibly soonvoidaddRights(ACL ace)Deprecated.this API will probably change incompatibly soonvoidappendMessages(Message[] messages)Appends the specified set of messages to this folder.voidclose(boolean expunge)Closes this folder.booleancreate(int type)Create this folder.booleandelete(boolean flag)Delete this folder.booleanequals(java.lang.Object other)booleanexists()Indicates whether this folder exists.Message[]expunge()Expunges this folder.voidfetch(Message[] messages, FetchProfile fp)IMAP fetch routine.ACL[]getACL()Deprecated.this API will probably change incompatibly soonintgetDeletedMessageCount()Returns the number of deleted messages in this folder.FoldergetFolder(java.lang.String name)Returns a subfolder with the specified name.java.lang.StringgetFullName()Returns the full path of this folder.MessagegetMessage(int msgnum)Returns the specified message number from this folder.MessagegetMessageByUID(long uid)Returns the message corresponding to the given UID, ornullif no such message exists.intgetMessageCount()Returns the number of messages in this folder.intgetMessageCountByCriteria(java.lang.String criteria)Convenience method for returning the number of messages in the current folder that match the single criteria.Message[]getMessagesByUID(long[] uids)Returns the messages specified by the given UIDs.Message[]getMessagesByUID(long start, long end)Returns the messages in the given range.java.lang.StringgetName()Returns the name of this folder.intgetNewMessageCount()Returns the number of new messages in this folder.FoldergetParent()Returns the parent folder of this folder.FlagsgetPermanentFlags()Returns the permanent flags for this folder.org.jpackage.mail.inet.imap.Quota[]getQuota()Returns the quotas for this folder.chargetSeparator()Returns the path separator charcter.intgetType()Returns the type of this folder.longgetUID(Message message)Returns the UID for the specified message.longgetUIDValidity()Returns the UIDValidity value associated with this folder.intgetUnreadMessageCount()Returns the number of unread messages in this folder.booleanhasNewMessages()Indicates whether this folder contains new messages.booleanisOpen()Indicates whether this folder is open.booleanisSubscribed()Indicates whether this folder is subscribed.Folder[]list(java.lang.String pattern)Returns the subfolders for this folder.RightslistRights(java.lang.String name)Deprecated.this API will probably change incompatibly soonFolder[]listSubscribed(java.lang.String pattern)Returns the subscribed subfolders for this folder.RightsmyRights()Deprecated.this API will probably change incompatibly soonvoidopen(int mode)Opens this folder.voidremoveACL(java.lang.String name)Deprecated.this API will probably change incompatibly soonvoidremoveRights(ACL ace)Deprecated.this API will probably change incompatibly soonbooleanrenameTo(Folder folder)Rename this folder.Message[]search(SearchTerm term)IMAP search function.Message[]search(SearchTerm term, Message[] msgs)IMAP search function.voidsetSubscribed(boolean flag)Subscribe to or unsubscribe from this folder.-
Methods inherited from class javax.mail.Folder
addConnectionListener, addFolderListener, addMessageChangedListener, addMessageCountListener, copyMessages, getMessages, getMessages, getMessages, getMode, getStore, getURLName, list, listSubscribed, notifyConnectionListeners, notifyFolderListeners, notifyFolderRenamedListeners, notifyMessageAddedListeners, notifyMessageChangedListeners, notifyMessageRemovedListeners, removeConnectionListener, removeFolderListener, removeMessageChangedListener, removeMessageCountListener, setFlags, setFlags, setFlags, toString
-
-
-
-
Field Detail
-
path
protected java.lang.String path
The folder path.
-
type
protected int type
The type of this folder (HOLDS_MESSAGES or HOLDS_FOLDERS).
-
permanentFlags
protected Flags permanentFlags
-
delimiter
protected char delimiter
-
messageCount
protected int messageCount
-
newMessageCount
protected int newMessageCount
-
uidValidity
protected long uidValidity
-
subscribed
protected boolean subscribed
-
-
Constructor Detail
-
IMAPFolder
protected IMAPFolder(Store store, java.lang.String path)
Constructor.
-
IMAPFolder
protected IMAPFolder(Store store, java.lang.String path, char delimiter)
Constructor.
-
IMAPFolder
protected IMAPFolder(Store store, java.lang.String path, int type, char delimiter)
Constructor.
-
-
Method Detail
-
getName
public java.lang.String getName()
Returns the name of this folder.
-
getFullName
public java.lang.String getFullName()
Returns the full path of this folder.- Specified by:
getFullNamein classFolder
-
getType
public int getType() throws MessagingExceptionReturns the type of this folder.- Specified by:
getTypein classFolder- Throws:
MessagingException- if a messaging error occurred
-
exists
public boolean exists() throws MessagingExceptionIndicates whether this folder exists.- Specified by:
existsin classFolder- Throws:
MessagingException- if a messaging error occurred
-
hasNewMessages
public boolean hasNewMessages() throws MessagingExceptionIndicates whether this folder contains new messages.- Specified by:
hasNewMessagesin classFolder- Throws:
MessagingException- if a messaging error occurred
-
open
public void open(int mode) throws MessagingExceptionOpens this folder.- Specified by:
openin classFolder- Parameters:
mode- open the Folder READ_ONLY or READ_WRITE- Throws:
MessagingException- if a messaging error occurred
-
create
public boolean create(int type) throws MessagingExceptionCreate this folder.- Specified by:
createin classFolder- Parameters:
type- the desired type of the folder- Throws:
MessagingException
-
delete
public boolean delete(boolean flag) throws MessagingExceptionDelete this folder.- Specified by:
deletein classFolder- Parameters:
flag- delete any subfolders- Returns:
- true if the folder is deleted successfully, false otherwise
- Throws:
FolderNotFoundException- if this folder does not existMessagingException
-
renameTo
public boolean renameTo(Folder folder) throws MessagingException
Rename this folder.- Specified by:
renameToin classFolder- Parameters:
folder- a folder representing the new name for this folder- Returns:
- true if the folder is renamed successfully, false otherwise
- Throws:
FolderNotFoundException- if this folder does not existMessagingException
-
close
public void close(boolean expunge) throws MessagingExceptionCloses this folder.- Specified by:
closein classFolder- Parameters:
expunge- if the folder is to be expunged before it is closed- Throws:
MessagingException- if a messaging error occurred
-
expunge
public Message[] expunge() throws MessagingException
Expunges this folder. This deletes all the messages marked as deleted.- Specified by:
expungein classFolder- Throws:
MessagingException- if a messaging error occurred
-
isOpen
public boolean isOpen()
Indicates whether this folder is open.
-
getPermanentFlags
public Flags getPermanentFlags()
Returns the permanent flags for this folder.- Specified by:
getPermanentFlagsin classFolder
-
getMessageCount
public int getMessageCount() throws MessagingExceptionReturns the number of messages in this folder.- Specified by:
getMessageCountin classFolder- Throws:
MessagingException- if a messaging error occurred
-
getNewMessageCount
public int getNewMessageCount() throws MessagingExceptionReturns the number of new messages in this folder.- Overrides:
getNewMessageCountin classFolder- Throws:
MessagingException- if a messaging error occurred
-
getMessage
public Message getMessage(int msgnum) throws MessagingException
Returns the specified message number from this folder. The message is only retrieved once from the server. Subsequent getMessage() calls to the same message are cached. Since POP3 does not provide a mechanism for retrieving only part of the message(headers, etc), the entire message is retrieved.- Specified by:
getMessagein classFolder- Parameters:
msgnum- the message number- Throws:
MessagingException- if a messaging error occurred
-
appendMessages
public void appendMessages(Message[] messages) throws MessagingException
Appends the specified set of messages to this folder. OnlyMimeMessages are accepted.- Specified by:
appendMessagesin classFolder- Parameters:
messages- array of messages to be appended- Throws:
FolderNotFoundException- if this folder does not existMessagingException- if the append operation failed
-
fetch
public void fetch(Message[] messages, FetchProfile fp) throws MessagingException
IMAP fetch routine. This executes the fetch for the specified message numbers and updates the messages according to the message statuses returned.- Overrides:
fetchin classFolder- Parameters:
messages- the messages to fetch the items forfp- the fetch profile- Throws:
MessagingException
-
search
public Message[] search(SearchTerm term) throws MessagingException
IMAP search function.- Overrides:
searchin classFolder- Parameters:
term- the search term- Throws:
FolderNotFoundException- if this folder does not existMessagingException
-
search
public Message[] search(SearchTerm term, Message[] msgs) throws MessagingException
IMAP search function.- Overrides:
searchin classFolder- Parameters:
term- the search termmsgs- the messages to be searched- Throws:
MessagingException
-
isSubscribed
public boolean isSubscribed()
Description copied from class:FolderIndicates whether this folder is subscribed.This method can be invoked on a closed folder.
- Overrides:
isSubscribedin classFolder
-
setSubscribed
public void setSubscribed(boolean flag) throws MessagingExceptionDescription copied from class:FolderSubscribe to or unsubscribe from this folder. Not all Stores support subscription.This method can be invoked on a closed folder.
- Overrides:
setSubscribedin classFolder- Throws:
MessagingException
-
list
public Folder[] list(java.lang.String pattern) throws MessagingException
Returns the subfolders for this folder.- Specified by:
listin classFolder- Parameters:
pattern- the match pattern- Throws:
MessagingException
-
listSubscribed
public Folder[] listSubscribed(java.lang.String pattern) throws MessagingException
Returns the subscribed subfolders for this folder.- Overrides:
listSubscribedin classFolder- Parameters:
pattern- the match pattern- Throws:
MessagingException
-
getParent
public Folder getParent() throws MessagingException
Returns the parent folder of this folder.- Specified by:
getParentin classFolder- Throws:
MessagingException
-
getFolder
public Folder getFolder(java.lang.String name) throws MessagingException
Returns a subfolder with the specified name.- Specified by:
getFolderin classFolder- Parameters:
name- the name of the folder- Throws:
MessagingException
-
getSeparator
public char getSeparator() throws MessagingExceptionReturns the path separator charcter.- Specified by:
getSeparatorin classFolder- Throws:
MessagingException
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
getUIDValidity
public long getUIDValidity() throws MessagingExceptionDescription copied from interface:UIDFolderReturns the UIDValidity value associated with this folder.A client should compare this value against a UIDValidity value saved from a previous session to ensure that any cached UIDs are valid.
- Specified by:
getUIDValidityin interfaceUIDFolder- Throws:
MessagingException
-
getMessageByUID
public Message getMessageByUID(long uid) throws MessagingException
Description copied from interface:UIDFolderReturns the message corresponding to the given UID, ornullif no such message exists.- Specified by:
getMessageByUIDin interfaceUIDFolder- Parameters:
uid- the UID of the desired message- Throws:
MessagingException
-
getMessagesByUID
public Message[] getMessagesByUID(long start, long end) throws MessagingException
Description copied from interface:UIDFolderReturns the messages in the given range. The special value LASTUID can be used as theendparameter to indicate the last available UID.- Specified by:
getMessagesByUIDin interfaceUIDFolder- Parameters:
start- the start UIDend- the end UID- Throws:
MessagingException
-
getMessagesByUID
public Message[] getMessagesByUID(long[] uids) throws MessagingException
Description copied from interface:UIDFolderReturns the messages specified by the given UIDs. If any UID is invalid,nullis returned for that entry.The returned array will be of the same size as the specified UIDs.
- Specified by:
getMessagesByUIDin interfaceUIDFolder- Parameters:
uids- the UIDs- Throws:
MessagingException
-
getUID
public long getUID(Message message) throws MessagingException
Description copied from interface:UIDFolderReturns the UID for the specified message.- Specified by:
getUIDin interfaceUIDFolder- Parameters:
message- a message in this folder- Throws:
MessagingException
-
getQuota
public org.jpackage.mail.inet.imap.Quota[] getQuota() throws MessagingExceptionReturns the quotas for this folder.- Throws:
MessagingException
-
getUnreadMessageCount
public int getUnreadMessageCount() throws MessagingExceptionReturns the number of unread messages in this folder.- Overrides:
getUnreadMessageCountin classFolder- Throws:
MessagingException- See Also:
Folder.getUnreadMessageCount()
-
getDeletedMessageCount
public int getDeletedMessageCount() throws MessagingExceptionReturns the number of deleted messages in this folder.- Overrides:
getDeletedMessageCountin classFolder- Throws:
FolderNotFoundException- if this folder does not existMessagingException- See Also:
Folder.getDeletedMessageCount()
-
getMessageCountByCriteria
public int getMessageCountByCriteria(java.lang.String criteria) throws MessagingExceptionConvenience method for returning the number of messages in the current folder that match the single criteria.- Throws:
MessagingException
-
getACL
public ACL[] getACL() throws MessagingException
Deprecated.this API will probably change incompatibly soonReturns the access control list for this folder. This is an array of access control entries.- Throws:
MessagingException
-
addACL
public void addACL(ACL ace) throws MessagingException
Deprecated.this API will probably change incompatibly soonAdds the specified access control entry to this folder.- Parameters:
ace- the access control entry- Throws:
MessagingException
-
removeACL
public void removeACL(java.lang.String name) throws MessagingExceptionDeprecated.this API will probably change incompatibly soonRemoves the ACL for the given principal.- Parameters:
name- the name of the principal- Throws:
MessagingException
-
addRights
public void addRights(ACL ace) throws MessagingException
Deprecated.this API will probably change incompatibly soonAdds the rights for the specified access control entry.- Parameters:
ace- the access control entry- Throws:
MessagingException
-
removeRights
public void removeRights(ACL ace) throws MessagingException
Deprecated.this API will probably change incompatibly soonRemoves the rights specified in the given access control entry from the principal.- Parameters:
ace- the access control entry- Throws:
MessagingException
-
listRights
public Rights listRights(java.lang.String name) throws MessagingException
Deprecated.this API will probably change incompatibly soonReturns the rights currently assigned to the given principal.- Parameters:
name- the name of the principal- Throws:
MessagingException
-
myRights
public Rights myRights() throws MessagingException
Deprecated.this API will probably change incompatibly soonReturns the rights assigned to the currently authenticated principal.- Throws:
MessagingException
-
-