ePOST API

rice.email
Class Folder

java.lang.Object
  extended by rice.email.Folder

public class Folder
extends java.lang.Object

Represents a notion of a folder in the email service.

Author:
Joe Montgomery

Field Summary
static int COMPRESS_LIMIT
           
static int MAX_SNAPSHOT_ENTRIES
           
static java.lang.String ROOT_FOLDER_NAME
           
 
Constructor Summary
Folder(EmailLog log, Post post, java.security.KeyPair pair)
          Constructs a Folder from a log and a storage service.
 
Method Summary
 void addChildFolder(Folder folder, Continuation command)
          Adds an existing folder as a child folder of this folder
 void addMessage(Email email, Continuation command)
          Appends an email to this Folder, with default (no) flags set.
 void addMessage(Email email, Flags flags, long internaldate, Continuation command)
          Appends an email to this Folder with the specified flags set.
 void addMessages(Email[] emails, Flags[] flags, long[] internaldates, Continuation command)
          Appends an email to this Folder with the specified flags set.
 void addSubscription(java.lang.String sub, Continuation command)
          Adds a subscriptions to the log
 void createChildFolder(java.lang.String name, Continuation command)
          Creates a new child of the given name.
 void createSnapShot(Continuation command)
          Creates and inserts a snapshot for the current folder
 void dump()
           
 void getChildFolder(java.lang.String name, Continuation command)
          Returns the selected Folder.
protected  void getChildReferences(java.util.Set set, Continuation command)
           
 java.lang.String[] getChildren()
          Returns the names of the child Folders of the current Folder.
 void getContentHashReferences(java.util.Set set, Continuation command)
          This method returns a list of all the handles stored in the folder or any subfolders.
 long getCreationTime()
          Returns the time (in milliseconds) that this email log was created.
 int getExists()
          Returns the number of messages which exist in this folder
protected  void getLogReferences(java.util.Set set, Continuation command)
           
protected  void getLogReferences(java.util.Set set, SnapShot[] snapshot, Continuation command)
           
 void getLogs(java.util.Set set, Continuation command)
          This method is periodically invoked by Post in order to get a list of all mutable data which the application is interested in.
protected  void getMessageReferences(java.util.Set set, Continuation command)
           
 void getMessages(Continuation command)
          Returns the Emails contained in this Folder.
 void getMessages(SnapShot[] snapshots, Continuation command)
          Returns the Emails contained in this Folder.
 java.lang.String getName()
          Returns the name of this folder
 int getNextUID()
          Returns the next UID that will be assigned to an incoming message.
 Post getPost()
           
 int getRecent()
          Returns the number of messages which are recent in this folder
 void getSubscriptions(Continuation command)
          Returns the list of subscriptions in the log
 boolean isRoot()
          Returns whether or not this folder is the root of the email hierarchy
 void moveMessage(StoredEmail email, Folder folder, Continuation command)
          Moves a message from this folder into a another, given folder.
 void removeFolder(java.lang.String name, Continuation command)
          Deletes a folder from the user's mailbox.
 void removeMessage(StoredEmail email, Continuation command)
          Deletes a message from this Folder.
 void removeMessages(StoredEmail[] email, Continuation command)
          Deletes a list of messages from this Folder.
 void removeSubscription(java.lang.String sub, Continuation command)
          Adds a subscriptions to the log
 void setName(java.lang.String name, Continuation command)
          Changes the name of this folder.
 void setPost(Post post)
          Sets the post service of this Folder.
protected  SnapShot[] splitEmails(StoredEmail[] emails, LogEntry entry)
          Splits the emails into a bunch of snapshots, for a memory cap
 java.lang.String toString()
           
 void updateMessage(StoredEmail email, Continuation command)
          Updates an Email (flags)
 void updateMessages(StoredEmail[] emails, Continuation command)
          Updates a list of Emails (flags)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COMPRESS_LIMIT

public static final int COMPRESS_LIMIT
See Also:
Constant Field Values

MAX_SNAPSHOT_ENTRIES

public static final int MAX_SNAPSHOT_ENTRIES
See Also:
Constant Field Values

ROOT_FOLDER_NAME

public static java.lang.String ROOT_FOLDER_NAME
Constructor Detail

Folder

public Folder(EmailLog log,
              Post post,
              java.security.KeyPair pair)
Constructs a Folder from a log and a storage service.

Parameters:
log - the Log which contains the data for the Folder.
storage - the storage service used to get log data from PAST.
Method Detail

isRoot

public boolean isRoot()
Returns whether or not this folder is the root of the email hierarchy

Returns:
Whether or not this folder is the root

setPost

public void setPost(Post post)
Sets the post service of this Folder.

Parameters:
post - the new post service for this Folder

getPost

public Post getPost()

getName

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

Returns:
The name of the folder

setName

public void setName(java.lang.String name,
                    Continuation command)
Changes the name of this folder. Should ONLY be used for single changes - does NOT change a hierarchy.

Parameters:
name - The new name to use
command - the work to perform after this call.

getSubscriptions

public void getSubscriptions(Continuation command)
Returns the list of subscriptions in the log

Parameters:
command - the work to perform after this call.

addSubscription

public void addSubscription(java.lang.String sub,
                            Continuation command)
Adds a subscriptions to the log

Parameters:
command - the work to perform after this call.
sub - The subscription to add

removeSubscription

