org.jasig.schedassist.model
Class AvailableBlockBuilder

java.lang.Object
  extended by org.jasig.schedassist.model.AvailableBlockBuilder

public final class AvailableBlockBuilder
extends Object

Factory for AvailableBlock objects.

Version:
$Id: AvailableBlockBuilder.java 2525 2010-09-10 19:13:01Z npblair $
Author:
Nicholas Blair, nblair@doit.wisc.edu

Field Summary
protected static int MINIMUM_MINUTES
           
protected static Pattern TIME_PATTERN
           
protected static String TIME_REGEX
           
 
Constructor Summary
AvailableBlockBuilder()
           
 
Method Summary
static SortedSet<AvailableBlock> combine(SortedSet<AvailableBlock> smallBlocks)
          Combine adjacent AvailableBlocks in the argument Set.
protected static long convertMinutesToMsec(int minutes)
          Convert integer minutes to milliseconds (as long).
static AvailableBlock createBlock(Date startDate, Date endDate)
          Create a single AvailableBlock with a visitorLimit of 1.
static AvailableBlock createBlock(Date startDate, Date endDate, int visitorLimit)
          Create a single AvailableBlock.
static AvailableBlock createBlock(Date startDate, Date endDate, int visitorLimit, String meetingLocation)
          Create a single AvailableBlock.
static AvailableBlock createBlock(String startTimePhrase, int duration)
          Create a single AvailableBlock that starts at the startTime Phrase (uses CommonDateOperations.parseDateTimePhrase(String) format) and ends duration minutes later.
static AvailableBlock createBlock(String startTimePhrase, String endTimePhrase)
          Create a single AvailableBlock with a visitorLimit of 1 and using this application's common time format ("yyyyMMdd-HHmm") for the start and end datetimes.
static AvailableBlock createBlock(String startTimePhrase, String endTimePhrase, int visitorLimit)
          Create a single AvailableBlock using this applications common time format ("yyyyMMdd-HHmm").
static AvailableBlock createBlock(String startTimePhrase, String endTimePhrase, int visitorLimit, String meetingLocation)
          Create a single AvailableBlock using this applications common time format ("yyyyMMdd-HHmm").
static AvailableBlock createBlockEndsAt(Date endDate, int duration)
          Create a single AvailableBlock that ENDS at the endDate argument and starts duration minutes prior.
static SortedSet<AvailableBlock> createBlocks(String startTimePhrase, String endTimePhrase, String daysOfWeekPhrase, Date startDate, Date endDate)
          Construct a list of AvailableBlock from the following criteria: startTimePhrase and endTimePhrase should look like HH:MM AM/PM. daysOfWeekPhrase looks like "MWF" and uses the following characters: N is Sunday M is Monday T is Tuesday W is Wednesday R is Thursday F is Friday S is Saturday startDate must exist before endDate on the calendar.
static SortedSet<AvailableBlock> createBlocks(String startTimePhrase, String endTimePhrase, String daysOfWeekPhrase, Date startDate, Date endDate, int visitorLimit)
          Construct a list of AvailableBlock from the following criteria: startTimePhrase and endTimePhrase should look like HH:MM AM/PM. daysOfWeekPhrase looks like "MWF" and uses the following characters: N is Sunday M is Monday T is Tuesday W is Wednesday R is Thursday F is Friday S is Saturday startDate must exist before endDate on the calendar.
static SortedSet<AvailableBlock> createBlocks(String startTimePhrase, String endTimePhrase, String daysOfWeekPhrase, Date startDate, Date endDate, int visitorLimit, String meetingLocation)
           
static AvailableBlock createMinimumEndBlock(Date endTime)
          Creates a minimum size AvailableBlock using the argument endTime as the end and MINIMUM_MINUTES minutes prior to endTime as the start.
static AvailableBlock createPreferredMinimumDurationBlock(Date startTime, MeetingDurations preferredMeetingDurations)
          Create an AvailableBlock from the specified startTime to an endTime interpreted from MeetingDurations.getMinLength().
