Class AddressBookController

java.lang.Object
  extended byAddressBookController

public class AddressBookController
extends java.lang.Object

An object of this class performs operations on the address book in response to user gestures on the GUI


Constructor Summary
AddressBookController(FileSystem fileSystem)
          Constructor
 
Method Summary
 void doAdd(AddressBookGUI gui)
          Do the Add a Person Use Case.
 void doDelete(AddressBookGUI gui, int index)
          Do the Delete a Person use case
 void doEdit(AddressBookGUI gui, int index)
          Do the Edit a Person use case
 void doNew(AddressBookGUI gui)
          Do the Create New Address Book Use Case
 void doOfferSaveChanges(AddressBookGUI gui)
          Do Offer to Save Changes extension.
 void doOpen(AddressBookGUI gui)
          Do the Open Existing Address Book Use Case
 void doPrint(AddressBookGUI gui)
          Do the Print Entries Use Case
 void doSave(AddressBookGUI gui)
          Do the Save Address Book Use Case.
 void doSaveAs(AddressBookGUI gui)
          Do the Save Address Book As use case
 void doSortByName(AddressBookGUI gui)
          Do the Sort Entries by Name Use Case
 void doSortByZip(AddressBookGUI gui)
          Do the Sort Entries by ZIP Use Case
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AddressBookController

public AddressBookController(FileSystem fileSystem)
Constructor

Parameters:
fileSystem - the object to use for interacting with the file system
Method Detail

doAdd

public void doAdd(AddressBookGUI gui)
Do the Add a Person Use Case.

Parameters:
gui - the gui that requested this operation

doEdit

public void doEdit(AddressBookGUI gui,
                   int index)
Do the Edit a Person use case

Parameters:
gui - the gui that requested this operation
index - the position of the desired person

doDelete

public void doDelete(AddressBookGUI gui,
                     int index)
Do the Delete a Person use case

Parameters:
gui - the gui that requested this operation
index - the position of the desired person

doSortByName

public void doSortByName(AddressBookGUI gui)
Do the Sort Entries by Name Use Case

Parameters:
gui - the gui that requested this operation

doSortByZip

public void doSortByZip(AddressBookGUI gui)
Do the Sort Entries by ZIP Use Case

Parameters:
gui - the gui that requested this operation

doPrint

public void doPrint(AddressBookGUI gui)
Do the Print Entries Use Case

Parameters:
gui - the gui that requested this operation

doNew

public void doNew(AddressBookGUI gui)
Do the Create New Address Book Use Case

Parameters:
gui - the gui that requested this operation

doOpen

public void doOpen(AddressBookGUI gui)
            throws java.io.IOException,
                   java.lang.ClassCastException,
                   java.lang.ClassNotFoundException,
                   java.lang.InterruptedException,
                   java.lang.SecurityException
Do the Open Existing Address Book Use Case

Parameters:
gui - the gui that requested this operation
Throws:
java.io.IOException - if there is a problem reading the file
java.lang.ClassCastException - if the file does not contain an AddressBook
java.lang.ClassNotFoundException - if the file does not contain an AddressBook, and the class it does contain is not found - this should never happen
java.lang.InterruptedException - if the user cancels the operation
java.lang.SecurityException - if the security manager disallows the operation

doSave

public void doSave(AddressBookGUI gui)
            throws java.io.IOException,
                   java.lang.InterruptedException,
                   java.lang.SecurityException
Do the Save Address Book Use Case. If there is no file for the current address book, doSaveAs() will be done instead

Parameters:
gui - the gui that requested this operation
Throws:
java.io.IOException - if there is a problem writing the file
java.lang.InterruptedException - will be propagated if thrown by doSaveAs()
java.lang.SecurityException - will be propagated if thrown by doSaveAs()

doSaveAs

public void doSaveAs(AddressBookGUI gui)
              throws java.io.IOException,
                     java.lang.InterruptedException,
                     java.lang.SecurityException
Do the Save Address Book As use case

Parameters:
gui - the gui that requested this operation
Throws:
java.io.IOException - if there is a problem writing the file
java.lang.InterruptedException - if the user cancels the operation
java.lang.SecurityException - if the security manager disallows the operation

doOfferSaveChanges

public void doOfferSaveChanges(AddressBookGUI gui)
                        throws java.lang.InterruptedException,
                               java.io.IOException,
                               java.lang.SecurityException
Do Offer to Save Changes extension. This method is called if the user initiates a new, open, or quit operation, or tries to close the window, with unsaved changes to the address book. The user is offered an opportunity to save those changes before proceeding.

Parameters:
gui - the gui that requested this operation
Throws:
java.lang.InterruptedException - if the user cancels the operation
java.io.IOException - will be propagated if thrown by doSave()
java.lang.SecurityException - will be propagated if thrown by doSave()