com.std.model
Class CalendarModel

java.lang.Object
extended by com.std.model.CalendarModel
All Implemented Interfaces:
java.lang.Iterable<Appointment>, java.util.Collection<Appointment>, java.util.NavigableSet<Appointment>, java.util.Set<Appointment>, java.util.SortedSet<Appointment>

public class CalendarModel
extends java.lang.Object
implements java.util.NavigableSet<Appointment>

facade for the functionality of the model

Author:
xxx

Constructor Summary
CalendarModel()
          creates a new calendar model
 
Method Summary
 boolean add(Appointment e)
           
 boolean addAll(java.util.Collection<? extends Appointment> c)
           
 void appointmentChanged(AppointmentSet source, Appointment subSource)
          callback for when an appointment has been changed
 void appointmentSetChanged(AppointmentSet source, Appointment subSource)
          callback for when an appointment has been added or removed
 void appointmentSetReplaced()
          callback for when the current appointment set has been replaced
 Appointment ceiling(Appointment e)
           
 void clear()
           
 java.util.Comparator<? super Appointment> comparator()
           
 boolean contains(java.lang.Object o)
           
 boolean containsAll(java.util.Collection<?> c)
           
 void currentAppointmentChanged()
          callback for when the current appointment has been changed
 java.util.Iterator<Appointment> descendingIterator()
           
 java.util.NavigableSet<Appointment> descendingSet()
           
 Appointment first()
           
 void firstAppointment()
          sets the current appointment to the first chronological appointment
 Appointment floor(Appointment e)
           
 AppointmentSet getAllAppointments()
           
 Appointment getCurrentAppointment()
           
 java.util.Date getCurrentDate()
           
 AppointmentSet getDayAppointments()
           
 java.lang.String getFileName()
           
 AppointmentSet getGridMonthAppointments()
           
 AppointmentSet getMonthAppointments()
           
 java.util.List<AppointmentSet> getMonthWeeksAppointments()
           
 AppointmentSet getWeekAppointments()
           
 java.util.List<AppointmentSet> getWeekDaysAppointments()
           
 java.util.SortedSet<Appointment> headSet(Appointment toElement)
           
 java.util.NavigableSet<Appointment> headSet(Appointment toElement, boolean inclusive)
           
 Appointment higher(Appointment e)
           
 boolean isEmpty()
           
 boolean isModified()
           
 java.util.Iterator<Appointment> iterator()
           
 Appointment last()
           
 void lastAppointment()
          sets the current appointment to the last chronological appointment
 void load()
          loads this object from a file
 void load(boolean discardOld)
          loads this object from a file
 void load(java.lang.String fileName)
          loads this object from a file
 void load(java.lang.String fileName, boolean discardOld)
          loads this object from a file
 void loadNew()
          sets this object to a new instance
 void loadNew(boolean discardOld)
          sets this object to a new instance
 Appointment lower(Appointment e)
           
 void nextAppointment()
          advances the current appointment to the next chronological appointment or, if the target is null, sets it to the first chronological appointment
 void nextDay()
          advances the current date by one day
 void nextMonth()
          advances the current date by one month
 void nextWeek()
          advances the current date by one week
 void nextYear()
          advances the current date by one year
 ObservableEvent onAppointmentChanged()
           
 ObservableEvent onAppointmentSelectionChanged()
           
 ObservableEvent onAppointmentSetChanged()
           
 ObservableEvent onDateSelectionChanged()
           
 Appointment pollFirst()
           
 Appointment pollLast()
           
 void previousAppointment()
          advances the current appointment to the previous chronological appointment or, if the target is null, sets it to the last chronological appointment
 void previousDay()
          regresses the current date by one day
 void previousMonth()
          regresses the current date by one month
 void previousWeek()
          regresses the current date by one week
 void previousYear()
          regresses the current date by one year
 boolean remove(java.lang.Object o)
           
 boolean removeAll(java.util.Collection<?> c)
           
 boolean retainAll(java.util.Collection<?> c)
           
 void save()
          saves this object to its previously specified file
 void save(java.lang.String fileName)
          saves this object to a file
 void save(java.lang.String fileName, boolean overwriteOld)
          saves this object to a file
 void setCurrentAppointment(Appointment target)
          sets the current appointment
 void setCurrentDate(java.util.Date target)
          sets the current date
 int size()
           
 java.util.SortedSet<Appointment> subSet(Appointment fromElement, Appointment toElement)
           
 java.util.NavigableSet<Appointment> subSet(Appointment fromElement, boolean fromInclusive, Appointment toElement, boolean toInclusive)
           
 java.util.SortedSet<Appointment> tailSet(Appointment fromElement)
           
 java.util.NavigableSet<Appointment> tailSet(Appointment fromElement, boolean inclusive)
           
 java.lang.Object[] toArray()
           
