gnu.mail.providers.mbox

Class MboxFolder

public class MboxFolder extends Folder

The folder class implementing a UNIX mbox-format mailbox.

Author: Chris Burdess

Constructor Summary
protected MboxFolder(Store store, File file, boolean inbox)
Constructor.
Method Summary
booleanacquireLock()
Locks this mailbox.
voidappendMessages(Message[] m)
Appends messages to this folder.
voidclose(boolean expunge)
Closes this folder.
booleancreate(int type)
Creates this folder in the store.
static StringdecodeFrom(String line)
Returns the specified line with any From_ line encoding removed.
booleandelete(boolean recurse)
Deletes this folder.
booleanexists()
Indicates whether this folder exists.
Message[]expunge()
Expunges this folder.
protected StringfromLine(MboxMessage message)
Returns the From_ line for the specified mbox message.
FoldergetFolder(String name)
Returns the subfolder of this folder with the specified name.
StringgetFullName()
Returns the full name of this folder.
MessagegetMessage(int msgnum)
Returns the specified message number from this folder.
intgetMessageCount()
Returns the number of messages in this folder.
Message[]getMessages()
Returns the messages in this folder.
StringgetName()
Returns the name of this folder.
FoldergetParent()
Returns the parent folder.
FlagsgetPermanentFlags()
Returns the permanent flags for this folder.
chargetSeparator()
Returns the separator character.
intgetType()
Returns the type of this folder.
URLNamegetURLName()
Return a URLName representing this folder.
booleanhasNewMessages()
Indicates whether this folder contains new messages.
booleanisOpen()
Indicates whether this folder is open.
Folder[]list()
Returns the subfolders of this folder.
Folder[]list(String pattern)
Returns the subfolders of this folder matching the specified pattern.
voidopen(int mode)
Opens this folder.
booleanreleaseLock()
Unlocks this mailbox.
booleanrenameTo(Folder folder)
Renames this folder.

Constructor Detail

MboxFolder

protected MboxFolder(Store store, File file, boolean inbox)
Constructor.

Method Detail

acquireLock

public boolean acquireLock()
Locks this mailbox. This uses a dotlock-like mechanism - see createNewFile(). If the directory containing the mbox folder is not writable, we will not be able to open the mbox for writing either.

appendMessages

public void appendMessages(Message[] m)
Appends messages to this folder. Only MimeMessages within the array will be appended, as we don't know how to retrieve internet content for other kinds.

Parameters: m an array of messages to be appended

close

public void close(boolean expunge)
Closes this folder.

Parameters: expunge if the folder is to be expunged before it is closed

Throws: MessagingException if a messaging error occurred

create

public boolean create(int type)
Creates this folder in the store.

decodeFrom

public static String decodeFrom(String line)
Returns the specified line with any From_ line encoding removed.

delete

public boolean delete(boolean recurse)
Deletes this folder.

exists

public boolean exists()
Indicates whether this folder exists.

Throws: MessagingException if a messaging error occurred

expunge

public Message[] expunge()
Expunges this folder. This deletes all the messages marked as deleted.

Throws: MessagingException if a messaging error occurred

fromLine

protected String fromLine(MboxMessage message)
Returns the From_ line for the specified mbox message. If this does not already exist(the message was appended to the folder since it was last opened), we will attempt to generate a suitable From_ line for it.

getFolder

public Folder getFolder(String name)
Returns the subfolder of this folder with the specified name.

getFullName

public String getFullName()
Returns the full name of this folder. If the folder resides under the root hierarchy of this Store, the returned name is relative to the root. Otherwise an absolute name, starting with the hierarchy delimiter, is returned.

getMessage

public Message getMessage(int msgnum)
Returns the specified message number from this folder.

Throws: MessagingException if a messaging error occurred

getMessageCount

public int getMessageCount()
Returns the number of messages in this folder.

Throws: MessagingException if a messaging error occurred

getMessages

public Message[] getMessages()
Returns the messages in this folder.

Throws: MessagingException if a messaging error occurred

getName

public String getName()
Returns the name of this folder.

getParent

public Folder getParent()
Returns the parent folder.

getPermanentFlags

public Flags getPermanentFlags()
Returns the permanent flags for this folder.

getSeparator

public char getSeparator()
Returns the separator character.

getType

public int getType()
Returns the type of this folder.

Throws: MessagingException if a messaging error occurred

getURLName

public URLName getURLName()
Return a URLName representing this folder.

hasNewMessages

public boolean hasNewMessages()
Indicates whether this folder contains new messages.

Throws: MessagingException if a messaging error occurred

isOpen

public boolean isOpen()
Indicates whether this folder is open.

list

public Folder[] list()
Returns the subfolders of this folder.

list

public Folder[] list(String pattern)
Returns the subfolders of this folder matching the specified pattern.

open

public void open(int mode)
Opens this folder. If the folder is opened for writing, a lock must be acquired on the mbox. If this fails a MessagingException is thrown.

Throws: MessagingException if a messaging error occurred

releaseLock

public boolean releaseLock()
Unlocks this mailbox. This deletes any associated lockfile if it exists. It returns false if an existing lockfile could not be deleted.

renameTo

public boolean renameTo(Folder folder)
Renames this folder.
© Copyright 2003, 2004 The Free Software Foundation, All rights reserved