com.funambol.mail
Class RMSStore

java.lang.Object
  extended by com.funambol.mail.RMSStore
All Implemented Interfaces:
Store
Direct Known Subclasses:
NokiaFP2RMSStore

public class RMSStore
extends java.lang.Object
implements Store

Implements the Store interface using J2ME RecordStore. Each Folder is mapped to a RecordStore with name equal to the full path of the Folder. The records of each RecordStore can contain any kind of data, including:

  • AccountFolder items;
  • Folder items;
  • Message items.

  • Field Summary
    static int DEFAULT_MAX_MESSAGE_NUMBER
              Max number of messages that can be stored
     
    Fields inherited from interface com.funambol.mail.Store
    LATEST_VERSION, VERSION_101, VERSION_102, VERSION_103, VERSION_104, VERSION_105
     
    Method Summary
     int addChild(java.lang.String path, RmsRecordItem child)
              This method add a new child to a Folder.
     Folder addFolder(Folder folder)
              Add a new Folder to the Store.
     int countChilds(java.lang.String path)
              This method returns the count of childs in a Folder.
     int countChilds(java.lang.String path, char prefix)
              This method returns the count of childs in a Folder.
    protected  ObjectStore createObjectStore()
               
    protected  ObjectStore createObjectStore(java.lang.String name)
               
     Folder[] findFolders(java.lang.String path)
              Retrieves a Folder in this Store that matches the provided substring.
     java.lang.String[] getChildIDs(java.lang.String path)
              This method returns the array of the childs IDs contained in a Folder.
     ChildrenEnumeration getChildren(java.lang.String path)
              Get the ChildrenEnumeration related to the given path.
     Folder getFolder(java.lang.String path)
              Retrieves a Folder object by path.
     Folder getFolder(java.lang.String path, boolean lightFolder)
              Retrieves a Folder object by path.
     int getVersion()
              This method gets the version of the Store which is currently being used on the device.
     void init(boolean reset)
              Initialize the store.
     Folder[] list()
              Retrieves the list of all the folders directly under this Store.
     Folder[] list(java.lang.String path)
              Returns the list of the subfolders contained under the specified Folder.
     RmsRecordItem readChild(java.lang.String path, java.lang.String childId)
              This method reads a Folder from the Store, using the child id.
     java.io.DataInputStream readChildBytes(java.lang.String path, java.lang.String childId)
              This method returns the InputStream of a Folder child.
     void removeChild(java.lang.String path, java.lang.String childId)
              This method removes a Folder child from the Store.
     boolean removeFolder(Folder folder, boolean recursive)
              Removes a Folder RecordStore, its parent reference and the subfolders.
     void removeFolder(java.lang.String folderPath)
              Recursively removes a Folder given the Folder name
     java.lang.String retrieveSubfolderID(java.lang.String subfolderPath, java.lang.String parentPath)
              Retrieve a subfolder from a folder record store and return its record id.
     void setVersion(int version)
              This method sets the version of the Store which is currently being used on the device.
     void updateChild(java.lang.String path, RmsRecordItem child)
              This method updates an existing Folder child in the Store.
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    DEFAULT_MAX_MESSAGE_NUMBER

    public static final int DEFAULT_MAX_MESSAGE_NUMBER
    Max number of messages that can be stored

    See Also:
    Constant Field Values
    Method Detail

    init

    public void init(boolean reset)
              throws MailException
    Description copied from interface: Store
    Initialize the store.

    Specified by:
    init in interface Store
    Parameters:
    reset - If true, erase and re-create all the store.
    Throws:
    MailException
    See Also:
    Store.init(boolean)

    list

    public Folder[] list()
    Description copied from interface: Store
    Retrieves the list of all the folders directly under this Store.

    Specified by:
    list in interface Store
    Returns:
    An array of folders, or null if the store is empty.
    See Also:
    Store.list()

    list

    public Folder[] list(java.lang.String path)
                  throws MailException
    Description copied from interface: Store
    Returns the list of the subfolders contained under the specified Folder.

    Specified by:
    list in interface Store
    Parameters:
    path - The path of the parent Folder.
    Returns:
    An array of folders, or null if path has no subfolders.
    Throws:
    MailException - If the path is not valid.
    See Also:
    Store.list(java.lang.String)

    addFolder

    public Folder addFolder(Folder folder)
                     throws MailException
    Description copied from interface: Store
    Add a new Folder to the Store.

    Specified by:
    addFolder in interface Store
    Parameters:
    folder - The Folder item to be stored.
    Returns:
    The added Folder reference
    Throws:
    MailException - If an error occurs on the store (e.g. no space left).
    See Also:
    Store.addFolder(com.funambol.mail.Folder)

    removeFolder

    public boolean removeFolder(Folder folder,
                                boolean recursive)
                         throws MailException
    Removes a Folder RecordStore, its parent reference and the subfolders.

    Specified by:
    removeFolder in interface Store
    Parameters:
    folder - The Folder to be removed. Use getFolder to retrieve the Folder from its path.
    recursive - Perform a recursive removal.
    Returns:
    true if the Folder has been actually deleted, false if the Folder did not exist.
    Throws:
    MailException - If an error occurs on the store.
    See Also:
    Store.removeFolder(com.funambol.mail.Folder, boolean)

    removeFolder

    public void removeFolder(java.lang.String folderPath)
                      throws MailException
    Description copied from interface: Store
    Recursively removes a Folder given the Folder name

    Specified by:
    removeFolder in interface Store
    Parameters:
    folderPath - the path of the Folder to be removed
    Throws:
    MailException - if a storage error occurs
    See Also:
    Store.removeFolder(String)

    getFolder

    public Folder getFolder(java.lang.String path)
                     throws MailException
    Description copied from interface: Store
    Retrieves a Folder object by path.

    Specified by:
    getFolder in interface Store
    Parameters:
    path - The path to the Folder in the device's file system
    Returns:
    The Folder object.
    Throws:
    MailException - If an error occurs accessing the Store.
    See Also:
    Store.getFolder(java.lang.String)

    getFolder

    public Folder getFolder(java.lang.String path,
                            boolean lightFolder)
                     throws MailException
    Description copied from interface: Store
    Retrieves a Folder object by path.

    Specified by:
    getFolder in interface Store
    Parameters:
    path - The path to the Folder in the device's file system
    lightFolder - If true return the Folder item without reading its properties (e.g. role, creation date). It doesn't check if it really exists in the Store.
    Returns:
    The Folder object.
    Throws:
    MailException - If an error occurs accessing the Store.
    See Also:
    Store.getFolder(java.lang.String, boolean)

    findFolders

    public Folder[] findFolders(java.lang.String path)
    Description copied from interface: Store
    Retrieves a Folder in this Store that matches the provided substring.

    Specified by:
    findFolders in interface Store
    Parameters:
    path - The partial path in the device's file system to the searched Folder.
    Returns:
    A list of Folder objects whose path matches the provided substring, or null if there are no matches.
    See Also:
    Store.findFolders(java.lang.String)

    retrieveSubfolderID

    public java.lang.String retrieveSubfolderID(java.lang.String subfolderPath,
                                                java.lang.String parentPath)
    Description copied from interface: Store
    Retrieve a subfolder from a folder record store and return its record id.

    Specified by:
    retrieveSubfolderID in interface Store
    Parameters:
    subfolderPath - The path to the subfolder
    parentPath - The path to the parent folder
    Returns:
    The folder ID, null if it's not found
    See Also:
    Store.retrieveSubfolderID(java.lang.String, java.lang.String)

    getChildIDs

    public java.lang.String[] getChildIDs(java.lang.String path)
                                   throws MailException
    Description copied from interface: Store
    This method returns the array of the childs IDs contained in a Folder.

    Specified by:
    getChildIDs in interface Store
    Parameters:
    path - The complete path of the Folder.
    Returns:
    An array containing all the childs Ids, or null if the Folder is empty.
    Throws:
    MailException - If an error occurs accessing the Store.
    See Also:
    Store.getChildIDs(java.lang.String)

    readChild

    public RmsRecordItem readChild(java.lang.String path,
                                   java.lang.String childId)
                            throws MailException
    Description copied from interface: Store
    This method reads a Folder from the Store, using the child id.

    Specified by:
    readChild in interface Store
    Parameters:
    path - The complete path of the Folder containing the child.
    childId - The child unique ID.
    Returns:
    The RmsRecordItem object corresponding to the childId.
    Throws:
    MailException - If an error occurs accessing the Store.
    See Also:
    Store.readChild(java.lang.String, java.lang.String)

    readChildBytes

    public java.io.DataInputStream readChildBytes(java.lang.String path,
                                                  java.lang.String childId)
                                           throws MailException
    Description copied from interface: Store
    This method returns the InputStream of a Folder child.

    Specified by:
    readChildBytes in interface Store
    Parameters:
    path - The complete path of the Folder containing the child.
    childId - The child unique ID.
    Returns:
    The DataInputStream corresponding to the childId.
    Throws:
    MailException - If an error occurs accessing the Store.
    See Also:
    Store.readChildBytes(java.lang.String, java.lang.String)

    getChildren

    public ChildrenEnumeration getChildren(java.lang.String path)
                                    throws MailException
    Description copied from interface: Store
    Get the ChildrenEnumeration related to the given path.

    Specified by:
    getChildren in interface Store
    Parameters:
    path - The path for which the ChildrenEnumeration shall be returned.
    Returns:
    The ChildrenEnumeration.
    Throws:
    MailException - If an error occurs accessing the Store.
    See Also:
    com.funambol.mail.Store#getChildrenEnumeration(java.lang.String)

    addChild

    public int addChild(java.lang.String path,
                        RmsRecordItem child)
                 throws MailException
    Description copied from interface: Store
    This method add a new child to a Folder.

    Specified by:
    addChild in interface Store
    Parameters:
    path - The complete path of the Folder.
    child - The RmsRecordItem child to save.
    Returns:
    The new child id
    Throws:
    MailException - If an error occurs accessing the Store.
    See Also:
    com.funambol.mail.Store#addChild(java.lang.String, com.funambol.storage.RmsRecordItem)

    updateChild

    public void updateChild(java.lang.String path,
                            RmsRecordItem child)
                     throws MailException
    Description copied from interface: Store
    This method updates an existing Folder child in the Store.

    Specified by:
    updateChild in interface Store
    Parameters:
    path - The complete path of the Folder containing the child.
    child - The RmsRecordItem child to save.
    Throws:
    MailException - If an error occurs accessing the Store.
    See Also:
    com.funambol.mail.Store#updateChild(java.lang.String, com.funambol.storage.RmsRecordItem)

    removeChild

    public void removeChild(java.lang.String path,
                            java.lang.String childId)
                     throws MailException
    Description copied from interface: Store
    This method removes a Folder child from the Store.

    Specified by:
    removeChild in interface Store
    Parameters:
    path - The complete path of the Folder containing the child.
    childId - A string representing the unique child ID.
    Throws:
    MailException - If an error occurs accessing the Store.
    See Also:
    Store.removeChild(java.lang.String, java.lang.String)

    countChilds

    public int countChilds(java.lang.String path)
                    throws MailException
    Description copied from interface: Store
    This method returns the count of childs in a Folder.

    Specified by:
    countChilds in interface Store
    Parameters:
    path - The complete path of the Folder.
    Throws:
    MailException - If an error occurs accessing the Store.
    See Also:
    Store.countChilds(java.lang.String)

    countChilds

    public int countChilds(java.lang.String path,
                           char prefix)
                    throws MailException
    Description copied from interface: Store
    This method returns the count of childs in a Folder. Only childs with the specified prefix will be counted.

    Specified by:
    countChilds in interface Store
    Parameters:
    path - The complete path of the Folder.
    prefix - The childs type to be counted.
    Throws:
    MailException - If an error occurs accessing the Store.
    See Also:
    Store.countChilds(java.lang.String, char)

    setVersion

    public void setVersion(int version)
    This method sets the version of the Store which is currently being used on the device. If no version is specified, the Store defaults to the latest one.

    Specified by:
    setVersion in interface Store
    Parameters:
    version - is the store version

    getVersion

    public int getVersion()
    This method gets the version of the Store which is currently being used on the device.

    Specified by:
    getVersion in interface Store

    createObjectStore

    protected ObjectStore createObjectStore()

    createObjectStore

    protected ObjectStore createObjectStore(java.lang.String name)


    Copyright © 2001-2009 Funambol.