de.enough.polish.calendar
Class CalendarEntry

java.lang.Object
  extended by de.enough.polish.calendar.CalendarEntry
All Implemented Interfaces:
Externalizable, Serializable

public class CalendarEntry
extends Object
implements Externalizable

Calendar Entry class provides access to data in events provided in the calendar.

Author:
Ramakrishna, Nagendra Sharma, Robert Virkus (clean up)

Field Summary
static String CLASS_CONFIDENTIAL
          For entries that are classified confidential.
static String CLASS_PRIVATE
          For entries that are classified private.
static String CLASS_PUBLIC
          For entries that are classified public.
static int REOCCURENCE_DAILY
          this entry recurs daily
static int REOCCURENCE_MONTHLY
          this entry recurs monthly
static int REOCCURENCE_NONE
          this entry does not recur at all
static int REOCCURENCE_WEEKLY
          this entry recurs weekly
static int REOCCURENCE_YEARLY
          this entry recurs yearly
 
Constructor Summary
CalendarEntry()
          Constructor for CalendarEntry
CalendarEntry(CalendarEntry original)
          Creates a new entry based on the specified one
CalendarEntry(String summary, CalendarCategory category, int year, int month, int day)
           
CalendarEntry(String summary, CalendarCategory category, int year, int month, int day, int reoccurence)
           
CalendarEntry(String summary, CalendarCategory category, int year, int month, int day, String description)
           
CalendarEntry(String summary, CalendarCategory category, int year, int month, int day, String description, int reoccurence)
           
CalendarEntry(String summary, CalendarCategory category, TimePoint start)
           
CalendarEntry(String summary, CalendarCategory category, TimePoint start, int reoccurence)
           
CalendarEntry(String summary, CalendarCategory category, TimePoint start, String description)
           
CalendarEntry(String summary, CalendarCategory category, TimePoint start, String description, int reoccurence)
           
CalendarEntry(TimePoint startDate, String description)
          Creates a new CalendarEntry
 
Method Summary
 CalendarEntry clone(TimePoint start)
          Clones this calendar entry for the specified date.
 int getAlarm()
           
 CalendarAlarm getCalendarAlarm()
           
 CalendarCategory getCategory()
           
 CalendarEntry[] getChildren()
          Gets the children of a repeating entry.
 String getClassType()
          Retrieves the class of this entry.
 String getDescription()
           
 int getDurationInMinutes()
           
 TimePoint getEndDate()
           
 Object getField(String name)
          Retrieves another field that is stored within this CalendarEntry
 long getGuid()
          Generates a global unique ID for this entry.
 String getId()
           
 String getLocation()
           
 String getNotes()
           
 String getOrganizer()
           
 CalendarEntry getParent()
          Retrieves access to the original calendar entry.
 EventRepeatRule getRepeat()
          Retrieves the event repeat rule for this entry
 int getSequence()
           
 TimePoint getStartDate()
           
 String getStatus()
           
 String getSummary()
           
 String getSummary(TimePoint calendarTimePoint)
           
 CalendarTextResolver getTextResolver()
          Retrieves the used text resolver.
 TimeZone getTimeZone()
           
 int getType()
          Retrieves the type of this entry.
 String getUserId()
           
 int getYearsSinceStart(TimePoint timePoint)
          Retrieves the difference in years between the start date of this entry and the specified time point
 boolean isAllday()
           
 boolean matches(TimePeriod period)
          Checks if this entry either starts or ends in the given time period
 void read(DataInputStream in)
          Restores the internal instance fields from the given input stream.
 void setAlarm(int alarm)
           
 void setAllday(boolean isAllday)
          setter method for isAllday of calendar entry
 void setCalendarAlarm(CalendarAlarm calendarAlarm)
          setter method for calendarAlarm
 void setCategory(CalendarCategory category)
          setter method for CalendarCategory
 void setChildren(CalendarEntryList entryList)
          Sets the children of a repeating entry.
 void setClassType(String classType)
          Sets the class of this entry
 void setDescription(String description)
          setter method for event description
 void setDurationInMinutes(int durationInMinutes)
          setter method for duration in minutes
 void setEndDate(Date date)
           
 void setEndDate(TimePoint endDate)
          setter method for end date
 void setField(String name, Object value)
          Adds an arbitrary field value to this entry
 void setId(String id)
          setter method for id
 void setLocation(String location)
          setter method for location
 void setNotes(String notes)
           
 void setOrganizer(String organizer)
          setter method for organizer
 void setReoccurence(int reoccurence)
          Specifies a simple reoccurence for this entry.
 void setRepeat(EventRepeatRule eventRepeatRule)
          Sets a repeat rule for this entry.
 void setSequence(int sequence)
          setter method for sequence of calendar entry
 void setStartDate(Date date)
           
 void setStartDate(TimePoint startDate)
          setter method for start date
 void setStartDate(TimePoint startDate, int durationInMinutes)
          setter method to set starting date and duration in minutes for calendar entry
 void setStatus(String status)
          setter method for status
 void setSummary(String summary)
          setter method for summary of calendar entry
 void setTextResolver(CalendarTextResolver resolver)
          Sets a text resolver that is used for resolving the summary and description of this CalendarEntry.
 void setTimeZone(TimeZone timeZone)
          setter method for local time zone
 void setType(int type)
          Specifies a type of this entry.
 void setUserId(String userId)
           
 void write(DataOutputStream out)
          Stores the internal instance fields to the output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REOCCURENCE_NONE

public static final int REOCCURENCE_NONE
this entry does not recur at all

See Also:
Constant Field Values

REOCCURENCE_DAILY

public static final int REOCCURENCE_DAILY
this entry recurs daily

See Also:
Constant Field Values

REOCCURENCE_WEEKLY

public static final int REOCCURENCE_WEEKLY
this entry recurs weekly

See Also:
Constant Field Values

REOCCURENCE_MONTHLY

public static final int REOCCURENCE_MONTHLY
this entry recurs monthly

See Also:
Constant Field Values

REOCCURENCE_YEARLY

public static final int REOCCURENCE_YEARLY
this entry recurs yearly

See Also:
Constant Field Values

CLASS_PUBLIC

public static final String CLASS_PUBLIC
For entries that are classified public.

See Also:
Constant Field Values

CLASS_PRIVATE

public static final String CLASS_PRIVATE
For entries that are classified private.

See Also:
Constant Field Values

CLASS_CONFIDENTIAL

public static final String CLASS_CONFIDENTIAL
For entries that are classified confidential.

See Also:
Constant Field Values
Constructor Detail

CalendarEntry

public CalendarEntry()
Constructor for CalendarEntry


CalendarEntry

public CalendarEntry(String summary,
                     CalendarCategory category,
                     int year,
                     int month,
                     int day)

CalendarEntry

public CalendarEntry(String summary,
                     CalendarCategory category,
                     int year,
                     int month,
                     int day,
                     int reoccurence)

CalendarEntry

public CalendarEntry(String summary,
                     CalendarCategory category,
                     int year,
                     int month,
                     int day,
                     String description)

CalendarEntry

public CalendarEntry(String summary,
                     CalendarCategory category,
                     int year,
                     int month,
                     int day,
                     String description,
                     int reoccurence)

CalendarEntry

public CalendarEntry(String summary,
                     CalendarCategory category,
                     TimePoint start)

CalendarEntry

public CalendarEntry(String summary,
                     CalendarCategory category,
                     TimePoint start,
                     int reoccurence)

CalendarEntry

public CalendarEntry(String summary,
                     CalendarCategory category,
                     TimePoint start,
                     String description)

CalendarEntry

public CalendarEntry(String summary,
                     CalendarCategory category,
                     TimePoint start,
                     String description,
                     int reoccurence)

CalendarEntry

