caltool.caldb
Class ItemKey

java.lang.Object
  extended by caltool.caldb.ItemKey
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable

public class ItemKey
extends java.lang.Object
implements java.lang.Comparable, java.io.Serializable

Class ItemKey is the Map key used to store items in a user calendar. It has five fields, some or all of which are used as the key for an item, per the following table:

    Field     Used For: Appt  Meeting   Task   Event
    =====================================================
    date                yes    yes      yes     yes
    time                yes    yes      yes     no
    duration            yes    yes      no      no
    title               yes    yes      yes     yes
    priority            no     no       yes     no
                                                                       
ItemKey is suitable for use in either a HashMap or a TreeMap, since it specializes Object.hashCode (for the HashMap) and implements Comparable (for the TreeMap).

See Also:
Serialized Form

Field Summary
protected  Date date
          The date field used in all keys
protected  Duration duration
          The duration field used in appointment and meeting keys
protected  Time time
          The time field used in all keys except for events
protected  java.lang.String title
          The title field used in all keys
 
Constructor Summary
ItemKey(Date date, Time time, Duration duration, java.lang.String title, int priority)
          Construct this with the given field values.
 
Method Summary
protected  int compareAppointmentKeys(ItemKey apptKey)
          Compare this and the given appointment/meeting key.
protected  int compareTaskKeys(ItemKey taskKey)
          Compare this and the given task key.
 int compareTo(java.lang.Object o)
          Define compareTo based on the total ordering of items defined in the spec.
 boolean equals(java.lang.Object obj)
          Define equality for this as componentwise equality.
 int hashCode()
          Define this' hash code as the sum of component hash codes.
protected  boolean isEventKey()
          Return true if this is an event key.
protected  boolean isTaskKey()
          Return true if this is a task key.
 java.lang.String toString()
          Convert this to a string representation.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

date

protected Date date
The date field used in all keys


time

protected Time time
The time field used in all keys except for events


duration

protected Duration duration
The duration field used in appointment and meeting keys


title

protected java.lang.String title
The title field used in all keys

Constructor Detail

ItemKey

public ItemKey(Date date,
               Time time,
               Duration duration,
               java.lang.String title,
               int priority)
Construct this with the given field values.

Method Detail

equals

public boolean equals(java.lang.Object obj)
Define equality for this as componentwise equality.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Define this' hash code as the sum of component hash codes.

Overrides:
hashCode in class java.lang.Object

compareTo

public int compareTo(java.lang.Object o)
Define compareTo based on the total ordering of items defined in the spec. Viz., all items in Day[i] are less than all items in Day[j], when the the calendar date of Day[i] precedes Day[j]. For a given day, the order is:

Specified by:
compareTo in interface java.lang.Comparable

toString

public java.lang.String toString()
Convert this to a string representation.

Overrides:
toString in class java.lang.Object

compareAppointmentKeys

protected int compareAppointmentKeys(ItemKey apptKey)
Compare this and the given appointment/meeting key.


compareTaskKeys

protected int compareTaskKeys(ItemKey taskKey)
Compare this and the given task key.


isEventKey

protected boolean isEventKey()
Return true if this is an event key. Per the field definition table, an event key is uniquely determined by a non-null time field and null priority field.


isTaskKey

protected boolean isTaskKey()
Return true if this is a task key. Per the field definition table, a task key is uniquely determined by a positive priority field.