|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.harvard.deas.hyperenc.gui.MessageStorage
edu.harvard.deas.hyperenc.gui.DBMessageStorage
public class DBMessageStorage
Stores collections of GuiMessages. Supports retrieval of all GuiMessages from
a particular sender. This storage is backed by a PersistentMap
, so
insertions and removals of messages in this storage are synchronously written
to disk, and can persist across instances of the application.
All storage in this MessageStorage is done by value; the returned GuiMessage is not necessarily the same object reference as the one that was originally stored, even if the insertion and lookup occur within the lifetime of a single VM.
Thread safety: This implementation is unconditionally thread-safe as a consequence of the thread-safety of the underlying database.
PersistentMap
Constructor Summary | |
---|---|
DBMessageStorage(String emailAddress)
Equivalent to DBMessageStorage(emailAddress, null) . |
|
DBMessageStorage(String emailAddress,
File envPath)
Constructor. |
Method Summary | |
---|---|
void |
addMessage(GuiMessage msg)
Put message in storage. |
GuiMessage |
getMessage(int id)
Get message from this storage, given its ID. |
Collection<GuiMessage> |
getMessagesBySender(Contact contact)
Get all stored messages sent from a particular contact. |
GuiMessage |
removeMessage(int id)
Remove a message from storage. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DBMessageStorage(String emailAddress)
DBMessageStorage(emailAddress, null)
.
emailAddress
- e-mail address for which this MessageStorage is storing e-mailspublic DBMessageStorage(String emailAddress, File envPath)
emailAddress
- e-mail address for which this MessageStorage is storing e-mailsenvPath
- The path on disk of the database environment underlying the database
backing this map. Must be readable and writable. If it doesn't
exist, it will be created. If null
, the default
environment specified by PersistentMap.DEFAULT_HOME
is used.PersistentMap
,
Environment
Method Detail |
---|
public void addMessage(GuiMessage msg)
MessageStorage
addMessage
in class MessageStorage
msg
- Message to be stored.public GuiMessage getMessage(int id)
MessageStorage
getID
method of GuiMessage.
getMessage
in class MessageStorage
id
- ID of desired message.
null
if
there is no such message stored.public Collection<GuiMessage> getMessagesBySender(Contact contact)
MessageStorage
getMessagesBySender
in class MessageStorage
contact
- contact of desired sender
public GuiMessage removeMessage(int id)
MessageStorage
removeMessage
in class MessageStorage
id
- ID of message to be removed.
null
if there is no
such message stored.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |