ContactCenters
V. 0.9.9.

umontreal.iro.lecuyer.contactcenters.dialer
Class ContactListenerDialerList

java.lang.Object
  extended by umontreal.iro.lecuyer.contactcenters.dialer.ContactListenerDialerList
All Implemented Interfaces:
ContactFactory, NewContactListener, DialerList

public class ContactListenerDialerList
extends Object
implements DialerList, NewContactListener

Implements the DialerList interface for a finite dialer list whose elements are obtained from an external source. Since this class implements the NewContactListener interface, it can be bound to an arrival process or any source of contacts. When a new contact is notified to this dialer list, it is added at the end of an internal ordered list for later use. When calling removeFirst(int[]), the first element from this internal list is returned.


Constructor Summary
ContactListenerDialerList()
          Constructs a new empty dialer list implemented by a doubly-linked list.
ContactListenerDialerList(List<Contact> dialerList)
          Constructs a new dialer list using the given dialerList to store the contacts.
 
Method Summary
 void clear()
          Clears the contents of this dialer list.
 List<Contact> getList()
          Returns the internal list containing the contacts to dial.
 void newContact(Contact contact)
          Adds the new contact contact to the dialer list.
 Contact newInstance()
          Constructs and returns a new Contact object.
 Contact removeFirst(int[] contactTypes)
          Removes and returns the first contact with one of the desired types from the dialer list.
 void setList(List<Contact> dialerList)
          Sets the internal list of contacts to dial to dialerList.
 int size(int[] contactTypes)
          Returns the number of contacts of desired types stored into this dialer list.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ContactListenerDialerList

public ContactListenerDialerList()
Constructs a new empty dialer list implemented by a doubly-linked list. The used implementation is provided by the standard LinkedList class.


ContactListenerDialerList

public ContactListenerDialerList(List<Contact> dialerList)
Constructs a new dialer list using the given dialerList to store the contacts. The given list should be empty or contain only Contact instances.

Parameters:
dialerList - the list used to store the contacts.
Throws:
NullPointerException - if dialerList is null.
Method Detail

getList

public List<Contact> getList()
Returns the internal list containing the contacts to dial. This list should contain only non-null Contact instances.

Returns:
the internal dialer list.

setList

public void setList(List<Contact> dialerList)
Sets the internal list of contacts to dial to dialerList.

Parameters:
dialerList - the list used to store the contacts.
Throws:
NullPointerException - if dialerList is null.

size

public int size(int[] contactTypes)
Description copied from interface: DialerList
Returns the number of contacts of desired types stored into this dialer list. This method counts and returns the number of stored contacts whose type identifiers correspond to one of the elements in the given contactTypes array. If the array is null, the check is applied for all contact types. If the size of the list is infinite, this must return Integer.MAX_VALUE. If the dialer list does not allow restriction to specific contact types, this method throws an UnsupportedOperationException.

Specified by:
size in interface DialerList
Parameters:
contactTypes - the array of desired contact types.
Returns:
the number of contacts in the dialer list.

removeFirst

public Contact removeFirst(int[] contactTypes)
Description copied from interface: DialerList
Removes and returns the first contact with one of the desired types from the dialer list. If the list is empty or does not contain any contact of the desired types, this method must throw a NoSuchElementException. If contactTypes is null, any contact type is allowed. If contactTypes is non-null while the dialer list does not support restrictions to specific contact types, this throws an UnsupportedOperationException.

Specified by:
removeFirst in interface DialerList
Parameters:
contactTypes - the array of desired contact types.
Returns:
the removed contact.

newContact

public void newContact(Contact contact)
Adds the new contact contact to the dialer list.

Specified by:
newContact in interface NewContactListener
Parameters:
contact - the contact being added.
Throws:
NullPointerException - if contact is null.

newInstance

public Contact newInstance()
Description copied from interface: ContactFactory
Constructs and returns a new Contact object. If a contact cannot be instantiated, a ContactInstantiationException is thrown.

Specified by:
newInstance in interface ContactFactory
Returns:
the new contact object.

toString

public String toString()
Overrides:
toString in class Object

clear

public void clear()
Description copied from interface: DialerList
Clears the contents of this dialer list. This method does not always reset the size of the list to 0. For example, this method has no effect in the case of infinite dialer lists. For dialer lists with limits on the number of dialed contacts, this resets the size to the maximum number of contacts allowed.

Specified by:
clear in interface DialerList

ContactCenters
V. 0.9.9.

To submit a bug or ask questions, send an e-mail to Richard Simard.