com.micromail
Class FolderWrapper

java.lang.Object
  extended bycom.micromail.FolderWrapper

public class FolderWrapper
extends java.lang.Object

A wrapper for an IMAP Folder object and its contained messages.


Nested Class Summary
 class FolderWrapper.Sort
          Implements the Comparator interface used for sorting message wrappers
 
Field Summary
static int DATE
          Specifies sorting by date
static int DOWN
          Specifies sorting in descending order
static int SENDER
          Specifies sorting by sender
static int SUBJECT
          Specifies sorting by subject
static int TYPE_INCOMING
          Classification for a folder containing incoming messages
static int TYPE_OUTGOING
          Classification for a folder containing outgoing messages
static int UP
          Specifies sorting in ascending order
 
Constructor Summary
FolderWrapper()
          Creates an empty folder wrapper
FolderWrapper(java.lang.String id, java.lang.String name, int folderType, java.lang.String displayName, int sortOrder, MailManager mailManager)
          Creates a folder wrapper for a specifieds folder
 
Method Summary
 void copyToFolder(javax.mail.Message message)
          Adds a Message object to a Folder on the IMAP server, and refreshes this FolderWrapper to reflect the changes on the server
 MessageWrapper deleteMessage(MessageWrapper messageWrapper)
          Deletes a message
 java.lang.String getDisplayName()
          Gets the display name of the folder
 javax.mail.Folder getFolder()
          Gets the Folder wrapped by this object
 java.lang.String getId()
          Gets the id of the folder as known by the MailManager
 MailManager getMailManager()
          Gets the MailManager
 int getMessageCount()
          Gets the number of messages in the folder
 MessageWrapper getMessageWrapperByNumber(java.lang.Integer number)
          Gets a message specified by its number
 MessageWrapper[] getMessageWrappers()
          Gets an array of MessageWrapper objects wrapping the Message objects in the folder
 java.lang.String getName()
          Gets the name of the folder as known t the IMAP server
 MessageWrapper getNextMessage(MessageWrapper messageWrapper)
          Gets the wrapper of the the message following a specified message, in the current sort order
 MessageWrapper getPreviousMessage(MessageWrapper messageWrapper)
          Gets the wrapper of the the message following a specified message, in the current sort order
 boolean isDraftsFolder()
          Determines if the wrapped Folder is the Drafts folder
 boolean isFirst(int index)
          Determines if a message is the first in the a list
 boolean isLast(int index)
          Determines if the folder contains incoming messages
 boolean isOutgoing()
          Determines if the folder contains outgoing messages
 boolean isSortedDateDown()
          Determines if the folder is sorted by date in descending order
 boolean isSortedDateUp()
          Determines if the folder is sorted by date in ascending order
 boolean isSortedFromDown()
          Determines if the folder is sorted by sender in descending order
 boolean isSortedFromUp()
          Determines if the folder is sorted by sender in ascending order
 boolean isSortedSubjectDown()
          Determines if the folder is sorted by subject in descending order
 boolean isSortedSubjectUp()
          Determines if
 void refresh(javax.mail.Folder folder)
          Refreshes the wrapper with a new Folder object obtained from the mail server
 void setMessageCount(int messageCount)
          Sets the number of messages in the folder
 void sortMessages(int sortOrder)
          Creates a TreeMap of references to the MessageWrappers sorted according to a specified order, and tags the MessageWrapper objects with their sort index value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_INCOMING

public static final int TYPE_INCOMING
Classification for a folder containing incoming messages

See Also:
Constant Field Values

TYPE_OUTGOING

public static final int TYPE_OUTGOING
Classification for a folder containing outgoing messages

See Also:
Constant Field Values

DATE

public static final int DATE
Specifies sorting by date

See Also:
Constant Field Values

SENDER

public static final int SENDER
Specifies sorting by sender

See Also:
Constant Field Values

SUBJECT

public static final int SUBJECT
Specifies sorting by subject

See Also:
Constant Field Values

UP

public static final int UP
Specifies sorting in ascending order

See Also:
Constant Field Values

DOWN

public static final int DOWN
Specifies sorting in descending order

See Also:
Constant Field Values
Constructor Detail

FolderWrapper

public FolderWrapper()
Creates an empty folder wrapper


FolderWrapper

public FolderWrapper(java.lang.String id,
                     java.lang.String name,
                     int folderType,
                     java.lang.String displayName,
                     int sortOrder,
                     MailManager mailManager)
