org.apache.myfaces.custom.schedule.model
Class AbstractScheduleModel

java.lang.Object
  extended by org.apache.myfaces.custom.schedule.model.AbstractScheduleModel
All Implemented Interfaces:
Serializable, ScheduleModel
Direct Known Subclasses:
SimpleScheduleModel

public abstract class AbstractScheduleModel
extends Object
implements ScheduleModel, Serializable

Extend this class to create your own implementation of a ScheduleModel

Version:
$Revision: 372589 $
Author:
Jurgen Lust (latest modification by $Author: baranda $)
See Also:
Serialized Form

Field Summary
protected  TimeZone timeZone
           
 
Fields inherited from interface org.apache.myfaces.custom.schedule.model.ScheduleModel
DAY, MONTH, WEEK, WORKWEEK
 
Constructor Summary
AbstractScheduleModel()
          Creates a new AbstractScheduleModel object.
AbstractScheduleModel(TimeZone timeZone)
           
 
Method Summary
protected  ScheduleDay add(Date date)
           Add a day to the schedule
protected  void clear()
           Remove all days
 boolean containsDate(Date date)
           Check if the schedule contains the specified date
 boolean containsRepeatedIntervals()
           
 Object get(int index)
           Get the day at position index.
protected  Calendar getCalendarInstance(Date date)
           
protected  SortedSet getDays()
          Get the set of days.
 int getMode()
           
 Date getSelectedDate()
           
 ScheduleEntry getSelectedEntry()
           
 TimeZone getTimeZone()
          Returns the timezone setting for this model
 boolean isEmpty()
           
 boolean isEntrySelected()
           
 Iterator iterator()
           
protected abstract  void loadDayAttributes(Day day)
           Load any attributes for this day: is it a working day or a holiday, and what is the name of the day (e.g.
protected abstract  Collection loadEntries(Date startDate, Date endDate)
           Load the schedule entries that fall between the startDate and the endDate.
 void refresh()
          Reload the entries for the currently selected period
protected  void setDay(Date date)
           Set the day
 void setMode(int mode)
           
protected  void setMonth(Date date)
           navigate to the specified month
 void setSelectedDate(Date date)
           
 void setSelectedEntry(ScheduleEntry selectedEntry)
           
protected  void setWeek(Date date)
           navigate to the specified week
protected  void setWorkWeek(Date date)
           navigate to the specified workweek
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.myfaces.custom.schedule.model.ScheduleModel
addEntry, removeEntry, removeSelectedEntry
 

Field Detail

timeZone

protected final TimeZone timeZone
Constructor Detail

AbstractScheduleModel

public AbstractScheduleModel()
Creates a new AbstractScheduleModel object.


AbstractScheduleModel

public AbstractScheduleModel(TimeZone timeZone)
Method Detail

getDays

protected SortedSet getDays()
Get the set of days. Initialise on first call.


getTimeZone

public TimeZone getTimeZone()
Returns the timezone setting for this model

Specified by:
getTimeZone in interface ScheduleModel
Returns:
The timezone for which the model should be built

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface ScheduleModel
Returns:
true if there are no entries
See Also:
ScheduleModel.isEmpty()

setMode

public void setMode(int mode)
Specified by:
setMode in interface ScheduleModel
Parameters:
mode - the mode: DAY, WORKWEEK, WEEK or MONTH
See Also:
ScheduleModel.setMode(int)

getMode

public int getMode()
Specified by:
getMode in interface ScheduleModel
Returns:
the mode: DAY, WORKWEEK, WEEK or MONTH
See Also:
ScheduleModel.getMode()

setSelectedDate

public void setSelectedDate(Date date)
Specified by:
setSelectedDate in interface ScheduleModel
Parameters:
date - the date to select
See Also:
ScheduleModel.setSelectedDate(java.util.Date)

getSelectedDate

public Date getSelectedDate()
Specified by:
getSelectedDate in interface ScheduleModel
Returns:
the selected date
See Also:
ScheduleModel.getSelectedDate()

setSelectedEntry

public void setSelectedEntry(ScheduleEntry selectedEntry)
Specified by:
setSelectedEntry in interface ScheduleModel
Parameters:
selectedEntry - the entry to select
See Also:
ScheduleModel.setSelectedEntry(org.apache.myfaces.custom.schedule.model.ScheduleEntry)

getSelectedEntry

public ScheduleEntry getSelectedEntry()
Specified by:
getSelectedEntry in interface ScheduleModel
Returns:
the selected entry
See Also:
ScheduleModel.getSelectedEntry()

isEntrySelected

public boolean isEntrySelected()
Specified by:
isEntrySelected in interface ScheduleModel
Returns:
whether an entry is currently selected
See Also:
ScheduleModel.isEntrySelected()

containsDate

public boolean containsDate(Date date)
Description copied from interface: ScheduleModel

Check if the schedule contains the specified date

Specified by:
containsDate in interface ScheduleModel
Parameters:
date - the date to check
Returns:
whether the schedule containts this date
See Also:
ScheduleModel.containsDate(java.util.Date)

get

public Object get(int index)
Description copied from interface: ScheduleModel

Get the day at position index.

Specified by:
get in interface ScheduleModel
Parameters:
index - the index
Returns:
the day
See Also:
ScheduleModel.get(int)

iterator

public Iterator iterator()
Specified by:
iterator in interface ScheduleModel
Returns:
an iterator for the days
See Also:
ScheduleModel.iterator()

size

public int size()
Specified by:
size in interface ScheduleModel
Returns:
the number of days in this model
See Also:
ScheduleModel.size()

setDay

protected void setDay(Date date)

Set the day

Parameters:
date - the new day

setMonth

protected void setMonth(Date date)

navigate to the specified month

Parameters:
date - the date to navigate to

setWeek

protected void setWeek(Date date)

navigate to the specified week

Parameters:
date - the date to navigate to

setWorkWeek

protected void setWorkWeek(Date date)

navigate to the specified workweek

Parameters:
date - the date to navigate to

add

protected ScheduleDay add(Date date)

Add a day to the schedule

Parameters:
date - the day to add
Returns:
the day that was added

clear

protected void clear()

Remove all days


refresh

public void refresh()
Description copied from interface: ScheduleModel
Reload the entries for the currently selected period

Specified by:
refresh in interface ScheduleModel
See Also:
ScheduleModel.refresh()

loadEntries

protected abstract Collection loadEntries(Date startDate,
                                          Date endDate)

Load the schedule entries that fall between the startDate and the endDate.

Parameters:
startDate - 0 AM on the start date
endDate - 12 PM on the end date

loadDayAttributes

protected abstract void loadDayAttributes(Day day)

Load any attributes for this day: is it a working day or a holiday, and what is the name of the day (e.g. "Christmas").

Parameters:
day - the day that should be loaded

containsRepeatedIntervals

public boolean containsRepeatedIntervals()
Specified by:
containsRepeatedIntervals in interface ScheduleModel
Returns:
true, if each day contains the same set of intervals

getCalendarInstance

protected Calendar getCalendarInstance(Date date)


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.