public void removeSubscription(java.lang.String sub,
                               Continuation command)
Adds a subscriptions to the log

Parameters:
command - the work to perform after this call.
sub - The subscription to add

getNextUID

public int getNextUID()
Returns the next UID that will be assigned to an incoming message.

Returns:
The next UID that will be assigned.

getExists

public int getExists()
Returns the number of messages which exist in this folder

Returns:
The number of messages which exists in the folder

getRecent

public int getRecent()
Returns the number of messages which are recent in this folder

Returns:
The number of messages which are recent in the folder

getCreationTime

public long getCreationTime()
Returns the time (in milliseconds) that this email log was created.

Returns:
The creation time

getContentHashReferences

public void getContentHashReferences(java.util.Set set,
                                     Continuation command)
This method returns a list of all the handles stored in the folder or any subfolders. Returns a PastContentHandle[] containing all of the handles in to the provided continatuion.


getMessageReferences

protected void getMessageReferences(java.util.Set set,
                                    Continuation command)

getLogReferences

protected void getLogReferences(java.util.Set set,
                                Continuation command)

getLogReferences

protected void getLogReferences(java.util.Set set,
                                SnapShot[] snapshot,
                                Continuation command)

getChildReferences

protected void getChildReferences(java.util.Set set,
                                  Continuation command)

getLogs

public void getLogs(java.util.Set set,
                    Continuation command)
This method is periodically invoked by Post in order to get a list of all mutable data which the application is interested in. The applications should return a PostData[] containing all of the data The application is still interested in to the provided continatuion.


updateMessage

public void updateMessage(StoredEmail email,
                          Continuation command)
Updates an Email (flags)

Parameters:
email - The email to update.
command - the work to perform after this call.

updateMessages

public void updateMessages(StoredEmail[] emails,
                           Continuation command)
Updates a list of Emails (flags)

Parameters:
email - The emails to update.
command - the work to perform after this call.

addMessage

public void addMessage(Email email,
                       Continuation command)
Appends an email to this Folder, with default (no) flags set. Creates a new StoredEmail instance with the given email. Sets all flags to false for the new email in the folder

Parameters:
email - The email to insert.
command - the work to perform after this call

addMessage

public void addMessage(Email email,
                       Flags flags,
                       long internaldate,
                       Continuation command)
Appends an email to this Folder with the specified flags set. Creates a new StoredEmail instance with the given email. Sets all flags to false for the new email in the folder

Parameters:
email - The email to insert.
flags - The flags to insert the email with
internaldate - The date to insert the email with
command - the work to perform after this call

addMessages

public void addMessages(Email[] emails,
                        Flags[] flags,
                        long[] internaldates,
                        Continuation command)
Appends an email to this Folder with the specified flags set. Creates a new StoredEmail instance with the given email. Sets all flags to false for the new email in the folder. NOTE: This method assumes that all of the emails have already stored thier data.

Parameters:
email - The email to insert.
command - the work to perform after this call

moveMessage

public void moveMessage(StoredEmail email,
                        Folder folder,
                        Continuation command)
Moves a message from this folder into a another, given folder. This means adding the message to the destination folder, and removing the message from this folder.

Parameters:
email - The email to move.
folder - The destination folder for the message.
command - the remaining work to carry out

removeMessage

public void removeMessage(StoredEmail email,
                          Continuation command)
Deletes a message from this Folder.

Parameters:
email - The email to delete.
command - the remaining work to carry out

removeMessages

public void removeMessages(StoredEmail[] email,
                           Continuation command)
Deletes a list of messages from this Folder.

Parameters:
emails - The emails to delete.
command - the remaining work to carry out

createChildFolder

public void createChildFolder(java.lang.String name,
                              Continuation command)
Creates a new child of the given name. The current Folder is the parent.

Parameters:
name - the name of the new child Folder
command - the work to perform after this call

addChildFolder

public void addChildFolder(Folder folder,
                           Continuation command)
Adds an existing folder as a child folder of this folder

Parameters:
folder - The folder to add
command - The command to call once the add is done

removeFolder

public void removeFolder(java.lang.String name,
                         Continuation command)
Deletes a folder from the user's mailbox.

Parameters:
name - The name of the folder to delete.
command - the work to perform after this call

getChildFolder

public void getChildFolder(java.lang.String name,
                           Continuation command)
Returns the selected Folder. The Folder is selected by its name; if the Folder does not exist an exception is thrown.

Parameters:
name - the name of the Folder to return
command - the work to perform after this call

splitEmails

protected SnapShot[] splitEmails(StoredEmail[] emails,
                                 LogEntry entry)
Splits the emails into a bunch of snapshots, for a memory cap

Parameters:
emails - The emails
Returns:
The sepeated emails

createSnapShot

public void createSnapShot(Continuation command)
Creates and inserts a snapshot for the current folder

Parameters:
command - The command to run once the result is received

getChildren

public java.lang.String[] getChildren()
Returns the names of the child Folders of the current Folder.

Returns:
an array of the names of the child Folders

getMessages

public void getMessages(Continuation command)
Returns the Emails contained in this Folder.

Parameters:
command - the work to perform after this call

getMessages

public void getMessages(SnapShot[] snapshots,
                        Continuation command)
Returns the Emails contained in this Folder.

Parameters:
command - the work to perform after this call

dump

public void dump()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

ePOST API

Copyright © 2001-2005 - Rice Pastry.