rsvp.controller
Class AppController

java.lang.Object
  extended by rsvp.controller.AppController
All Implemented Interfaces:
AppControllerInterface

public class AppController
extends java.lang.Object
implements AppControllerInterface

The AppController is the main controller for the RSVP application. It provides a layer of functionality related to making new events, retrieving event information, and dealing with event database metadata. The view classes will interact with the AppController after the main application has created an EventDB.

Author:
willb

Field Summary
 
Fields inherited from interface rsvp.controller.AppControllerInterface
DEFAULT_FILENAME
 
Constructor Summary
AppController(EventDBInterface db)
          Creates a new AppController to mediate access to a particular EventDB.
 
Method Summary
 EventControllerInterface getEvent(int id)
          Creates and returns an EventController to mediate access to the event with the given ID.
 int getEventCount()
          Returns the number of events currently in this application's event database.
 boolean load()
          Loads the application state from the default save filename.
 boolean loadFromFile(java.lang.String filename)
          Loads the application state from the given filename.
 boolean save()
          Saves the application state to the default save filename.
 boolean saveToFile(java.lang.String filename)
          Saves the application state to the given filename.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AppController

public AppController(EventDBInterface db)
Creates a new AppController to mediate access to a particular EventDB.

Parameters:
db - an EventDB
Method Detail

getEventCount

public int getEventCount()
Description copied from interface: AppControllerInterface
Returns the number of events currently in this application's event database.

Specified by:
getEventCount in interface AppControllerInterface
Returns:
the number of events currently in this application's event database.

getEvent

public EventControllerInterface getEvent(int id)
Description copied from interface: AppControllerInterface
Creates and returns an EventController to mediate access to the event with the given ID. Throws a BogusParameterException if the given ID is invalid.

Precondition: id must be a valid event ID for the underlying database (as below).

Specified by:
getEvent in interface AppControllerInterface
Parameters:
id - the ID of a given event; must be between 0 (inclusive) and getEventCount() (exclusive).
Returns:
a newly-allocated EventController providing access to the event with the given event ID.

save

public boolean save()
Description copied from interface: AppControllerInterface
Saves the application state to the default save filename.

Note: It is optional to implement this method; if you choose not to, you can simply have it return false. If you do implement this method, you may want to use the DBPersistence class from the rsvp.util package.

Specified by:
save in interface AppControllerInterface
Returns:
true if the save was successful and false otherwise

load

public boolean load()
Description copied from interface: AppControllerInterface
Loads the application state from the default save filename.

Note: It is optional to implement this method; if you choose not to, you can simply have it return false. If you do implement this method, you may want to use the DBPersistence class from the rsvp.util package.

Specified by:
load in interface AppControllerInterface
Returns:
true if the load was successful and false otherwise

saveToFile

public boolean saveToFile(java.lang.String filename)
Description copied from interface: AppControllerInterface
Saves the application state to the given filename.

Note: It is optional to implement this method; if you choose not to, you can simply have it return false. If you do implement this method, you may want to use the DBPersistence class from the rsvp.util package.

Specified by:
saveToFile in interface AppControllerInterface
Parameters:
filename - the file to save to
Returns:
true if the save was successful and false otherwise

loadFromFile

public boolean loadFromFile(java.lang.String filename)
Description copied from interface: AppControllerInterface
Loads the application state from the given filename.

Note: It is optional to implement this method; if you choose not to, you can simply have it return false. If you do implement this method, you may want to use the DBPersistence class from the rsvp.util package.

Specified by:
loadFromFile in interface AppControllerInterface
Parameters:
filename - the file to load from
Returns:
true if the load was successful and false otherwise