⇒ Index (Frames) |  ⇒ Index (No Frames) |  ⇒ Package |  ⇒ Package Tree |  ⇒ Full Tree 
gnu.mail.providers.mbox

Class MboxFolder

java.lang.Object
|
+--javax.mail.Folder
   |
   +--gnu.mail.providers.mbox.MboxFolder


public class MboxFolder
extends Folder

The folder class implementing a UNIX mbox-format mailbox.
Author:

Constructor Summary

MboxFolder(Store store, String filename, boolean inbox)

Constructor.

MboxFolder(Store store, String filename)

Constructor.

Method Summary

synchronized boolean

acquireLock()

Locks this mailbox.

synchronized void

appendMessages(Message m)

Appends messages to this folder.

void

close(boolean expunge)

Closes this folder.

boolean

create(int type)

Creates this folder in the store.

static String

decodeFrom(String line)

Returns the specified line with any From_ line encoding removed.

boolean

delete(boolean recurse)

Deletes this folder.

boolean

exists()

Indicates whether this folder exists.

Message[]

expunge()

Expunges this folder.

String

fromLine(MboxMessage message)

Returns the From_ line for the specified mbox message.

Folder

getFolder(String filename)

Returns the subfolder of this folder with the specified name.

String

getFullName()

Returns the full name of this folder.

Message

getMessage(int msgnum)

Returns the specified message number from this folder.

int

getMessageCount()

Returns the number of messages in this folder.

synchronized Message[]

getMessages()

Returns the messages in this folder.

String

getName()

Returns the name of this folder.

Folder

getParent()

Returns the parent folder.

Flags

getPermanentFlags()

Returns the permanent flags for this folder.

char

getSeparator()

Returns the separator character.

int

getType()

Returns the type of this folder.

URLName

getURLName()

Return a URLName representing this folder.

boolean

hasNewMessages()

Indicates whether this folder contains new messages.

boolean

isOpen()

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.

void

open(int mode)

Opens this folder.

synchronized boolean

releaseLock()

Unlocks this mailbox.

boolean

renameTo(Folder folder)

Renames this folder.

Constructor Details

MboxFolder

protected MboxFolder(Store store, String filename)

Constructor.

Parameters:
store
filename

MboxFolder

protected MboxFolder(Store store, String filename, boolean inbox)

Constructor.

Parameters:
store
filename
inbox

Method Details

acquireLock

public synchronized 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 synchronized 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.

Parameters:
type

decodeFrom

public static String decodeFrom(String line)

Returns the specified line with any From_ line encoding removed.

Parameters:
line

delete

public boolean delete(boolean recurse)

Deletes this folder.

Parameters:
recurse

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.

Parameters:
message

getFolder

public Folder getFolder(String filename)

Returns the subfolder of this folder with the specified name.

Parameters:
filename

getFullName

public String getFullName()

Returns the full name of this folder.


getMessage

public Message getMessage(int msgnum)

Returns the specified message number from this folder.

Parameters:
msgnum
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 synchronized 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.

Parameters:
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.

Parameters:
mode
Throws:
MessagingException - if a messaging error occurred

releaseLock

public synchronized 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.

Parameters:
folder