<T> T[]
toArray(T[] a)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Set
equals, hashCode
 

Constructor Detail

CalendarModel

public CalendarModel()
creates a new calendar model

Method Detail

add

public boolean add(Appointment e)
Specified by:
add in interface java.util.Collection<Appointment>
Specified by:
add in interface java.util.Set<Appointment>

addAll

public boolean addAll(java.util.Collection<? extends Appointment> c)
Specified by:
addAll in interface java.util.Collection<Appointment>
Specified by:
addAll in interface java.util.Set<Appointment>

appointmentChanged

public void appointmentChanged(AppointmentSet source,
Appointment subSource)
callback for when an appointment has been changed

Parameters:
source - the set that has been changed
subSource - the appointment that has been changed

appointmentSetChanged

public void appointmentSetChanged(AppointmentSet source,
Appointment subSource)
callback for when an appointment has been added or removed

Parameters:
source - the set that has been changed
subSource - the appointment that has been changed

appointmentSetReplaced

public void appointmentSetReplaced()
callback for when the current appointment set has been replaced


ceiling

public Appointment ceiling(Appointment e)
Specified by:
ceiling in interface java.util.NavigableSet<Appointment>

clear

public void clear()
Specified by:
clear in interface java.util.Collection<Appointment>
Specified by:
clear in interface java.util.Set<Appointment>

comparator

public java.util.Comparator<? super Appointment> comparator()
Specified by:
comparator in interface java.util.SortedSet<Appointment>

contains

public boolean contains(java.lang.Object o)
Specified by:
contains in interface java.util.Collection<Appointment>
Specified by:
contains in interface java.util.Set<Appointment>

containsAll

public boolean containsAll(java.util.Collection<?> c)
Specified by:
containsAll in interface java.util.Collection<Appointment>
Specified by:
containsAll in interface java.util.Set<Appointment>

currentAppointmentChanged

public void currentAppointmentChanged()
callback for when the current appointment has been changed


descendingIterator

public java.util.Iterator<Appointment> descendingIterator()
Specified by:
descendingIterator in interface java.util.NavigableSet<Appointment>

descendingSet

public java.util.NavigableSet<Appointment> descendingSet()
Specified by:
descendingSet in interface java.util.NavigableSet<Appointment>

first

public Appointment first()
Specified by:
first in interface java.util.SortedSet<Appointment>

firstAppointment

public void firstAppointment()
sets the current appointment to the first chronological appointment


floor

public Appointment floor(Appointment e)
Specified by:
floor in interface java.util.NavigableSet<Appointment>

getAllAppointments

public AppointmentSet getAllAppointments()
Returns:
a new AppointmentSet containing all the appointments in this set

getCurrentAppointment

public Appointment getCurrentAppointment()
Returns:
the currently selected appointment

getCurrentDate

public java.util.Date getCurrentDate()
Returns:
the currently selected date

getDayAppointments

public AppointmentSet getDayAppointments()
Returns:
an AppointmentSet containing all the appointments for the current day

getFileName

public java.lang.String getFileName()
Returns:
the name of the file this object represents

getGridMonthAppointments

public AppointmentSet getGridMonthAppointments()
Returns:
an AppointmentSet containing all the appointments for the current grid month

getMonthAppointments

public AppointmentSet getMonthAppointments()
Returns:
an AppointmentSet containing all the appointments for the current month

getMonthWeeksAppointments

public java.util.List<AppointmentSet> getMonthWeeksAppointments()
Returns:
a list of AppointmentSets containing all the appointments for the weeks in the current month

getWeekAppointments

public AppointmentSet getWeekAppointments()
Returns:
an AppointmentSet containing all the appointments for the current week

getWeekDaysAppointments

public java.util.List<AppointmentSet> getWeekDaysAppointments()
Returns:
a list of AppointmentSets containing all the appointments for the days in the current week

headSet

public java.util.SortedSet<Appointment> headSet(Appointment toElement)
Specified by:
headSet in interface java.util.NavigableSet<Appointment>
Specified by:
headSet in interface java.util.SortedSet<Appointment>

headSet

public java.util.NavigableSet<Appointment> headSet(Appointment toElement,
boolean inclusive)
Specified by:
headSet in interface java.util.NavigableSet<Appointment>

higher

public Appointment higher(Appointment e)
Specified by:
higher in interface java.util.NavigableSet<Appointment>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection<Appointment>
Specified by:
isEmpty in interface java.util.Set<Appointment>

isModified

public boolean isModified()
Returns:
true iff this set has been modified since the last save or load operation

iterator

public java.util.Iterator<Appointment> iterator()
Specified by:
iterator in interface java.lang.Iterable<Appointment>
Specified by:
iterator in interface java.util.Collection<Appointment>
Specified by:
iterator in interface java.util.NavigableSet<Appointment>
Specified by:
iterator in interface java.util.Set<Appointment>

last

public Appointment last()
Specified by:
last in interface java.util.SortedSet<Appointment>

lastAppointment

public void lastAppointment()
sets the current appointment to the last chronological appointment


load

public void load()
throws java.lang.ClassNotFoundException,
java.io.IOException
loads this object from a file

Throws:
java.io.IOException
java.lang.IllegalArgumentException - when the file hasn't been previously saved
java.lang.IllegalStateException - when changes have been made since the last save or load operation
java.lang.ClassNotFoundException

load

public void load(boolean discardOld)
throws java.lang.ClassNotFoundException,
java.io.IOException
loads this object from a file

Parameters:
discardOld - setting this to true will automatically discard any changes to the current object. setting this to false will throw an IllegalStateException when the object has been changed since the last save or load
Throws:
java.io.IOException
java.lang.IllegalArgumentException - when the file hasn't been previously saved
java.lang.IllegalStateException - when changes have been made since the last save or load operation and discardOld is false.
java.lang.ClassNotFoundException

load

public void load(java.lang.String fileName)
throws java.lang.ClassNotFoundException,
java.io.IOException
loads this object from a file

Parameters:
fileName - the name of the file to load from. if this is null, default to the current file name
Throws:
java.io.IOException
java.lang.IllegalArgumentException - when fileName is null and the file hasn't been previously saved
java.lang.IllegalStateException - when changes have been made since the last save or load operation
java.lang.ClassNotFoundException

load

public void load(java.lang.String fileName,
boolean discardOld)
throws java.lang.ClassNotFoundException,
java.io.IOException
loads this object from a file

Parameters:
fileName - the name of the file to load from. if this is null, default to the current file name
discardOld - setting this to true will automatically discard any changes to the current object. setting this to false will throw an IllegalStateException when the object has been changed since the last save or load
Throws:
java.io.IOException
java.lang.IllegalArgumentException - when fileName is null and the file hasn't been previously saved
java.lang.IllegalStateException - when changes have been made since the last save or load operation and discardOld is false.
java.lang.ClassNotFoundException

loadNew

public void loadNew()
sets this object to a new instance

Throws:
java.io.IOException
java.lang.IllegalStateException - when changes have been made since the last save or load operation

loadNew

public void loadNew(boolean discardOld)
sets this object to a new instance

Parameters:
discardOld - setting this to true will automatically discard any changes to the current object. setting this to false will throw an IllegalStateException when the object has been changed since the last save or load
Throws:
java.io.IOException
java.lang.IllegalStateException - when changes have been made since the last save or load operation and discardOld is false.

lower

public Appointment lower(Appointment e)
Specified by:
lower in interface java.util.NavigableSet<Appointment>

nextAppointment

public void nextAppointment()
advances the current appointment to the next chronological appointment or, if the target is null, sets it to the first chronological appointment


nextDay

public void nextDay()
advances the current date by one day


nextMonth

public void nextMonth()
advances the current date by one month


nextWeek

public void nextWeek()
advances the current date by one week


nextYear

public void nextYear()
advances the current date by one year


onAppointmentChanged

public ObservableEvent onAppointmentChanged()
Returns:
the observable event that will send out notifications when an Appointment has been changed

onAppointmentSelectionChanged

public ObservableEvent onAppointmentSelectionChanged()
Returns:
the observable event that will send out notifications when the current appointment has been changed

onAppointmentSetChanged

public ObservableEvent onAppointmentSetChanged()
Returns:
the observable event that will send out notifications when an Appointment has been added or removed

onDateSelectionChanged

public ObservableEvent onDateSelectionChanged()
Returns:
the observable event that will send out notifications when the current date has been changed

pollFirst

public Appointment pollFirst()
Specified by:
pollFirst in interface java.util.NavigableSet<Appointment>

pollLast

public Appointment pollLast()
Specified by:
pollLast in interface java.util.NavigableSet<Appointment>

previousAppointment

public void previousAppointment()
advances the current appointment to the previous chronological appointment or, if the target is null, sets it to the last chronological appointment


previousDay

public void previousDay()
regresses the current date by one day


previousMonth

public void previousMonth()
regresses the current date by one month


previousWeek

public void previousWeek()
regresses the current date by one week


previousYear

public void previousYear()
regresses the current date by one year


remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.Collection<Appointment>
Specified by:
remove in interface java.util.Set<Appointment>

removeAll

public boolean removeAll(java.util.Collection<?> c)
Specified by:
removeAll in interface java.util.Collection<Appointment>
Specified by:
removeAll in interface java.util.Set<Appointment>

retainAll

public boolean retainAll(java.util.Collection<?> c)
Specified by:
retainAll in interface java.util.Collection<Appointment>
Specified by:
retainAll in interface java.util.Set<Appointment>

save

public void save()
throws java.io.IOException
saves this object to its previously specified file

Throws:
java.io.IOException
java.lang.IllegalArgumentException - when the file hasn't been previously saved

save

public void save(java.lang.String fileName)
throws java.io.IOException
saves this object to a file

Parameters:
fileName - the name of the file to save to. if this is null, default to the current file name
Throws:
java.io.IOException
java.lang.IllegalArgumentException - when fileName is null and the file hasn't been previously saved
java.lang.IllegalStateException - when fileName exists but is not this object

save

public void save(java.lang.String fileName,
boolean overwriteOld)
throws java.io.IOException
saves this object to a file

Parameters:
fileName - the name of the file to save to. if this is null, default to the current file name
overwriteOld - setting this to true will automatically overwrite any file with the specified file name. setting this to false will throw an IllegalStateException when fileName already exists
Throws:
java.io.IOException
java.lang.IllegalArgumentException - when fileName is null and the file hasn't been previously saved
java.lang.IllegalStateException - when fileName exists but is not this object and overwriteOld is false.

setCurrentAppointment

public void setCurrentAppointment(Appointment target)
sets the current appointment

Throws:
java.lang.IllegalArgumentException - if the intended target is null or not a member of the parent set

setCurrentDate

public void setCurrentDate(java.util.Date target)
sets the current date


size

public int size()
Specified by:
size in interface java.util.Collection<Appointment>
Specified by:
size in interface java.util.Set<Appointment>

subSet

public java.util.SortedSet<Appointment> subSet(Appointment fromElement,
Appointment toElement)
Specified by:
subSet in interface java.util.NavigableSet<Appointment>
Specified by:
subSet in interface java.util.SortedSet<Appointment>

subSet

public java.util.NavigableSet<Appointment> subSet(Appointment fromElement,
boolean fromInclusive,
Appointment toElement,
boolean toInclusive)
Specified by:
subSet in interface java.util.NavigableSet<Appointment>

tailSet

public java.util.SortedSet<Appointment> tailSet(Appointment fromElement)
Specified by:
tailSet in interface java.util.NavigableSet<Appointment>
Specified by:
tailSet in interface java.util.SortedSet<Appointment>

tailSet

public java.util.NavigableSet<Appointment> tailSet(Appointment fromElement,
boolean inclusive)
Specified by:
tailSet in interface java.util.NavigableSet<Appointment>

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection<Appointment>
Specified by:
toArray in interface java.util.Set<Appointment>

toArray

public <T> T[] toArray(T[] a)
Specified by:
toArray in interface java.util.Collection<Appointment>
Specified by:
toArray in interface java.util.Set<Appointment>