static AvailableBlock createPreferredMinimumDurationBlock(Date startTime, MeetingDurations preferredMeetingDurations, int visitorLimit)
          Create an AvailableBlock from the specified startTime to an endTime interpreted from MeetingDurations.getMinLength().
static AvailableBlock createSmallestAllowedBlock(Date startTime)
          Creates a minimum size AvailableBlock by adding MINIMUM_MINUTES minutes to startTime as the endTime and visitorLimit of 1.
static AvailableBlock createSmallestAllowedBlock(Date startTime, int visitorLimit)
          Creates a minimum size AvailableBlock by adding MINIMUM_MINUTES minutes to startTime as the endTime.
static AvailableBlock createSmallestAllowedBlock(String startTimePhrase)
          Creates a minimum size AvailableBlock by adding MINIMUM_MINUTES minutes to startTime as the endTime and visitorLimit of 1.
static AvailableBlock createSmallestAllowedBlock(String startTimePhrase, int visitorLimit)
          Creates a minimum size AvailableBlock by adding MINIMUM_MINUTES minutes to startTime as the endTime.
static SortedSet<AvailableBlock> expand(AvailableBlock largeBlock, int meetingLengthMinutes)
          Expand one AvailableBlock into a SortedSet of AvailableBlocks with a duration equal to the meetingLengthMinutes argument in minutes.
static SortedSet<AvailableBlock> expand(Set<AvailableBlock> largeBlocks, int meetingLengthMinutes)
          Expand a Set of AvailableBlock into a SortedSet of AvailableBlocks with a duration equal to the meetingLengthMinutes argument in minutes.
