Package com.icegreen.greenmail.store
Class InMemoryStore
java.lang.Object
com.icegreen.greenmail.store.InMemoryStore
- All Implemented Interfaces:
ImapConstants
,Store
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 <darrell@apache.org>
-
Field Summary
Fields inherited from interface com.icegreen.greenmail.imap.ImapConstants
BAD, BYE, CAPABILITIES, EIGHT_BIT_ENCODING, HIERARCHY_DELIMITER, HIERARCHY_DELIMITER_CHAR, INBOX_NAME, NAMESPACE_PREFIX, NAMESPACE_PREFIX_CHAR, NO, OK, SP, UNTAGGED, USER_NAMESPACE, VERSION
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateMailbox
(MailFolder parent, String mailboxName, boolean selectable) Creates a mailbox under the supplied parent with the given name.void
deleteMailbox
(MailFolder folder) Deletes the supplied mailbox from the store.getChildren
(MailFolder parent) getMailbox
(MailFolder parent, String name) Looks up a child mailbox of the supplied parent with the name given.getMailbox
(String absoluteMailboxName) Retrieves a mailbox based on a fully qualified name.listMailboxes
(String searchPattern) Lists all of the mailboxes in the store which have a name matching the supplied search pattern.void
renameMailbox
(MailFolder existingFolder, String newName) Renames the mailbox with the new name.setSelectable
(MailFolder folder, boolean selectable) Tells the store to make the supplied mailbox selectable or not (able to store messages).
-
Constructor Details
-
InMemoryStore
public InMemoryStore()
-
-
Method Details
-
getMailbox
Description copied from interface:Store
Retrieves a mailbox based on a fully qualified name.- Specified by:
getMailbox
in interfaceStore
- Returns:
- The mailbox if present, or
null
if not.
-
getMailbox
Description copied from interface:Store
Looks up a child mailbox of the supplied parent with the name given.- Specified by:
getMailbox
in interfaceStore
- Parameters:
parent
- The parent mailboxname
- 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 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
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 interfaceStore
- Parameters:
folder
- A mailbox from this store.- Throws:
FolderException
- If the mailbox couldn't be deleted.
-
renameMailbox
Description copied from interface:Store
Renames the mailbox with the new name.- Specified by:
renameMailbox
in interfaceStore
- Parameters:
existingFolder
- A mailbox from this store.newName
- The new name for the mailbox.- Throws:
FolderException
- If the mailbox couldn't be renamed
-
getChildren
- Specified by:
getChildren
in interfaceStore
- Parameters:
parent
- A mailbox from this store.- Returns:
- A read-only collection of
MailFolder
instances, which are the children of the supplied parent.
-
setSelectable
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 interfaceStore
- Parameters:
folder
- The mailbox to modify.selectable
- Whether this mailbox should be able to store messages.- Returns:
- The modified mailbox
-
listMailboxes
Description copied from interface:Store
Lists all of 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 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- See Also:
-