Package net.fortuna.mstor.connector
Interface FolderDelegate<T extends MessageDelegate>
-
- Type Parameters:
T- the type of message delegate supported
- All Known Implementing Classes:
AbstractFolderDelegate,AbstractMetaFolder,JcrFolder,MboxFolder,MetaFolder,NntpFolder,YamlMetaFolder
public interface FolderDelegate<T extends MessageDelegate>Implementors support delegation of specific functions fromMStorFolder.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description longallocateUid(MessageDelegate message)Allocates a new message UID for the folder.voidappendMessages(javax.mail.Message[] messages)Append the specified messages to this delegate.voidclose()Close the folder delegate.booleancreate(int type)Initialise the delegate based on the specified folder type.booleandelete()Delete the folder delegate.booleanexists()Indicates whether the folder represented by this delegate exists.voidexpunge(javax.mail.Message[] deleted)Permanently delete the specified messages from this delegate.intgetDeletedMessageCount()Optional support for more efficient implementation.FolderDelegate<T>getFolder(String name)Returns a child folder delegate with the specified name.StringgetFolderName()StringgetFullName()longgetLastModified()Returns the last modification timestamp of this folder.longgetLastUid()Retrieves the last allocated message UID for the folder.TgetMessage(int messageNumber)Returns message delegate corresponding to the specified message id.InputStreamgetMessageAsStream(int index)Returns an input stream from which to read the specified message.intgetMessageCount()Returns the number of messages in the folder delegate.FolderDelegate<T>getParent()chargetSeparator()intgetType()longgetUidValidity()Returns the UID validity associated with the metadata.FolderDelegate<T>[]list(String pattern)Returns a list of child folder delegates matching the specified pattern.voidopen(int mode)Open the folder delegate.booleanrenameTo(String name)Rename the folder delegate.
-
-
-
Method Detail
-
getFolderName
String getFolderName()
- Returns:
- Returns the name.
-
getFullName
String getFullName()
- Returns:
- the full name of the folder.
-
getParent
FolderDelegate<T> getParent()
- Returns:
- the parent folder delegate of this delegate.
-
exists
boolean exists()
Indicates whether the folder represented by this delegate exists.- Returns:
- true if the folder exists, otherwise false
-
getType
int getType()
- Returns:
- the type of folder this delegate represents.
- See Also:
Folder.HOLDS_FOLDERS,Folder.HOLDS_MESSAGES
-
list
FolderDelegate<T>[] list(String pattern)
Returns a list of child folder delegates matching the specified pattern.- Parameters:
pattern- a pattern to match folders against- Returns:
- a list of folder delegates
-
getSeparator
char getSeparator()
- Returns:
- the folder separator for this delegate type.
-
create
boolean create(int type) throws javax.mail.MessagingExceptionInitialise the delegate based on the specified folder type.- Parameters:
type- a folder type- Returns:
- true if the delegate is created, otherwise false
- Throws:
javax.mail.MessagingException- where an unexpected error occurs creating the delegate
-
getFolder
FolderDelegate<T> getFolder(String name) throws javax.mail.MessagingException
Returns a child folder delegate with the specified name.- Parameters:
name- a folder name- Returns:
- the folder delegate with the specified name, or null if the folder doesn't exist
- Throws:
javax.mail.MessagingException- where an unexpected error occurs retrieving the folder
-
delete
boolean delete()
Delete the folder delegate.- Returns:
- true if the delegate is deleted, otherwise false
-
renameTo
boolean renameTo(String name)
Rename the folder delegate.- Parameters:
name- the new folder name- Returns:
- true if the folder is renamed, otherwise false
-
open
void open(int mode)
Open the folder delegate.- Parameters:
mode- the mode to open the folder- See Also:
Folder.READ_ONLY,Folder.READ_WRITE
-
close
void close() throws javax.mail.MessagingExceptionClose the folder delegate.- Throws:
javax.mail.MessagingException- where an unexpected error occurs closing the folder
-
getMessageCount
int getMessageCount() throws javax.mail.MessagingExceptionReturns the number of messages in the folder delegate.- Returns:
- the total message count
- Throws:
javax.mail.MessagingException- where an unexpected error occurs retrieving the message count
-
getDeletedMessageCount
int getDeletedMessageCount() throws javax.mail.MessagingException, UnsupportedOperationExceptionOptional support for more efficient implementation.- Returns:
- the total deleted message count
- Throws:
javax.mail.MessagingException- where an unexpected error occursUnsupportedOperationException- if this method is not supported by the folder implementation
-
getMessageAsStream
InputStream getMessageAsStream(int index) throws IOException
Returns an input stream from which to read the specified message.- Parameters:
index- the index of the message to return- Returns:
- an input stream for the specified message
- Throws:
IOException- where an error occurs
-
appendMessages
void appendMessages(javax.mail.Message[] messages) throws javax.mail.MessagingExceptionAppend the specified messages to this delegate.- Parameters:
messages- an array of messages to append to the folder- Throws:
javax.mail.MessagingException- where an error occurs appending the messages
-
expunge
void expunge(javax.mail.Message[] deleted) throws javax.mail.MessagingExceptionPermanently delete the specified messages from this delegate.- Parameters:
deleted- an array of deleted messages to expunge- Throws:
javax.mail.MessagingException- where an error occurs expunging the messages
-
getMessage
T getMessage(int messageNumber) throws DelegateException
Returns message delegate corresponding to the specified message id. If no delegate exists a new Message delegate is created.- Parameters:
messageNumber- the message number of the message to retrieve- Returns:
- the message with the specified message number, or null if the messages doesn't exist
- Throws:
DelegateException- where an error occurs retrieving the message
-
getLastUid
long getLastUid() throws UnsupportedOperationExceptionRetrieves the last allocated message UID for the folder.- Returns:
- the latest UID for the folder
- Throws:
UnsupportedOperationException- if this method is not supported by the folder implementation
-
allocateUid
long allocateUid(MessageDelegate message) throws UnsupportedOperationException, DelegateException
Allocates a new message UID for the folder.- Parameters:
message- the message to allocate a UID value to- Returns:
- the allocated UID for the specified message
- Throws:
DelegateException- where an error occurs allocating a UIDUnsupportedOperationException- if this method is not supported by the folder implementation
-
getUidValidity
long getUidValidity() throws UnsupportedOperationException, javax.mail.MessagingExceptionReturns the UID validity associated with the metadata. If no UID validity exist a new value is initialised.- Returns:
- a long representation of the UID validity
- Throws:
UnsupportedOperationException- if this method is not supported by the folder implementationjavax.mail.MessagingException- if an error occurs retrieving the validity value
-
getLastModified
long getLastModified() throws UnsupportedOperationExceptionReturns the last modification timestamp of this folder.- Returns:
- a timestamp as a long value
- Throws:
UnsupportedOperationException- if this method is not supported by the folder implementation
-
-