com.calfater.mailcarbon.helper
Class FolderHelper

java.lang.Object
  extended by com.calfater.mailcarbon.helper.FolderHelper

public class FolderHelper
extends java.lang.Object

Tools for managing Folders.


Constructor Summary
FolderHelper()
           
 
Method Summary
static void addMessage(javax.mail.Folder folder, javax.mail.Message message)
          Add a new message into an already opened folder.
static void createFolder(javax.mail.Store store, java.lang.String folderName)
          Create a new folder inside the store.
static void delete(javax.mail.Folder folder)
          Delete this Folder.
static java.util.ArrayList<javax.mail.Folder> getFolderList(javax.mail.Folder folder)
          Get all folders inside a specific folder.
static java.util.ArrayList<javax.mail.Message> getMessages(javax.mail.Folder folder)
          Copy all messages from a source server folder to a backup server folder.
static int messageCount(javax.mail.Folder folder)
          Get the number of messages inside a folder.
static java.lang.String truncate(java.lang.String str, int length)
          Truncate the length of a folder name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FolderHelper

public FolderHelper()
Method Detail

getFolderList

public static java.util.ArrayList<javax.mail.Folder> getFolderList(javax.mail.Folder folder)
                                                            throws javax.mail.MessagingException
Get all folders inside a specific folder.

Parameters:
folder - The parent folder.
Returns:
the list of folders.
Throws:
javax.mail.MessagingException

messageCount

public static int messageCount(javax.mail.Folder folder)
                        throws javax.mail.MessagingException
Get the number of messages inside a folder. If the folder is not subscribe, the methos returns 0.

Parameters:
folder - The folder.
Returns:
The number of messages.
Throws:
javax.mail.MessagingException

getMessages

public static java.util.ArrayList<javax.mail.Message> getMessages(javax.mail.Folder folder)
                                                           throws javax.mail.MessagingException
Copy all messages from a source server folder to a backup server folder.

Parameters:
folder - A source Folder.
Returns:
A list of all subfolders.
Throws:
javax.mail.MessagingException

truncate

public static java.lang.String truncate(java.lang.String str,
                                        int length)
Truncate the length of a folder name.

Parameters:
str - The folder name.
length - The new size.
Returns:
The new folder truncated.

createFolder

public static void createFolder(javax.mail.Store store,
                                java.lang.String folderName)
                         throws javax.mail.MessagingException
Create a new folder inside the store.

Parameters:
store - An opened Store.
folderName - The full name of the new folder.
Throws:
javax.mail.MessagingException

addMessage

public static void addMessage(javax.mail.Folder folder,
                              javax.mail.Message message)
                       throws javax.mail.MessagingException
Add a new message into an already opened folder.

Parameters:
folder - The opened folder.
message - The message.
Throws:
javax.mail.MessagingException

delete

public static void delete(javax.mail.Folder folder)
                   throws javax.mail.MessagingException
Delete this Folder. This method will succeed only on a closed Folder. The deletion do not affects subfolders.

Parameters:
folder - The folder to be deleted.
Throws:
javax.mail.MessagingException