public CalendarEntry(TimePoint startDate,
                     String description)
Creates a new CalendarEntry

Parameters:
startDate -
description -

CalendarEntry

public CalendarEntry(CalendarEntry original)
Creates a new entry based on the specified one

Parameters:
original - the original entry of which all relevant settings are copied
Method Detail

getCalendarAlarm

public CalendarAlarm getCalendarAlarm()
Returns:
returns alarm setting of calendar entry

getCategory

public CalendarCategory getCategory()
Returns:
returns category of calendar entry

getDescription

public String getDescription()
Returns:
returns category of calendar entry

getStartDate

public TimePoint getStartDate()
Returns:
returns starting date of calendar entry

getEndDate

public TimePoint getEndDate()
Returns:
returns ending date of calendar entry

getTimeZone

public TimeZone getTimeZone()
Returns:
returns local time zone of calendar entry

getDurationInMinutes

public int getDurationInMinutes()
Returns:
returns duration in minutes of calendar entry

getOrganizer

public String getOrganizer()
Returns:
returns organizer of calendar entry

getLocation

public String getLocation()
Returns:
returns location of calendar entry

getSequence

public int getSequence()
Returns:
returns sequence of calendar entry

getStatus

public String getStatus()
Returns:
returns status of calendar entry

getType

public int getType()
Retrieves the type of this entry. This is an extension point that can be used by different implementations.

Returns:
returns type of calendar entry as set by the application

setType

public void setType(int type)
Specifies a type of this entry. This can be used to implement different behavior.

Parameters:
type - the implementation specific type

isAllday

public boolean isAllday()
Returns:
returns isAllday of calendar entry

getId

public String getId()
Returns:
returns id of calendar entry

getClassType

public String getClassType()
Retrieves the class of this entry. By default entries are deemed to be public.

Returns:
returns classType of this calendar entry
See Also:
CLASS_PUBLIC, CLASS_PRIVATE, CLASS_CONFIDENTIAL

setClassType

public void setClassType(String classType)
Sets the class of this entry

Parameters:
classType -
See Also:
CLASS_PUBLIC, CLASS_PRIVATE, CLASS_CONFIDENTIAL

getSummary

public String getSummary()
Returns:
returns summary of calendar entry

getSummary

public String getSummary(TimePoint calendarTimePoint)

setCategory

public void setCategory(CalendarCategory category)
setter method for CalendarCategory

Parameters:
category -

setCalendarAlarm

public void setCalendarAlarm(CalendarAlarm calendarAlarm)
setter method for calendarAlarm

Parameters:
calendarAlarm -

setStartDate

public void setStartDate(TimePoint startDate,
                         int durationInMinutes)
setter method to set starting date and duration in minutes for calendar entry

Parameters:
startDate -
durationInMinutes -

setDescription

public void setDescription(String description)
setter method for event description

Parameters:
description -

setStartDate

public void setStartDate(TimePoint startDate)
setter method for start date

Parameters:
startDate -

setEndDate

public void setEndDate(TimePoint endDate)
setter method for end date

Parameters:
endDate -

setTimeZone

public void setTimeZone(TimeZone timeZone)
setter method for local time zone

Parameters:
timeZone -

setDurationInMinutes

public void setDurationInMinutes(int durationInMinutes)
setter method for duration in minutes

Parameters:
durationInMinutes -

setOrganizer

public void setOrganizer(String organizer)
setter method for organizer

Parameters:
organizer -

setLocation

public void setLocation(String location)
setter method for location

Parameters:
location -

setReoccurence

public void setReoccurence(int reoccurence)
Specifies a simple reoccurence for this entry. Use setRepeat() for complex reoccurcence rules.

Parameters:
reoccurence - the reoccurrence for this event.
See Also:
REOCCURENCE_YEARLY, REOCCURENCE_MONTHLY, REOCCURENCE_WEEKLY, REOCCURENCE_DAILY, REOCCURENCE_NONE, setRepeat(EventRepeatRule)

