|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.harvard.deas.hyperenc.ContactList
edu.harvard.deas.hyperenc.DBContactList
public class DBContactList
A contact list backed by a database on disk. This class uses PersistentMap to store the Contacts to disk. Because PersistentMap provides an unsorted view of the data, this class also stores all Contacts in the list in a sorted collection in memory; all changes to this list are made in the in-memory copy and also written through to disk via the PersistentMap.
DBContactList
attempts to read in any existing contact list from
disk that has the same owner. If none is found, a new, empty DBContactList is
created. Because entries are stored in the on-disk database in an inherently
unsorted manner, the order of Contacts in a DBContactList may not be
consistent across multiple sessions—the order is subject to change
every time the data is read in from disk.
PersistentMap
Constructor Summary | |
---|---|
DBContactList(Contact owner)
Equivalent to DBContactList(owner, null) . |
|
DBContactList(Contact owner,
File envPath)
Creates a new DBContactList. |
Method Summary | |
---|---|
void |
addContact(Contact c)
Appends c to the list. |
Contact |
get(int index)
Returns the contact at index index in the list. |
Contact |
getContact(Address a)
Returns the Contact in this list with e-mail address a . |
boolean |
isEmpty()
Returns whether this list is empty. |
Iterator<Contact> |
iterator()
Returns an Iterator over the Contacts in this list. |
void |
removeContact(Contact c)
Removes c from the list. |
int |
size()
Returns the number of contacts in the list. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DBContactList(Contact owner, File envPath)
owner
- the owner of this list (usually the Contact corresponding to the
user of the hyper-encryption application)envPath
- The path on disk of 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
public DBContactList(Contact owner)
DBContactList(owner, null)
.
owner
- the owner of this list (usually the Contact corresponding to the
user of the hyper-encryption application)Method Detail |
---|
public Iterator<Contact> iterator()
ContactList
iterator
in interface Iterable<Contact>
iterator
in class ContactList
public void addContact(Contact c)
ContactList
c
to the list.
addContact
in class ContactList
c
- the contact to be addedpublic void removeContact(Contact c)
ContactList
c
from the list.
removeContact
in class ContactList
c
- the contact to be removedpublic Contact get(int index)
ContactList
index
in the list.
get
in class ContactList
index
- an integer index between 0 and this.size() - 1
public int size()
ContactList
size
in class ContactList
public boolean isEmpty()
ContactList
isEmpty
in class ContactList
true
iff the size of this list is 0public Contact getContact(Address a)
a
.
getContact
in class ContactList
a
- e-mail address
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |