com.funambol.mail
Class Folder

java.lang.Object
  extended by com.funambol.mail.Folder
Direct Known Subclasses:
AccountFolder

public class Folder
extends java.lang.Object

Represents a mailbox folder on the device. Folders can contain Message objects, other Folder objects or both. This nesting capability enables a folder hierarchy for stored messages. The different levels of hierarchy in a folder's full name are separated by the hierarchy separator character FOLDER_SEPARATOR. You can retrieve a contained folder by name using getFolder(), or a list of contained folders by using list()


Field Summary
protected  java.util.Date created
          The folder creation date
static char FOLDER_ITEM_PREFIX
           
static char FOLDER_SEPARATOR
           
protected  java.lang.String fullname
          The folder fullname (e.g.
protected  int recordId
          The record id in the record store
protected  java.lang.String role
          The folder role (e.g.
static java.lang.String ROOT_FOLDER_PATH
           
protected  Store store
          Each Folder contains a reference to the Store
 
Constructor Summary
Folder(Store store)
          Constructs a new Folder providing a reference to the Store in which it has to be created.
Folder(java.lang.String fullname, java.lang.String role, java.util.Date created, Store store)
          Constructs a new Folder providing a name for it, the role, the creation date and a reference to the Store in which it has to be created.
 
Method Summary
 void appendMessage(Message msg)
          Appends the given Message to this Folder
 void deleteMessage(Message msg)
          Deletes a Message from this Folder The message is properly updated so that it is both complete (completely loaded in memory) and its parent folder is cleared.
 void deleteMessage(java.lang.String recordId)
          Deletes a Message from this Folder, using the record id as key.
 void deserialize(java.io.DataInputStream din)
           
 ChildrenEnumeration getChildren()
          This method returns the ChildrenEnumeration of this Folder.
 java.util.Date getCreated()
          Returns the Folder creation date
 java.lang.String getFullName()
          Returns the full name of this Folder.
 Message getMessage(java.lang.String recordId)
          Gets the Message object corresponding to the given record ID.
 int getMessageCount()
          Get the total number of messages in this Folder
 java.lang.String getName()
          Returns the name of this Folder, taking the last part of the fullname
 Folder getParent()
          Returns the parent Folder of this Folder
 int getRecordId()
           
 java.lang.String getRole()
          Returns the Folder role
 char getSeparator()
          Returns the delimiter character that separates this Folder's pathname from the names of immediate subfolders TODO: Perhaps it is better to define in a field the character used as separator and not directly here (this adopted here is the solution by Sun)
static boolean isSupportedStream(char prefix)
          Check whether the provided prefix char represents a Folder DataInputStream
 Folder[] list()
          This method returns the list of subfolders under this Folder
 void serialize(java.io.DataOutputStream dout)
           
 void setRecordId(int id)
           
 void setRole(java.lang.String role)
          Set the Folder role
 void setStore(Store store)
          Set the Store containing this Folder
 void updateMessage(Message msg)
          Updates the given Message
protected  void writeRecordPrefix(java.io.DataOutputStream dout)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FOLDER_ITEM_PREFIX

public static final char FOLDER_ITEM_PREFIX
See Also:
Constant Field Values

FOLDER_SEPARATOR

public static final char FOLDER_SEPARATOR
See Also:
Constant Field Values

ROOT_FOLDER_PATH

public static final java.lang.String ROOT_FOLDER_PATH
See Also:
Constant Field Values

fullname

protected java.lang.String fullname
The folder fullname (e.g. /Funambol/Inbox)


role

protected java.lang.String role
The folder role (e.g. Inbox)


created

protected java.util.Date created
The folder creation date


store

protected Store store
Each Folder contains a reference to the Store


recordId

protected int recordId
The record id in the record store

Constructor Detail

Folder

public Folder(Store store)
Constructs a new Folder providing a reference to the Store in which it has to be created. It is used when creating a Folder from a DataInputStream.

Parameters:
store - The Store in which the folder has to be created

Folder

public Folder(java.lang.String fullname,
              java.lang.String role,
              java.util.Date created,
              Store store)
Constructs a new Folder providing a name for it, the role, the creation date and a reference to the Store in which it has to be created.

Parameters:
fullname - The fullname for this Folder
role - The role for this Folder
created - The creation date for this Folder
store - The Store in which the folder has to be created
Method Detail

getFullName

public java.lang.String getFullName()
Returns the full name of this Folder.

Returns:
The string containing the full name of this Folder

getName

public java.lang.String getName()
Returns the name of this Folder, taking the last part of the fullname

Returns:
The string containing the name of this Folder

setStore

public void setStore(Store store)
Set the Store containing this Folder

Parameters:
store - A reference to the Store containing this Folder

getRole

public java.lang.String getRole()
Returns the Folder role

Returns:
The Folder role

setRole

public void setRole(java.lang.String role)
Set the Folder role

Parameters:
role - The new role

getCreated

public java.util.Date getCreated()
Returns the Folder creation date

Returns:
The Folder role

getParent

public Folder getParent()
                 throws MailException
Returns the parent Folder of this Folder

Returns:
The Folder object this Folder is child of
Throws:
MailException

getSeparator

public char getSeparator()
Returns the delimiter character that separates this Folder's pathname from the names of immediate subfolders TODO: Perhaps it is better to define in a field the character used as separator and not directly here (this adopted here is the solution by Sun)

Returns:
The hierarchy separator character

list

public Folder[] list()
              throws MailException
This method returns the list of subfolders under this Folder

Returns:
The subfolders array
Throws:
MailException

appendMessage

public void appendMessage(Message msg)
                   throws MailException
Appends the given Message to this Folder

Parameters:
msg - The Message to be added
Throws:
MailException

updateMessage

public void updateMessage(Message msg)
                   throws MailException
Updates the given Message

Parameters:
msg - The Message to be updated
Throws:
MailException

getMessage

public Message getMessage(java.lang.String recordId)
                   throws MailException
Gets the Message object corresponding to the given record ID.

Parameters:
recordId -
Returns:
Throws:
MailException

getChildren

public ChildrenEnumeration getChildren()
                                throws MailException
This method returns the ChildrenEnumeration of this Folder. NOTE: the children could of different types: Message, Folder or AccountFolder

Returns:
A Enumeration of the Message items contained in this Folder
Throws:
MailException - If an error occurs accessing the Store

deleteMessage

public void deleteMessage(Message msg)
                   throws MailException
Deletes a Message from this Folder The message is properly updated so that it is both complete (completely loaded in memory) and its parent folder is cleared. After this call the Message object is valid and can be used in any operation.

Parameters:
msg - A reference to the message to be deleted
Throws:
MailException

deleteMessage

public void deleteMessage(java.lang.String recordId)
                   throws MailException
Deletes a Message from this Folder, using the record id as key. If the client has one or more Message objects that hold the message at this record id position, there is no guarantee these objects are still valid after this call. For such cases the client should use @see deleteMessage(Message)

Parameters:
key - A reference to the message to be deleted
Throws:
MailException

getMessageCount

public int getMessageCount()
                    throws MailException
Get the total number of messages in this Folder

Throws:
MailException

isSupportedStream

public static boolean isSupportedStream(char prefix)
Check whether the provided prefix char represents a Folder DataInputStream

Parameters:
prefix - The item prefix.
Returns:
true If supported.

writeRecordPrefix

protected void writeRecordPrefix(java.io.DataOutputStream dout)
                          throws java.io.IOException
Throws:
java.io.IOException

serialize

public void serialize(java.io.DataOutputStream dout)
               throws java.io.IOException
Throws:
java.io.IOException
See Also:
com.funambol.storage.Serializable#serialize(java.io.DataOutputStream)

deserialize

public void deserialize(java.io.DataInputStream din)
                 throws java.io.IOException
Throws:
java.io.IOException
See Also:
com.funambol.storage.Serializable#deserialize(java.io.DataInputStream)

setRecordId

public void setRecordId(int id)
See Also:
com.funambol.storage.RmsRecordItem#setRecordId(int)

getRecordId

public int getRecordId()
See Also:
com.funambol.storage.RmsRecordItem#getRecordId()


Copyright © 2001-2009 Funambol.