|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Observable
mvp.Model
caltool.caldb.UserCalendar
public class UserCalendar
The main data components of a user UserCalendar are a collection of scheduled items and calendar-specific settings. Calendar bookkeeping components are the ID of the user who owns the calendar, the file it's stored on, the currently selected date, and a flag indicating if the calendar requires saving.
In the current design, the concrete representation of the scheduled item list is a TreeMap. UserCalendar provides a getItem method to look up a scheduled item by its unique key. Based on the specs, the unique key for each type of item is as follows:
Item Unique Key ==================================================================== Appointment {date, start time, duration, title} Meeting {date, start time, duration, title} Task {date, time, title, priority} Event {date, title}UserCalendar also provides an array-valued getItems method to retrieve all of the items that are scheduled in a specified interval of date/time. This method is used by the caltool viewing methods to access the scheduled items for a given day, week, or month.
UserCalendar provides general-purpose methods to support the higher-level model classes in the schedule and view packages. The general-purpose methods of UserCalendar do no input validity checking, assuming it has been performed by the higher-level model methods.
Field Summary |
---|
Fields inherited from class mvp.Model |
---|
view |
Constructor Summary | |
---|---|
UserCalendar(java.lang.String uid)
Construct this by constructing and initializing all components. |
Method Summary | |
---|---|
void |
add(ScheduledItem item)
Add the given item to this.items. |
void |
delete(ScheduledItem item)
Delete the given item from this.items. |
ScheduledItem |
getItem(ItemKey key)
Return the scheduled item of the given unique key. |
ScheduledItem[] |
getItems(Date startDate,
Date endDate)
Return an array of items in the given date range. |
ScheduledItem |
getNextItem(ItemKey key)
Return the next item in item-key order after the item with the given key. |
ScheduledItem |
getPrev(ItemKey key)
Return the previous item in item-key order after the item with the given key. |
Date |
getSelectedDate()
Return the date most recently selected by the user via clicking in some view. |
ScheduledItem |
getSelectedItem()
Return the item most recently selected by the user via clicking in some view. |
int |
numItems()
Return the number of items in this.items, for testing purposes. |
void |
setSelectedDate(Date date)
Set the currently selected date to the given date. |
void |
setSelectedItem(ScheduledItem item)
Set the currently selected date to the given date. |
java.lang.String |
toString()
Convert this to a printable string. |
Methods inherited from class mvp.Model |
---|
dump, exit, getView, setView |
Methods inherited from class java.util.Observable |
---|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public UserCalendar(java.lang.String uid)
Method Detail |
---|
public void add(ScheduledItem item)
pre: ; post: // // The input item is added to items via items.put, which means // that item is added if an item of the same key is not already // there. This is marked as changed via Observable.setChanged(). // (items' == items.put(item.getKey(), item)) && this'.hasChanged();
public void delete(ScheduledItem item)
pre: ; post: // // The input item is added to items via HashMap.put, which means // that item is added if an item of the same key is not already // there. This is marked as changed via Observable.setChanged(). // (items' == items.remove(item.getKey(), item)) && this'.hasChanged();
public ScheduledItem getItem(ItemKey key)
pre: ; post: // // If there is an item with the given key in this.items, then the // return value is that item, otherwise the return is null. // (exists (item in items) (item.getKey().equals(key)) && (return == item) || (return == null);
public ScheduledItem[] getItems(Date startDate, Date endDate)
public ScheduledItem getPrev(ItemKey key)
public ScheduledItem getNextItem(ItemKey key)
public Date getSelectedDate()
public void setSelectedDate(Date date)
public ScheduledItem getSelectedItem()
public void setSelectedItem(ScheduledItem item)
public java.lang.String toString()
toString
in class java.lang.Object
public int numItems()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |