The MVC Controller (dcops Package)
The dcops package contains two classes that perform the date difference calculations, and the EventCalendar class to manage Event objects. It also contains EventListManager that acts as the intermediary between the UI and the data store that maintains Event List information.
I created the EventCalendar class as an extension of the GregorianCalendar class, which in turn extends the abstract Calendar class (both of the latter two classes are in the Java SE run-time library, rt.jar). An Event is a named date/time. For example, the Event “Assassination of John F. Kennedy” has the associated date “1963-11-23 16:00:00 GMT”. (Also see Figure 7 for a sample of Events). EventCalendar provides data and methods to manage an Event name and calendar date/time.
I use EventCalendar objects to manage the data in the Start Calendar and Finish Calendar.
Listing 14 – EventCalendar Class
EventListManager is a façade class for access to the data store that maintains one or more lists of Events. It works via methods identified in the EventDataStoreServices interface (defined in the dcstore package). The constructor reads an Event List into an ArrayList; the number of records in an Event data store is small, so I chose to load the entire file in memory. Methods are provided to read records from the Event List and append a record to the Event List.
Listing 15 – EventListManager Class
CalendarOps contains a number of methods to perform calculations on the Start Calendar and Finish Calendar, and to provide access (through getter methods) to data in these objects.
This class defines an enum to handle separate START and FINISH cases, and declares the StartCalendar and FinishCalendar objects. The class methods (all static) are straightforward Java code to process data in these two objects.
Listing 16 – CalendarOps Class Header
CutoverOps is a small class with ‘hardcoded’ declarations for the Julian-Gregorian cut-over date. This class can be expanded to more rigorously handle cut-over dates based upon the location when the Gregorian calendar was adopted, but that requires establishing geo-location data beyond the current scope of this project.
Listing 17 – CutoverOps Class