Package com.icegreen.greenmail.store
Class InMemoryStore
- java.lang.Object
-
- com.icegreen.greenmail.store.InMemoryStore
-
- All Implemented Interfaces:
ImapConstants,Store
public class InMemoryStore extends Object implements Store, ImapConstants
A simple in-memory implementation ofStore, used for testing and development. Note: this implementation does not persist *anything* to disk.- Version:
- $Revision: 109034 $
- Author:
- Darrell DeBoer
-
-
Field Summary
-
Fields inherited from interface com.icegreen.greenmail.imap.ImapConstants
BAD, BYE, HIERARCHY_DELIMITER, HIERARCHY_DELIMITER_CHAR, INBOX_NAME, MESSAGES, NAMESPACE_PREFIX, NAMESPACE_PREFIX_CHAR, NO, OK, SP, STORAGE, UNTAGGED, USER_NAMESPACE, VERSION
-
-
Constructor Summary
Constructors Constructor Description InMemoryStore()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MailFoldercreateMailbox(MailFolder parent, String mailboxName, boolean selectable)Creates a mailbox under the supplied parent with the given name.voiddeleteMailbox(MailFolder folder)Deletes the supplied mailbox from the store.voiddeleteQuota(String qualifiedRootPrefix)Deletes the quota.Collection<MailFolder>getChildren(MailFolder parent)MailFoldergetMailbox(MailFolder parent, String name)Looks up a child mailbox of the supplied parent with the name given.MailFoldergetMailbox(String absoluteMailboxName)Retrieves a mailbox based on a fully qualified name.jakarta.mail.Quota[]getQuota(String root, String qualifiedRootPrefix)Gets the quotas.booleanisQuotaSupported()Checks if quota capability is activated.Collection<MailFolder>listMailboxes(String searchPattern)Lists all the mailboxes in the store which have a name matching the supplied search pattern.voidrenameMailbox(MailFolder existingFolder, String newName)Renames the mailbox with the new name.voidsetQuota(jakarta.mail.Quota quota, String qualifiedRootPrefix)Sets the quota.voidsetQuotaSupported(boolean pQuotaSupported)Toggles quota capability.MailFoldersetSelectable(MailFolder folder, boolean selectable)Tells the store to make the supplied mailbox selectable or not (able to store messages).
-
-
-
Method Detail
-
getMailbox
public MailFolder getMailbox(String absoluteMailboxName)
Description copied from interface:StoreRetrieves a mailbox based on a fully qualified name.- Specified by:
getMailboxin interfaceStore- Parameters:
absoluteMailboxName- the fully qualified name.- Returns:
- The mailbox if present, or
nullif not.
-
getMailbox
public MailFolder getMailbox(MailFolder parent, String name)
Description copied from interface:StoreLooks up a child mailbox of the supplied parent with the name given.- Specified by:
getMailboxin interfaceStore- Parameters:
parent- The parent mailboxname- The name of the child to lookup- Returns:
- The child mailbox, or
nullif not found.
-
createMailbox
public MailFolder createMailbox(MailFolder parent, String mailboxName, boolean selectable) throws FolderException
Description copied from interface:StoreCreates 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:
createMailboxin interfaceStore- Parameters:
parent- A mailbox from this store.mailboxName- The name of the mailbox to create.selectable- Iftrue, 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:StoreDeletes the supplied mailbox from the store. To be deleted, mailboxes must be empty of messages, and not have any children.- Specified by:
deleteMailboxin interfaceStore- 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:StoreRenames the mailbox with the new name.- Specified by:
renameMailboxin interfaceStore- Parameters:
existingFolder- A mailbox from this store.newName- The new name for the mailbox.
-
getChildren
public Collection<MailFolder> getChildren(MailFolder parent)
- Specified by:
getChildrenin interfaceStore- Parameters:
parent- A mailbox from this store.- Returns:
- A read-only collection of
MailFolderinstances, which are the children of the supplied parent.
-
setSelectable
public MailFolder setSelectable(MailFolder folder, boolean selectable)
Description copied from interface:StoreTells 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:
setSelectablein interfaceStore- 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:StoreLists 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:
listMailboxesin interfaceStore- 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:StoreGets the quotas.
-
setQuota
public void setQuota(jakarta.mail.Quota quota, String qualifiedRootPrefix)Description copied from interface:StoreSets the quota.
-
deleteQuota
public void deleteQuota(String qualifiedRootPrefix)
Description copied from interface:StoreDeletes the quota.- Specified by:
deleteQuotain interfaceStore- Parameters:
qualifiedRootPrefix- the user specific prefix
-
isQuotaSupported
public boolean isQuotaSupported()
Description copied from interface:StoreChecks if quota capability is activated.- Specified by:
isQuotaSupportedin interfaceStore- Returns:
- true, if quota is supported.
-
setQuotaSupported
public void setQuotaSupported(boolean pQuotaSupported)
Description copied from interface:StoreToggles quota capability.- Specified by:
setQuotaSupportedin interfaceStore- Parameters:
pQuotaSupported- true, if supported.
-
-