rsvp.controller
Class EventController

java.lang.Object
  extended by rsvp.controller.EventController
All Implemented Interfaces:
EventControllerInterface

public class EventController
extends java.lang.Object
implements EventControllerInterface

An EventController mediates interactions between the view layer and a particular Event.

Author:
willb
See Also:
Event

Constructor Summary
EventController(EventInterface event)
          Constructs an EventController to mediate access to a given Event.
 
Method Summary
 void addResponse(EmailAddressInterface guest, int status, java.lang.String comment)
          Adds a new response to this event, indicating whether or not a particular guest can attend.
 void delete(java.lang.String passcode)
          Deletes the given Event by invoking its delete() method.
 SimpleDate getEventDate()
          Returns the date of this event.
 java.lang.String getEventLocation()
          Returns the location of this event.
 java.lang.String getEventName()
          Returns the name of this event.
 EmailAddressInterface getEventOrganizer()
          Returns the EmailAddress of this event's organizer or host.
 ResponseControllerInterface getResponseController(int id)
          Returns a ResponseController to mediate access to the Response with the given ID.
 void setEventDate(SimpleDate date, java.lang.String passcode)
          Updates this event by changing its date.
 void setEventLocation(java.lang.String newLoc, java.lang.String passcode)
          Updates this event by changing its location.
 void setEventName(java.lang.String newName, java.lang.String passcode)
          Updates this event by changing its name.
 void setEventOrganizer(EmailAddressInterface email, java.lang.String passcode)
          Updates this event by changing its organizer.
 int totalResponsesForEvent()
          Returns the total number of responses for this event, including "yes", "no", and "maybe" responses.
 int yesResponsesForEvent()
          Returns the total number of "yes" responses for this event.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventController

public EventController(EventInterface event)
Constructs an EventController to mediate access to a given Event.

Parameters:
event -
Method Detail

delete

public void delete(java.lang.String passcode)
Description copied from interface: EventControllerInterface
Deletes the given Event by invoking its delete() method. If the passcode supplied is not the same as the Event's passcode, this method will throw a PermissionException.

Specified by:
delete in interface EventControllerInterface
Parameters:
passcode - the passcode for this Event

setEventName

public void setEventName(java.lang.String newName,
                         java.lang.String passcode)
Description copied from interface: EventControllerInterface
Updates this event by changing its name. If the passcode supplied is not the same as the Event's passcode, this method will throw a PermissionException.

Specified by:
setEventName in interface EventControllerInterface

setEventOrganizer

public void setEventOrganizer(EmailAddressInterface email,
                              java.lang.String passcode)
Description copied from interface: EventControllerInterface
Updates this event by changing its organizer. If the passcode supplied is not the same as the Event's passcode, this method will throw a PermissionException.

Specified by:
setEventOrganizer in interface EventControllerInterface
Parameters:
email - the email address of the new organizer

setEventDate

public void setEventDate(SimpleDate date,
                         java.lang.String passcode)
Description copied from interface: EventControllerInterface
Updates this event by changing its date. If the passcode supplied is not the same as the Event's passcode, this method will throw a PermissionException.

Specified by:
setEventDate in interface EventControllerInterface
Parameters:
date - the new date

setEventLocation

public void setEventLocation(java.lang.String newLoc,
                             java.lang.String passcode)
Description copied from interface: EventControllerInterface
Updates this event by changing its location. If the passcode supplied is not the same as the Event's passcode, this method will throw a PermissionException.

Specified by:
setEventLocation in interface EventControllerInterface
Parameters:
newLoc - the new Location of this event

getEventName

public java.lang.String getEventName()
Description copied from interface: EventControllerInterface
Returns the name of this event.

Specified by:
getEventName in interface EventControllerInterface
Returns:

getEventOrganizer

public EmailAddressInterface getEventOrganizer()
Description copied from interface: EventControllerInterface
Returns the EmailAddress of this event's organizer or host.

Specified by:
getEventOrganizer in interface EventControllerInterface
Returns:

getEventDate

public SimpleDate getEventDate()
Description copied from interface: EventControllerInterface
Returns the date of this event.

Specified by:
getEventDate in interface EventControllerInterface
Returns:

getEventLocation

public java.lang.String getEventLocation()
Description copied from interface: EventControllerInterface
Returns the location of this event.

Specified by:
getEventLocation in interface EventControllerInterface
Returns:

totalResponsesForEvent

public int totalResponsesForEvent()
Description copied from interface: EventControllerInterface
Returns the total number of responses for this event, including "yes", "no", and "maybe" responses.

Specified by:
totalResponsesForEvent in interface EventControllerInterface
Returns:

yesResponsesForEvent

public int yesResponsesForEvent()
Description copied from interface: EventControllerInterface
Returns the total number of "yes" responses for this event.

Specified by:
yesResponsesForEvent in interface EventControllerInterface
Returns:

addResponse

public void addResponse(EmailAddressInterface guest,
                        int status,
                        java.lang.String comment)
Description copied from interface: EventControllerInterface
Adds a new response to this event, indicating whether or not a particular guest can attend.

Preconditions: see below.

Specified by:
addResponse in interface EventControllerInterface
Parameters:
guest - the email address of the responding guest. Must correspond to a valid email address -- if it does not, this method will throw a BogusParameterException.
status - the response status. Must be one of Response.YES, Response.NO, or Response.MAYBE -- if it is not, this method will throw a BogusParameterException.
comment - the text of any explanatory comment that this guest has included with her reply.

getResponseController

public ResponseControllerInterface getResponseController(int id)
Description copied from interface: EventControllerInterface
Returns a ResponseController to mediate access to the Response with the given ID. If the given ID is not valid, this method must throw a BogusParameterException.

Preconditions: id must be valid, as below.

Specified by:
getResponseController in interface EventControllerInterface
Parameters:
id - a valid response identifier -- that is, one that is between 0 (inclusive) and totalResponsesForEvent() (exclusive)
Returns: