All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.network.mail.base.Folder

java.lang.Object
   |
   +----com.ibm.network.mail.base.Folder

public class Folder
extends Object
implements Serializable
Folder is a class that represents a folder for storing mail messages. A folder stores its essages in a text file under the specified directory. If the name of the file is not specified, it uses default of 'messages'.

Folders are created using one of two forms of the factory method createFolder().

The name of the folder can be any valid string. But three names represented by the static constant attributes INBOX, TRASH and SENT are reserved. INBOX represents the default folder for all new messages. TRASH represents the folder where all the deleted messages are stored. TRASH can be emptied by using expunge(). SENT represents the folder where all the sent messages are stored.

When the folder is deserialized from the persistent stream, it contains a list of SummaryHeaders. Messages are retrieved from the folder file only when user actually wants to see them. Once the message has been retrieved, any subsequent request for displaying the message will be handled by the SummaryHeader directly without having to read it again from the folder file.

Author:
Abdul Majeed Ghadialy, Mohit M Sant
See Also:
MimeMessage, SummaryHeader

Variable Index

 o INBOX
Default folder for new messages.
 o SENT
Default folder for messages sent.
 o TRASH
Default folder for deleted messages.

Constructor Index

 o Folder()
Constructor for Folder.

Method Index

 o addMessage(MimeMessage)
Adds a message to the folder.
 o close()
Closes the folder, the folder file's contents are flushed and the file is closed.
 o createFolder(String, String)
Factory method to create a new Folder with given folder name and directory name.
 o createFolder(String, String, String)
Factory method to create a new Folder with given folder name and directory name and the file name which will contain messages.
 o deleteAll()
Deletes all the messages in this folder.
 o deleteMessage(SummaryHeader)
Deletes the specified message.
 o expunge()
Empties this Folder.
 o finalize()
Finalize method which invokes close().
 o getMessage(SummaryHeader)
Returns the specified message.
 o getName()
Returns the name of this Folder.
 o getSummaryHeaders()
Returns an enumeration of the SummaryHeaders in this folder.
 o list()
Returns the list of all folders.
 o moveMessage(SummaryHeader, Folder)
Moves a message from one folder to another.
 o open()
Opens this folder.
 o registerDeserializedFolder(Folder)
Registers a deserialized folder.
 o setDirectoryName(String)
Sets the directory for this folder.

Variables

 o INBOX
 public static final String INBOX
Default folder for new messages.

 o TRASH
 public static final String TRASH
Default folder for deleted messages.

 o SENT
 public static final String SENT
Default folder for messages sent.

Constructors

 o Folder
 public Folder()
Constructor for Folder. This constructor is ONLY for Serialization/Deserialization and should not be used by the developers.

Methods

 o addMessage
 public synchronized SummaryHeader addMessage(MimeMessage msg) throws IOException
Adds a message to the folder. The message is actually written to the folder file and a summary of the message is returned. This summary can be shown in a user interface.

Parameters:
msg - the message to be added.
Returns:
a summaryHeader object containing a summary of the message.
 o close
 public synchronized void close()
Closes the folder, the folder file's contents are flushed and the file is closed.

 o createFolder
 public static Folder createFolder(String folder,
                                   String directory)
Factory method to create a new Folder with given folder name and directory name. A file named 'messages' will be created under the specified directory, if not already present. This file will hold the messages in this Folder. One more file with the name specified in folder parameter will be created under the directory specified in directory parameter. This file will contain the SummaryHeader objects for the messages in the folder.

Parameters:
folder - name of the new Folder.
directory - full path to the directory which will hold the folder file.
Returns:
the newly created Folder.
 o createFolder
 public static Folder createFolder(String folder,
                                   String directory,
                                   String file)
Factory method to create a new Folder with given folder name and directory name and the file name which will contain messages. A file with the name specified in file parameter will be created under the specified directory, if not already present. This file will hold the messages in this Folder. One more file with the name specified in folder parameter will be created under the the directory specified in directory parameter. This file will contain the SummaryHeader objects for the messages in the folder.

Parameters:
folder - name of the new Folder.
directory - full path to the directory to hold the folder file.
file - name of the file to hold messages.
Returns:
the newly created Folder.
 o deleteAll
 public synchronized void deleteAll()
Deletes all the messages in this folder.

 o deleteMessage
 public synchronized void deleteMessage(SummaryHeader hdr)
Deletes the specified message.

Parameters:
hdr - SummaryHeader of the message to be deleted.
 o expunge
 public synchronized void expunge()
Empties this Folder.

 o finalize
 public void finalize()
Finalize method which invokes close().

Overrides:
finalize in class Object
 o getMessage
 public synchronized MimeMessage getMessage(SummaryHeader hdr)
Returns the specified message. The Folder reads the message from the folder file. Sets the message in the hdr using setMessage in SummaryHeader and returns the message.

Parameters:
hdr - SummaryHeader identifying the MimeMessage.
Returns:
the message identified by hdr.
 o getName
 public String getName()
Returns the name of this Folder.

Returns:
name of this Folder.
 o getSummaryHeaders
 public synchronized Enumeration getSummaryHeaders()
Returns an enumeration of the SummaryHeaders in this folder.

Returns:
an enumeration of the SummaryHeaders in this folder
 o list
 public static Vector list()
Returns the list of all folders.

Returns:
a vector of all folders.
 o moveMessage
 public synchronized void moveMessage(SummaryHeader header,
                                      Folder target)
Moves a message from one folder to another. This is a convenience method for achieving it with the use of a SummaryHeader.

Parameters:
target - destination folder.
 o open
 public synchronized void open() throws IOException
Opens this folder.

 o registerDeserializedFolder
 public static void registerDeserializedFolder(Folder folder)
Registers a deserialized folder. This method is to be called after a folder has been deserialized. Before calling this, a folder with the same name must be created by invoking createFolder().

Parameters:
folder - the deserialized folder.
 o setDirectoryName
 public synchronized void setDirectoryName(String directory)
Sets the directory for this folder. The folder file is moved to this new directory. Hence, if the folder file contained messages prior to moving, they are preserved.

Parameters:
directory - full path to the destination directory.

All Packages  Class Hierarchy  This Package  Previous  Next  Index