Creates a folder wrapper for a specifieds folder

Parameters:
id - folder id @see MailManager
name - the internal folder name used by the mail provider
folderType - the folder type, either TYPE_INCOMING or TYPE_OUTGOING
displayName - folder name for display
Method Detail

refresh

public void refresh(javax.mail.Folder folder)
             throws javax.mail.MessagingException
Refreshes the wrapper with a new Folder object obtained from the mail server

Parameters:
folder - the new Folder object
Throws:
javax.mail.MessagingException

copyToFolder

public void copyToFolder(javax.mail.Message message)
                  throws javax.mail.MessagingException
Adds a Message object to a Folder on the IMAP server, and refreshes this FolderWrapper to reflect the changes on the server

Parameters:
message - the mssage
Throws:
javax.mail.MessagingException

sortMessages

public void sortMessages(int sortOrder)
                  throws javax.mail.MessagingException
Creates a TreeMap of references to the MessageWrappers sorted according to a specified order, and tags the MessageWrapper objects with their sort index value

Parameters:
sortOrder - the sorting order
Throws:
javax.mail.MessagingException

deleteMessage

public MessageWrapper deleteMessage(MessageWrapper messageWrapper)
                             throws javax.mail.MessagingException
Deletes a message

Parameters:
messageWrapper - wrapper of the message to be deleted
Returns:
the MessageWrapper of the next message in the list from which the message was selected If the message was the last in the list, the wrapper will be that of the new last member of the list. If the folder is now empty, a null value is returned
Throws:
javax.mail.MessagingException

setMessageCount

public void setMessageCount(int messageCount)
Sets the number of messages in the folder


getMessageCount

public int getMessageCount()
Gets the number of messages in the folder

Returns:

getMessageWrappers

public MessageWrapper[] getMessageWrappers()
Gets an array of MessageWrapper objects wrapping the Message objects in the folder

Returns:
the MessageWrapper array

getMessageWrapperByNumber

public MessageWrapper getMessageWrapperByNumber(java.lang.Integer number)
Gets a message specified by its number

Returns:
the MessageWrapper

getName

public java.lang.String getName()
Gets the name of the folder as known t the IMAP server

Returns:
the name

getDisplayName

public java.lang.String getDisplayName()
Gets the display name of the folder

Returns:
the display name

getId

public java.lang.String getId()
Gets the id of the folder as known by the MailManager

Returns:
the id

isDraftsFolder

public boolean isDraftsFolder()
Determines if the wrapped Folder is the Drafts folder

Returns:
true if

getMailManager

public MailManager getMailManager()
Gets the MailManager

Returns:

getFolder

public javax.mail.Folder getFolder()
Gets the Folder wrapped by this object

Returns:

isOutgoing

public boolean isOutgoing()
Determines if the folder contains outgoing messages

Returns:
true if the folder contaions outgoing messages

isLast

public boolean isLast(int index)
Determines if the folder contains incoming messages

Returns:
true if the folder contains incoming messages

isFirst

public boolean isFirst(int index)
Determines if a message is the first in the a list

Returns:
true if message is first in the list

isSortedDateUp

public boolean isSortedDateUp()
Determines if the folder is sorted by date in ascending order

Returns:
true if

isSortedDateDown

public boolean isSortedDateDown()
Determines if the folder is sorted by date in descending order

Returns:
true if the folder is sorted by in order

isSortedFromUp

public boolean isSortedFromUp()
Determines if the folder is sorted by sender in ascending order

Returns:
true if the folder is sorted by in order

isSortedFromDown

public boolean isSortedFromDown()
Determines if the folder is sorted by sender in descending order

Returns:
true if

isSortedSubjectUp

public boolean isSortedSubjectUp()
Determines if

Returns:
true if the folder is sorted by subject in ascending order

isSortedSubjectDown

public boolean isSortedSubjectDown()
Determines if the folder is sorted by subject in descending order

Returns:
true if

getNextMessage

public MessageWrapper getNextMessage(MessageWrapper messageWrapper)
Gets the wrapper of the the message following a specified message, in the current sort order

Parameters:
messageWrapper - the message wrapper
Returns:
the wrapper of the next message

getPreviousMessage

public MessageWrapper getPreviousMessage(MessageWrapper messageWrapper)
Gets the wrapper of the the message following a specified message, in the current sort order

Parameters:
messageWrapper - the message wrapper
Returns:
wrapper of the previous message