com.example.model
Class Schedule

java.lang.Object
  extended by com.example.model.Schedule

public class Schedule
extends java.lang.Object

A Schedule object takes a set of restraint times along the busy times for a group and returns the free times common to all members of the group that fall within the restraints. The object contains a list of TimeInterval objects for each day Monday-Friday which store the free times for each day.

Since:
Schedule1.1
Version:
Schedule1.1
Author:
Anthony M. Furst

Constructor Summary
Schedule()
           
 
Method Summary
 void addBusyTimesToList(TimeInterval interval, java.util.List<TimeInterval> dayList)
          Adds a busy time TimeInterval to a list of intervals for a particular day.
 void addFreeTimesToList(TimeInterval interval, java.util.List<TimeInterval> dayList)
          Adds a free time TimeInterval to a list of intervals for a particular day.
 java.lang.String combine(java.util.List<TimeInterval> dayList, char day)
          Takes a list of intervals for a particular day, the character symbol for that day, and combines the free times in that list into a string which gets returned.
 java.lang.String getFreeTimes()
          Creates a String representation of the free times for each day, combines those strings into one all-encompassing string and returns it.
 int getMinFreeTimeSpan()
          Return the minimum time span for an interval to be considered valid free time.
 int getTime(java.lang.String time)
          Takes a time that was parsed from the original string, and returns that time as an integer in universal time, to be used in a TimeInterval object.
 void setBusyTimes(java.lang.String times)
          Parses a string of the form "MW 9:00 AM-11:15 AM, T 12:25 PM - 4:00 PM", containing a set of busy times for the schedule object.
 void setFreeTimeConstraints(java.lang.String times)
          Parses a string of the form "MW 9:00 AM-11:15 AM, T 12:25 PM - 4:00 PM", containing the free time constraints for the schedule object.
 void setMinFreeTimeSpan(java.lang.String span)
          Set the minimum time span for an interval to be considered valid free time.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Schedule

public Schedule()
Method Detail

setFreeTimeConstraints

public void setFreeTimeConstraints(java.lang.String times)
                            throws FreeTimesAlreadySetException
Parses a string of the form "MW 9:00 AM-11:15 AM, T 12:25 PM - 4:00 PM", containing the free time constraints for the schedule object. Seperates the intervals of times, creates a TimeInterval object for each one, and adds those objects to the appropriate lists.

Parameters:
times - A string containing a list of free times and during which days those times occur.
Throws:
FreeTimesAlreadySetException

setBusyTimes

public void setBusyTimes(java.lang.String times)
                  throws FreeTimesNotSetException
Parses a string of the form "MW 9:00 AM-11:15 AM, T 12:25 PM - 4:00 PM", containing a set of busy times for the schedule object. Seperates the intervals of times, creates a TimeInterval object for each one, and adds those objects to the appropriate lists.

Parameters:
times - A string containing a list of busy times and during which days those times occur.
Throws:
FreeTimesNotSetException

getTime

public int getTime(java.lang.String time)
Takes a time that was parsed from the original string, and returns that time as an integer in universal time, to be used in a TimeInterval object. The string "2:30 PM" that was parsed from the original string would be returned as 1430.

Parameters:
time - A String representing a particular time.
Returns:
An integer representation of that time in universal format.

addFreeTimesToList

public void addFreeTimesToList(TimeInterval interval,
                               java.util.List<TimeInterval> dayList)
                        throws FreeTimesAlreadySetException
Adds a free time TimeInterval to a list of intervals for a particular day.

Parameters:
interval - A TimeInterval that is to be added to a particular list.
dayList - A list of TimeIntervals to which interval is to be added.
Throws:
FreeTimesAlreadySetException

addBusyTimesToList

public void addBusyTimesToList(TimeInterval interval,
                               java.util.List<TimeInterval> dayList)
                        throws FreeTimesNotSetException
Adds a busy time TimeInterval to a list of intervals for a particular day.

Parameters:
interval - A TimeInterval that is to be added to a particular list.
dayList - A list of TimeIntervals to which interval to be added.
Throws:
FreeTimesNotSetException

getFreeTimes

public java.lang.String getFreeTimes()
Creates a String representation of the free times for each day, combines those strings into one all-encompassing string and returns it.

Returns:
A string representation of all free times common to all sets of times entered and which are within the restraints.

combine

public java.lang.String combine(java.util.List<TimeInterval> dayList,
                                char day)
Takes a list of intervals for a particular day, the character symbol for that day, and combines the free times in that list into a string which gets returned. Returned string has the form "M 6:00 AM-8:00 AM, 12:30 PM-2:00 PM".

Parameters:
dayList - A list of TimeIntervals which is to be combined into a string.
day - The day on which the times in dayList occur.
Returns:
A string representation of all free times contained in dayList.

setMinFreeTimeSpan

public void setMinFreeTimeSpan(java.lang.String span)
Set the minimum time span for an interval to be considered valid free time.

Parameters:
span - String representation of the spanning time.

getMinFreeTimeSpan

public int getMinFreeTimeSpan()
Return the minimum time span for an interval to be considered valid free time.

Returns:
Minimum time span.