Class InMemoryStore

  • All Implemented Interfaces:
    ImapConstants, Store

    public class InMemoryStore
    extends Object
    implements Store, ImapConstants
    A simple in-memory implementation of Store, used for testing and development. Note: this implementation does not persist *anything* to disk.
    Version:
    $Revision: 109034 $
    Author:
    Darrell DeBoer
    • Constructor Detail

      • InMemoryStore

        public InMemoryStore()
    • Method Detail

      • getMailbox

        public MailFolder getMailbox​(String absoluteMailboxName)
        Description copied from interface: Store
        Retrieves a mailbox based on a fully qualified name.
        Specified by:
        getMailbox in interface Store
        Parameters:
        absoluteMailboxName - the fully qualified name.
        Returns:
        The mailbox if present, or null if not.
      • getMailbox

        public MailFolder getMailbox​(MailFolder parent,
                                     String name)
        Description copied from interface: Store
        Looks up a child mailbox of the supplied parent with the name given.
        Specified by:
        getMailbox in interface Store
        Parameters:
        parent - The parent mailbox
        name - The name of the child to lookup
        Returns:
        The child mailbox, or null if not found.
      • createMailbox

        public MailFolder createMailbox​(MailFolder parent,
                                        String mailboxName,
                                        boolean selectable)
                                 throws FolderException
        Description copied from interface: Store
        Creates a mailbox under the supplied parent with the given name. If specified, the mailbox created will be made selectable (able to store messages).
        Specified by:
        createMailbox in interface Store
        Parameters:
        parent - A mailbox from this store.
        mailboxName - The name of the mailbox to create.
        selectable - If true, the mailbox will be created to store messages.
        Returns:
        The created mailbox
        Throws:
        FolderException - If the mailbox couldn't be created.
      • deleteMailbox

        public void deleteMailbox​(MailFolder folder)
                           throws FolderException
        Description copied from interface: Store
        Deletes the supplied mailbox from the store. To be deleted, mailboxes must be empty of messages, and not have any children.
        Specified by:
        deleteMailbox in interface Store
        Parameters:
        folder - A mailbox from this store.
        Throws:
        FolderException - If the mailbox couldn't be deleted.
      • renameMailbox

        public void renameMailbox​(MailFolder existingFolder,
                                  String newName)
        Description copied from interface: Store
        Renames the mailbox with the new name.
        Specified by:
        renameMailbox in interface Store
        Parameters:
        existingFolder - A mailbox from this store.
        newName - The new name for the mailbox.
      • setSelectable

        public MailFolder setSelectable​(MailFolder folder,
                                        boolean selectable)
        Description copied from interface: Store
        Tells the store to make the supplied mailbox selectable or not (able to store messages). The returned mailbox may be a new instance, and the supplied mailbox may no longer be valid.
        Specified by:
        setSelectable in interface Store
        Parameters:
        folder - The mailbox to modify.
        selectable - Whether this mailbox should be able to store messages.
        Returns:
        The modified mailbox
      • listMailboxes

        public Collection<MailFolder> listMailboxes​(String searchPattern)
                                             throws FolderException
        Description copied from interface: Store
        Lists all the mailboxes in the store which have a name matching the supplied search pattern.

        Valid wildcards are:

        • '*' - matches any number of characters, including the hierarchy delimiter
        • '%' - matches any number of characters, but not the hierarchy delimiter
        Specified by:
        listMailboxes in interface Store
        Parameters:
        searchPattern - The pattern to match mailboxes
        Returns:
        A read-only collection of mailboxes which match this pattern
        Throws:
        FolderException - If the list operation failed
      • getQuota

        public jakarta.mail.Quota[] getQuota​(String root,
                                             String qualifiedRootPrefix)
        Description copied from interface: Store
        Gets the quotas. See rfc2087
        Specified by:
        getQuota in interface Store
        Parameters:
        root - the quota root
        qualifiedRootPrefix - the user specific prefix
        Returns:
        the quotas, or an empty array.
        See Also:
        IMAPStore.getQuota(String)
      • setQuota

        public void setQuota​(jakarta.mail.Quota quota,
                             String qualifiedRootPrefix)
        Description copied from interface: Store
        Sets the quota. See rfc2087
        Specified by:
        setQuota in interface Store
        Parameters:
        quota - the quota.
        qualifiedRootPrefix - the user specific prefix
        See Also:
        IMAPStore.setQuota(jakarta.mail.Quota)
      • deleteQuota

        public void deleteQuota​(String qualifiedRootPrefix)
        Description copied from interface: Store
        Deletes the quota.
        Specified by:
        deleteQuota in interface Store
        Parameters:
        qualifiedRootPrefix - the user specific prefix
      • isQuotaSupported

        public boolean isQuotaSupported()
        Description copied from interface: Store
        Checks if quota capability is activated.
        Specified by:
        isQuotaSupported in interface Store
        Returns:
        true, if quota is supported.
      • setQuotaSupported

        public void setQuotaSupported​(boolean pQuotaSupported)
        Description copied from interface: Store
        Toggles quota capability.
        Specified by:
        setQuotaSupported in interface Store
        Parameters:
        pQuotaSupported - true, if supported.