edu.harvard.deas.hyperenc
Class ContactList

java.lang.Object
  extended by edu.harvard.deas.hyperenc.ContactList
All Implemented Interfaces:
Iterable<Contact>
Direct Known Subclasses:
BasicContactList, DBContactList

public abstract class ContactList
extends Object
implements Iterable<Contact>

A list of Contacts. Implements a subset of the List interface, and an additional method, getContact, that finds the Contact in the list with the given e-mail address.


Constructor Summary
protected ContactList()
          Default constructor
 
Method Summary
abstract  void addContact(Contact c)
          Appends c to the list.
abstract  Contact get(int index)
          Returns the contact at index index in the list.
abstract  Contact getContact(Address a)
          Returns the Contact in this list with e-mail address a.
 boolean isEmpty()
          Returns whether this list is empty.
abstract  Iterator<Contact> iterator()
          Returns an Iterator over the Contacts in this list.
abstract  void removeContact(Contact c)
          Removes c from the list.
abstract  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

ContactList

protected ContactList()
Default constructor

Method Detail

addContact

public abstract void addContact(Contact c)
Appends c to the list.

Parameters:
c - the contact to be added

removeContact

public abstract void removeContact(Contact c)
Removes c from the list.

Parameters:
c - the contact to be removed

get

public abstract Contact get(int index)
                     throws IndexOutOfBoundsException
Returns the contact at index index in the list.

Parameters:
index - an integer index between 0 and this.size() - 1
Returns:
the contact at the specified index
Throws:
IndexOutOfBoundsException - if the value of index is illegal

iterator

public abstract Iterator<Contact> iterator()
Returns an Iterator over the Contacts in this list. The Iterator returns Contacts in the order in which they appear in this list, that is, starting from index 0 and going in increasing order.

Specified by:
iterator in interface Iterable<Contact>

size

public abstract int size()
Returns the number of contacts in the list.

Returns:
the size of this list

isEmpty

public boolean isEmpty()
Returns whether this list is empty.

Returns:
true iff the size of this list is 0

getContact

public abstract Contact getContact(Address a)
Returns the Contact in this list with e-mail address a.

Parameters:
a - e-mail address
Returns:
the Contact with the given e-mail address