setRepeat

public void setRepeat(EventRepeatRule eventRepeatRule)
Sets a repeat rule for this entry.

Parameters:
eventRepeatRule - the new repeat rule
See Also:
setReoccurence(int)

setStatus

public void setStatus(String status)
setter method for status

Parameters:
status -

setId

public void setId(String id)
setter method for id

Parameters:
id -

setAllday

public void setAllday(boolean isAllday)
setter method for isAllday of calendar entry

Parameters:
isAllday -

setSequence

public void setSequence(int sequence)
setter method for sequence of calendar entry

Parameters:
sequence -

setSummary

public void setSummary(String summary)
setter method for summary of calendar entry

Parameters:
summary -

getRepeat

public EventRepeatRule getRepeat()
Retrieves the event repeat rule for this entry

Returns:
returns the repeat rule of calendar entry

getAlarm

public int getAlarm()
Returns:
the alarm value

setAlarm

public void setAlarm(int alarm)
Parameters:
alarm - sets the alarm to the given value

getNotes

public String getNotes()
Returns:
notes gets the notes for this calendar entry

setNotes

public void setNotes(String notes)
Parameters:
notes - sets the notes for this calendar entry

getField

public Object getField(String name)
Retrieves another field that is stored within this CalendarEntry

Parameters:
name - the name of the field key
Returns:
the value of that specified field, can be null
See Also:
setField(String, Object)

setField

public void setField(String name,
                     Object value)
Adds an arbitrary field value to this entry

Parameters:
name - the name of the field
value - the value of the field
See Also:
getField(String)

getUserId

public String getUserId()

setUserId

public void setUserId(String userId)

write

public void write(DataOutputStream out)
           throws IOException
Description copied from interface: Externalizable
Stores the internal instance fields to the output stream.

Specified by:
write in interface Externalizable
Parameters:
out - the output stream to which instance fields should be written
Throws:
IOException - when writing fails

read

public void read(DataInputStream in)
          throws IOException
Description copied from interface: Externalizable
Restores the internal instance fields from the given input stream.

Specified by:
read in interface Externalizable
Parameters:
in - the input stream from which the data is loaded
Throws:
IOException - when reading fails

clone

public CalendarEntry clone(TimePoint start)
Clones this calendar entry for the specified date.

Parameters:
start - the new and only date for the cloned copy
Returns:
a copy of this event with the new date as its only event time

matches

public boolean matches(TimePeriod period)
Checks if this entry either starts or ends in the given time period

Parameters:
period - the period
Returns:
true when this event falls into the given time sequence

getParent

public CalendarEntry getParent()
Retrieves access to the original calendar entry.

Returns:
the parent entry, can be null if this is not a cloned copy

getChildren

public CalendarEntry[] getChildren()
Gets the children of a repeating entry.

Returns:
CalandarEntry[] The array with the children. Null if the entry has no children.

setChildren

public void setChildren(CalendarEntryList entryList)
Sets the children of a repeating entry.

Parameters:
entryList - A CalendarEntryList which contains the children.

getYearsSinceStart

public int getYearsSinceStart(TimePoint timePoint)
Retrieves the difference in years between the start date of this entry and the specified time point

Parameters:
timePoint - the time point
Returns:
the difference in years, -1 if no start date has been defined

setStartDate

public void setStartDate(Date date)

setEndDate

public void setEndDate(Date date)

setTextResolver

public void setTextResolver(CalendarTextResolver resolver)
Sets a text resolver that is used for resolving the summary and description of this CalendarEntry. Note that a resolver is not serialized when saving this entry.

Parameters:
resolver - the resolver, use null for removing the resolver.

getTextResolver

public CalendarTextResolver getTextResolver()
Retrieves the used text resolver.

Returns:
the text resolver or null if none has been registered

getGuid

public long getGuid()
Generates a global unique ID for this entry.

Returns:
the generated GUID