protected static void interpretAndUpdateTime(String timePhrase, Calendar toModify)
          Parses the timePhrase (e.g.
protected static List<Date> matchingDays(String daysOfWeekPhrase, Date startDate, Date endDate)
          Returns a List of Date objects that fall between startDate and endDate and exist on the days specified by daysOfWeekPhrase.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TIME_REGEX

protected static final String TIME_REGEX
See Also:
Constant Field Values

TIME_PATTERN

protected static final Pattern TIME_PATTERN

MINIMUM_MINUTES

protected static final int MINIMUM_MINUTES
See Also:
Constant Field Values
Constructor Detail

AvailableBlockBuilder

public AvailableBlockBuilder()
Method Detail

createBlocks

public static SortedSet<AvailableBlock> createBlocks(String startTimePhrase,
                                                     String endTimePhrase,
                                                     String daysOfWeekPhrase,
                                                     Date startDate,
                                                     Date endDate)
                                              throws InputFormatException
Construct a list of AvailableBlock from the following criteria:

Parameters:
startTimePhrase -
endTimePhrase -
daysOfWeekPhrase -
startDate -
endDate -
Returns:
the List of AvailableBlocks that fall within the specified date/time criteria.
Throws:
InputFormatException - if the values for startTimePhrase or endTimePhrase do not match the expected format

createBlocks

public static SortedSet<AvailableBlock> createBlocks(String startTimePhrase,
                                                     String endTimePhrase,
                                                     String daysOfWeekPhrase,
                                                     Date startDate,
                                                     Date endDate,
                                                     int visitorLimit)
                                              throws InputFormatException
Construct a list of AvailableBlock from the following criteria:

Parameters:
startTimePhrase -
endTimePhrase -
daysOfWeekPhrase -
startDate -
endDate -
visitorLimit -
Returns:
the List of AvailableBlocks that fall within the specified date/time criteria.
Throws:
InputFormatException - if the values for startTimePhrase or endTimePhrase do not match the expected format

createBlocks

public static SortedSet<AvailableBlock> createBlocks(String startTimePhrase,
                                                     String endTimePhrase,
                                                     String daysOfWeekPhrase,
                                                     Date startDate,
                                                     Date endDate,
                                                     int visitorLimit,
                                                     String meetingLocation)
                                              throws InputFormatException
Parameters:
startTimePhrase -
endTimePhrase -
daysOfWeekPhrase -
startDate -
endDate -
visitorLimit -
meetingLocation -
Returns:
Throws:
InputFormatException

createBlock

public static AvailableBlock createBlock(Date startDate,
                                         Date endDate)
Create a single AvailableBlock with a visitorLimit of 1.

Parameters:
startDate -
endDate -
Returns:
the new block

createBlock

public static AvailableBlock createBlock(Date startDate,
                                         Date endDate,
                                         int visitorLimit)
Create a single AvailableBlock.

Parameters:
startDate -
endDate -
visitorLimit -
Returns:
the new block

createBlock

public static AvailableBlock createBlock(Date startDate,
                                         Date endDate,
                                         int visitorLimit,
                                         String meetingLocation)
Create a single AvailableBlock.

Parameters:
startDate -
endDate -
visitorLimit -
meetingLocation -
Returns:
the new block

createBlock

public static AvailableBlock createBlock(String startTimePhrase,
                                         String endTimePhrase)
                                  throws InputFormatException
Create a single AvailableBlock with a visitorLimit of 1 and using this application's common time format ("yyyyMMdd-HHmm") for the start and end datetimes.

Parameters:
startTimePhrase -
endTimePhrase -
Returns:
the new block
Throws:
InputFormatException
See Also:
CommonDateOperations.parseDateTimePhrase(String)

createBlock

public static AvailableBlock createBlock(String startTimePhrase,
                                         String endTimePhrase,
                                         int visitorLimit)
                                  throws InputFormatException
Create a single AvailableBlock using this applications common time format ("yyyyMMdd-HHmm").

Parameters:
startTimePhrase -
endTimePhrase -
visitorLimit -
Returns:
the new block
Throws:
InputFormatException
See Also:
CommonDateOperations.parseDateTimePhrase(String)

createBlock

public static AvailableBlock createBlock(String startTimePhrase,
                                         String endTimePhrase,
                                         int visitorLimit,
                                         String meetingLocation)
                                  throws InputFormatException
Create a single AvailableBlock using this applications common time format ("yyyyMMdd-HHmm").

Parameters:
startTimePhrase -
endTimePhrase -
visitorLimit -
Returns:
the new block
Throws:
InputFormatException
See Also:
CommonDateOperations.parseDateTimePhrase(String)

createBlock

public static AvailableBlock createBlock(String startTimePhrase,
                                         int duration)
                                  throws InputFormatException
Create a single AvailableBlock that starts at the startTime Phrase (uses CommonDateOperations.parseDateTimePhrase(String) format) and ends duration minutes later.

Parameters:
startTimePhrase -
duration -
Returns:
the new block
Throws:
InputFormatException

createBlockEndsAt

public static AvailableBlock createBlockEndsAt(Date endDate,
                                               int duration)
Create a single AvailableBlock that ENDS at the endDate argument and starts duration minutes prior.

Parameters:
endDate - end time
duration - how many minutes prior for the start date
Returns:
the new block

createPreferredMinimumDurationBlock

public static AvailableBlock createPreferredMinimumDurationBlock(Date startTime,
                                                                 MeetingDurations preferredMeetingDurations)
Create an AvailableBlock from the specified startTime to an endTime interpreted from MeetingDurations.getMinLength(). visitorLimit for the returned AvailableBlock will be set to 1.

Parameters:
startTime -
preferredMeetingDurations -
Returns:
the new block

createPreferredMinimumDurationBlock

public static AvailableBlock createPreferredMinimumDurationBlock(Date startTime,
                                                                 MeetingDurations preferredMeetingDurations,
                                                                 int visitorLimit)
Create an AvailableBlock from the specified startTime to an endTime interpreted from MeetingDurations.getMinLength().

Parameters:
startTime -
preferredMeetingDurations -
visitorLimit -
Returns:
the new block

createSmallestAllowedBlock

public static AvailableBlock createSmallestAllowedBlock(String startTimePhrase)
                                                 throws InputFormatException
Creates a minimum size AvailableBlock by adding MINIMUM_MINUTES minutes to startTime as the endTime and visitorLimit of 1.

Parameters:
startTimePhrase -
Returns:
the new block
Throws:
InputFormatException

createSmallestAllowedBlock

public static AvailableBlock createSmallestAllowedBlock(String startTimePhrase,
                                                        int visitorLimit)
                                                 throws InputFormatException
Creates a minimum size AvailableBlock by adding MINIMUM_MINUTES minutes to startTime as the endTime.

Parameters:
startTimePhrase -
visitorLimit -
Returns:
the new block
Throws:
InputFormatException
See Also:
createSmallestAllowedBlock(Date, int)

createSmallestAllowedBlock

public static AvailableBlock createSmallestAllowedBlock(Date startTime)
Creates a minimum size AvailableBlock by adding MINIMUM_MINUTES minutes to startTime as the endTime and visitorLimit of 1.

Parameters:
startTime -
Returns:
the new block
See Also:
createSmallestAllowedBlock(Date, int)

createSmallestAllowedBlock

public static AvailableBlock createSmallestAllowedBlock(Date startTime,
                                                        int visitorLimit)
Creates a minimum size AvailableBlock by adding MINIMUM_MINUTES minutes to startTime as the endTime.

Parameters:
startTime -
visitorLimit -
Returns:
the new block

createMinimumEndBlock

public static AvailableBlock createMinimumEndBlock(Date endTime)
Creates a minimum size AvailableBlock using the argument endTime as the end and MINIMUM_MINUTES minutes prior to endTime as the start.

Parameters:
endTime -
Returns:
the new block

expand

public static SortedSet<AvailableBlock> expand(AvailableBlock largeBlock,
                                               int meetingLengthMinutes)
Expand one AvailableBlock into a SortedSet of AvailableBlocks with a duration equal to the meetingLengthMinutes argument in minutes.

Parameters:
largeBlock -
Returns:
the new set

expand

public static SortedSet<AvailableBlock> expand(Set<AvailableBlock> largeBlocks,
                                               int meetingLengthMinutes)
Expand a Set of AvailableBlock into a SortedSet of AvailableBlocks with a duration equal to the meetingLengthMinutes argument in minutes.

Parameters:
largeBlocks -
Returns:
the new set

combine

public static SortedSet<AvailableBlock> combine(SortedSet<AvailableBlock> smallBlocks)
Combine adjacent AvailableBlocks in the argument Set.

Parameters:
smallBlocks -
Returns:
the new set

matchingDays

protected static List<Date> matchingDays(String daysOfWeekPhrase,
                                         Date startDate,
                                         Date endDate)
Returns a List of Date objects that fall between startDate and endDate and exist on the days specified by daysOfWeekPhrase. For instance, passing "MWF", a start Date of June 30 2008, and an end Date of July 04 2008, this method will return a list of 3 Date objects (one for Monday June 30, one for Wednesday July 2, and one for Friday July 4). The time values for returned Dates will always be 00:00:00 (in the JVM's default timezone).

Parameters:
daysOfWeekPhrase -
startDate -
endDate -
Returns:
a List of Date objects that fall between startDate and endDate and exist on the days specified by daysOfWeekPhrase.

interpretAndUpdateTime

protected static void interpretAndUpdateTime(String timePhrase,
                                             Calendar toModify)
                                      throws InputFormatException
Parses the timePhrase (e.g. 9:30 AM) and updates the HOUR_OF_DAY and MINUTE fields on the toModify Calendar. Mutates the toModify Calendar argument.

Parameters:
timePhrase -
toModify -
Throws:
InputFormatException

convertMinutesToMsec

protected static long convertMinutesToMsec(int minutes)
Convert integer minutes to milliseconds (as long).

Parameters:
minutes -
Returns:
the number of milliseconds in the minutes argument


Copyright © 2012 Jasig. All Rights Reserved.