Package net.fortuna.mstor.connector.mbox
Class MboxFolder
- java.lang.Object
-
- net.fortuna.mstor.connector.AbstractFolderDelegate<MessageDelegate>
-
- net.fortuna.mstor.connector.mbox.MboxFolder
-
- All Implemented Interfaces:
FolderDelegate<MessageDelegate>
public class MboxFolder extends AbstractFolderDelegate<MessageDelegate>
-
-
Constructor Summary
Constructors Constructor Description MboxFolder(File file)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
appendMessages(javax.mail.Message[] messages)
Append the specified messages to this delegate.void
close()
Close the folder delegate.boolean
create(int type)
Initialise the delegate based on the specified folder type.protected MessageDelegate
createMessage(int messageNumber)
boolean
delete()
Delete the folder delegate.boolean
exists()
Indicates whether the folder represented by this delegate exists.void
expunge(javax.mail.Message[] deleted)
Permanently delete the specified messages from this delegate.FolderDelegate<MessageDelegate>
getFolder(String name)
Returns a child folder delegate with the specified name.String
getFolderName()
String
getFullName()
long
getLastModified()
Returns the last modification timestamp of this folder.long
getLastUid()
Retrieves the last allocated message UID for the folder.MessageDelegate
getMessage(int messageNumber)
Returns message delegate corresponding to the specified message id.InputStream
getMessageAsStream(int index)
Returns an input stream from which to read the specified message.int
getMessageCount()
Returns the number of messages in the folder delegate.FolderDelegate<MessageDelegate>
getParent()
char
getSeparator()
int
getType()
long
getUidValidity()
Returns the UID validity associated with the metadata.FolderDelegate<MessageDelegate>[]
list(String pattern)
Returns a list of child folder delegates matching the specified pattern.void
open(int mode)
Open the folder delegate.boolean
renameTo(String name)
Rename the folder delegate.protected void
setLastUid(long uid)
-
Methods inherited from class net.fortuna.mstor.connector.AbstractFolderDelegate
allocateUid, getDeletedMessageCount
-
-
-
-
Constructor Detail
-
MboxFolder
public MboxFolder(File file)
- Parameters:
file
- an mbox data file
-
-
Method Detail
-
getType
public final int getType()
- Returns:
- the type of folder this delegate represents.
- See Also:
Folder.HOLDS_FOLDERS
,Folder.HOLDS_MESSAGES
-
getFolderName
public final String getFolderName()
- Returns:
- Returns the name.
-
getFullName
public final String getFullName()
- Returns:
- the full name of the folder.
-
getParent
public final FolderDelegate<MessageDelegate> getParent()
- Returns:
- the parent folder delegate of this delegate.
-
getFolder
public final FolderDelegate<MessageDelegate> getFolder(String name)
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
-
list
public final FolderDelegate<MessageDelegate>[] 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
-
exists
public final boolean exists()
Indicates whether the folder represented by this delegate exists.- Returns:
- true if the folder exists, otherwise false
-
delete
public final boolean delete()
Delete the folder delegate.- Returns:
- true if the delegate is deleted, otherwise false
-
renameTo
public final boolean renameTo(String name)
Rename the folder delegate.- Parameters:
name
- the new folder name- Returns:
- true if the folder is renamed, otherwise false
-
open
public final 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
public final void close() throws javax.mail.MessagingException
Close the folder delegate.- Throws:
javax.mail.MessagingException
- where an unexpected error occurs closing the folder
-
getSeparator
public final char getSeparator()
- Returns:
- the folder separator for this delegate type.
-
getMessageCount
public final int getMessageCount() throws javax.mail.MessagingException
Returns 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
-
getMessageAsStream
public final 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
public final void appendMessages(javax.mail.Message[] messages) throws javax.mail.MessagingException
Append 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
-
create
public final boolean create(int type) throws javax.mail.MessagingException
Initialise 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
-
expunge
public final void expunge(javax.mail.Message[] deleted) throws javax.mail.MessagingException
Permanently 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
-
createMessage
protected MessageDelegate createMessage(int messageNumber)
- Specified by:
createMessage
in classAbstractFolderDelegate<MessageDelegate>
- Parameters:
messageNumber
- the message number to associate with the new message- Returns:
- a new message delegate instance
-
getMessage
public MessageDelegate getMessage(int messageNumber)
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
-
setLastUid
protected void setLastUid(long uid) throws UnsupportedOperationException
- Specified by:
setLastUid
in classAbstractFolderDelegate<MessageDelegate>
- Parameters:
uid
- the latest UID for the folder- Throws:
UnsupportedOperationException
- if this method is not supported in the folder delegate
-
getLastUid
public long getLastUid() throws UnsupportedOperationException
Retrieves 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
-
getUidValidity
public long getUidValidity() throws UnsupportedOperationException
Returns 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 implementation
-
getLastModified
public long getLastModified() throws UnsupportedOperationException
Returns 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
-
-