com.webmethods.caf.faces.data.object
Class DefaultCalendarProvider

java.lang.Object
  extended by com.webmethods.caf.faces.bean.PageFlowScopeAdapter
      extended by com.webmethods.caf.faces.data.object.DefaultCalendarProvider
All Implemented Interfaces:
IPageFlowScopeAdapter, ICalendarProvider, IContentProvider, ITableContentProvider

public class DefaultCalendarProvider
extends PageFlowScopeAdapter
implements ICalendarProvider

DefaultCalendarProvider represents the default implementation for ICalendarProvider. Provides a slice of calendar days to a table where each row represents a calendar day. The index indicates the date offset from the provider start date


Field Summary
protected  Calendar m_calendar
           
protected  CalendarUnit m_calendarUnit
           
protected  int m_dayIndex
           
protected  String m_dayVar
           
protected  Date m_endDate
           
protected  boolean m_init
           
protected  Date m_initialDate
           
protected  Locale m_locale
           
protected  int m_numUnits
           
protected  Date m_startDate
           
protected  TimeZone m_timeZone
           
protected  int m_unitIndex
           
protected  String m_units
           
protected static long MS_IN_DAY
           
static String UNIT_DAY
           
static String UNIT_MONTH
           
static String UNIT_WEEK
           
static String UNIT_YEAR
           
 
Fields inherited from class com.webmethods.caf.faces.bean.PageFlowScopeAdapter
fExpireWithPageFlow
 
Constructor Summary
DefaultCalendarProvider()
          Default construtor using the default locale, time zone, and calendar.
DefaultCalendarProvider(Date startDate, Date endDate, Locale locale, TimeZone timeZone)
          Construct new instance using locale, time zone provided.
DefaultCalendarProvider(Date startDate, Locale locale, TimeZone timeZone)
          Construct new instance using locale, time zone provided.
DefaultCalendarProvider(Locale locale, TimeZone timeZone)
          Construct new instance using locale, time zone provided.
 
Method Summary
protected  Date calcDefaultStartDate()
           
protected  int calcIndexFromDate(Date date)
           
protected  Date calcUnitStartDate(Date date)
           
 ICalendarDay getCurrentDay()
          Get the day at the current day index within the current calendar unit.
 Object getCurrentRow()
          Returns current row.
 CalendarUnit getCurrentUnit()
          Get the current aligned calendar unit index, expressed as the number of calendar units from the provider start date
 int getDayCount()
          Get the number of days within the current calendar unit.
 Date getEndDate()
          Get the end date of the date range for this provider.
 Date getInitialDate()
          Get the initial date to display.
 int getNumUnits()
          Get the number of calendar units in this provider.
 Object[] getPropertyKeys()
          Returns list of properties supported by this content provider.
 int getRowCount()
          Return the number of rows of data objects represented by this DataModel.
 int getRowIndex()
          Return the zero-relative index of the currently selected row.
 String getRowVariable()
           Returns row variable name.
 Date getStartDate()
          Get the start date of the date range for this provider.
 Class getType(Object propertyKey)
          Returns java type of the given property
 int getUnitCount()
          Get the number of calendar units in this provider.
 Date getUnitEndDate()
          get the last day date in the current unit row (e.g.
 String getUnits()
          Get the calendar unit of measure for this provider.
 Date getUnitStartDate()
          get the first day date in the current unit row (e.g.
 String getUnitVariable()
          Get the name of the request variable that current CalendarUnit will be exposed as.
 Object getValue(Object propertyKey)
          Returns value of the given property
 boolean hasProperty(Object propertyKey)
          Checks if the given property is supported by this content provider
 void initialize(String units, Date startDate, Date endDate, Date initialDate, int numDisplayUnits)
          Common method to set the content of the calendar provider.
 boolean isDayAvailable()
          Is the day selected by setDayIndex within the start and end dates of the current calendar unit.
 boolean isInitialized()
          Determine if method initialize has been called.
 boolean isRowAvailable()
          Return a flag indicating whether there is rowData available at the current rowIndex.
 boolean isUnitAvailable()
           
 void setDayIndex(int dayIndex)
          Set the index of the day within the current calendar unit.
 void setEndDate(Date date)
          Set the end date for the date range for this provider
 void setInitialDate(Date initialDate)
          Set the initial date to display.
 void setNumUnits(int units)
          Set the the number of calendar units
 void setRowIndex(int rowIndex)
          Set row index.
 void setRowVariable(String var)
           Sets row variable name to use for accessing row specific data.
 void setStartDate(Date date)
          Set the start date of the date range for this provider.
 void setUnitIndex(int unitIndex)
          Set the current aligned calendar unit index, expressed as the number of calendar units from the provider start date
 void setUnits(String units)
          Set the calendar unit of measure for this provider.
 void setUnitVariable(String var)
          Set the name of the request variable that current Calendar Unit will be exposed as.
 String toString()
          Returns string representation of content.
 
Methods inherited from class com.webmethods.caf.faces.bean.PageFlowScopeAdapter
getExpireWithPageFlow, setExpireWithPageFlow
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_init

protected boolean m_init

m_unitIndex

protected int m_unitIndex

m_dayIndex

protected int m_dayIndex

m_units

protected String m_units

m_startDate

protected Date m_startDate

m_endDate

protected Date m_endDate

m_initialDate

protected Date m_initialDate

m_numUnits

protected int m_numUnits

m_calendarUnit

protected CalendarUnit m_calendarUnit

m_calendar

protected Calendar m_calendar

m_locale

protected Locale m_locale

m_timeZone

protected TimeZone m_timeZone

m_dayVar

protected String m_dayVar

UNIT_DAY

public static final String UNIT_DAY
See Also:
Constant Field Values

UNIT_WEEK

public static final String UNIT_WEEK
See Also:
Constant Field Values

UNIT_MONTH

public static final String UNIT_MONTH
See Also:
Constant Field Values

UNIT_YEAR

public static final String UNIT_YEAR
See Also:
Constant Field Values

MS_IN_DAY

protected static final long MS_IN_DAY
See Also:
Constant Field Values
Constructor Detail

DefaultCalendarProvider

public DefaultCalendarProvider()
Default construtor using the default locale, time zone, and calendar.


DefaultCalendarProvider

public DefaultCalendarProvider(Locale locale,
                               TimeZone timeZone)
Construct new instance using locale, time zone provided.

Parameters:
locale -
timeZone -

DefaultCalendarProvider

public DefaultCalendarProvider(Date startDate,
                               Locale locale,
                               TimeZone timeZone)
Construct new instance using locale, time zone provided. Also set start date.

Parameters:
startDate -
locale -
timeZone -

DefaultCalendarProvider

public DefaultCalendarProvider(Date startDate,
                               Date endDate,
                               Locale locale,
                               TimeZone timeZone)
Construct new instance using locale, time zone provided. Also set start date and end date.

Parameters:
startDate -
endDate -
locale -
timeZone -
Method Detail

isInitialized

public boolean isInitialized()
Description copied from interface: ICalendarProvider
Determine if method initialize has been called.

Specified by:
isInitialized in interface ICalendarProvider
Returns:
boolean true if method initialize has been called, otherwise false.

initialize

public void initialize(String units,
                       Date startDate,
                       Date endDate,
                       Date initialDate,
                       int numDisplayUnits)
Description copied from interface: ICalendarProvider
Common method to set the content of the calendar provider.

Specified by:
initialize in interface ICalendarProvider
Parameters:
units - The unit of measurement. (Example: day, week, month, year )
startDate - The start date for the date range of events in this calendar provider.
endDate - The end date for the date range of events in this calendar provider.
initialDate - An initial start date within the date range of events in this calendar provider.
numDisplayUnits - The number of calendar units displays by the provider.

getStartDate

public Date getStartDate()
Description copied from interface: ICalendarProvider
Get the start date of the date range for this provider. Must return a valid Date.

Specified by:
getStartDate in interface ICalendarProvider
Returns:
The end date for the date range of this provider.

setStartDate

public void setStartDate(Date date)
Description copied from interface: ICalendarProvider
Set the start date of the date range for this provider.

Specified by:
setStartDate in interface ICalendarProvider

getEndDate

public Date getEndDate()
Description copied from interface: ICalendarProvider
Get the end date of the date range for this provider. Must return a valid Date.

Specified by:
getEndDate in interface ICalendarProvider
Returns:
The end date for the date range of this provider.

setEndDate

public void setEndDate(Date date)
Description copied from interface: ICalendarProvider
Set the end date for the date range for this provider

Specified by:
setEndDate in interface ICalendarProvider

getInitialDate

public Date getInitialDate()
Description copied from interface: ICalendarProvider
Get the initial date to display. Use the start date if not set.

Specified by:
getInitialDate in interface ICalendarProvider
Returns:
The initial date this provider will display.

setInitialDate

public void setInitialDate(Date initialDate)
Description copied from interface: ICalendarProvider
Set the initial date to display.

Specified by:
setInitialDate in interface ICalendarProvider
Parameters:
initialDate - The initial date this provider will display.

getUnits

public String getUnits()
Description copied from interface: ICalendarProvider
Get the calendar unit of measure for this provider. ( Example: day, week, month, year )

Specified by:
getUnits in interface ICalendarProvider
Returns:
The unit of measure.
See Also:
DefaultCalendarProvider

setUnits

public void setUnits(String units)
Description copied from interface: ICalendarProvider
Set the calendar unit of measure for this provider. ( Example: day, week, month, year )

Specified by:
setUnits in interface ICalendarProvider
Parameters:
units - The unit of measure.
See Also:
DefaultCalendarProvider

getNumUnits

public int getNumUnits()
Description copied from interface: ICalendarProvider
Get the number of calendar units in this provider. For displaying multiple CalendarUnit's in day mode, the end date for each CalendarUnit will have to be set or calculated to display properly.

Specified by:
getNumUnits in interface ICalendarProvider
Returns:
The number of calendar units
See Also:
CalendarUnit

setNumUnits

public void setNumUnits(int units)
Description copied from interface: ICalendarProvider
Set the the number of calendar units

Specified by:
setNumUnits in interface ICalendarProvider

toString

public String toString()
Description copied from interface: IContentProvider
Returns string representation of content.

Specified by:
toString in interface IContentProvider
Overrides:
toString in class Object
Returns:
String representation of the wrapped content

getDayCount

public int getDayCount()
Description copied from interface: ICalendarProvider
Get the number of days within the current calendar unit.

Specified by:
getDayCount in interface ICalendarProvider
Returns:
The number of days, staring at one.

getUnitStartDate

public Date getUnitStartDate()
get the first day date in the current unit row (e.g. first of month)

Specified by:
getUnitStartDate in interface ICalendarProvider
Returns:
The start date for the calendar unit.

getUnitEndDate

public Date getUnitEndDate()
get the last day date in the current unit row (e.g. last of month)

Specified by:
getUnitEndDate in interface ICalendarProvider
Returns:
The end date for the calendar unit.

getPropertyKeys

public Object[] getPropertyKeys()
Description copied from interface: IContentProvider
Returns list of properties supported by this content provider. Can return Object[0], never null.

Specified by:
getPropertyKeys in interface IContentProvider
Returns:
array of property keys which is typically of type String or Integer

getType

public Class getType(Object propertyKey)
              throws PropertyNotFoundException
Description copied from interface: IContentProvider
Returns java type of the given property

Specified by:
getType in interface IContentProvider
Parameters:
propertyKey - the property key of type String or Integer
Returns:
property java Class
Throws:
PropertyNotFoundException - if property is not supported

getValue

public Object getValue(Object propertyKey)
                throws EvaluationException,
                       PropertyNotFoundException
Description copied from interface: IContentProvider
Returns value of the given property

Specified by:
getValue in interface IContentProvider
Parameters:
propertyKey - the property key of type String or Integer
Returns:
value of the property, can be null
Throws:
EvaluationException - if error during property evaluation
PropertyNotFoundException - if property is not supported

hasProperty

public boolean hasProperty(Object propertyKey)
Description copied from interface: IContentProvider
Checks if the given property is supported by this content provider

Specified by:
hasProperty in interface IContentProvider
Parameters:
propertyKey - property key of type String or Integer
Returns:
true if property is supported

getRowCount

public int getRowCount()
Description copied from interface: ITableContentProvider
Return the number of rows of data objects represented by this DataModel.

Return -1, if the number of rows is unknown, or no wrappedData is available.

Specified by:
getRowCount in interface ITableContentProvider
Returns:
how many rows between start date and end date based on display units return -1 if end date is null.
See Also:
DataModel

getRowIndex

public int getRowIndex()
Description copied from interface: ITableContentProvider
Return the zero-relative index of the currently selected row.

If we are not currently positioned on a row, or no wrappedData is available, return -1.

Specified by:
getRowIndex in interface ITableContentProvider
Returns:
row index
See Also:
DataModel

isRowAvailable

public boolean isRowAvailable()
Description copied from interface: ITableContentProvider
Return a flag indicating whether there is rowData available at the current rowIndex. If no wrappedData is available, return false.

Specified by:
isRowAvailable in interface ITableContentProvider
Returns:
the flag indicates whether the row is available. It's available if the date row is between the start and end dates.
See Also:
DataModel

isUnitAvailable

public boolean isUnitAvailable()
See Also:
DefaultCalendarProvider.isRowAvailable()

setUnitIndex

public void setUnitIndex(int unitIndex)
Description copied from interface: ICalendarProvider
Set the current aligned calendar unit index, expressed as the number of calendar units from the provider start date

Specified by:
setUnitIndex in interface ICalendarProvider
Parameters:
unitIndex - The index for the current calendar unit.
See Also:
DefaultCalendarProvider.setRowIndex(int)

setRowIndex

public void setRowIndex(int rowIndex)
Set row index. Also reset the calendar unit member.

Specified by:
setRowIndex in interface ITableContentProvider
See Also:
DataModel

getRowVariable

public String getRowVariable()
Description copied from interface: ITableContentProvider

Returns row variable name.

If specified row variable can be used to access current row data for the provider internal needs, like sorting or addressing.

Specified by:
getRowVariable in interface ITableContentProvider
Returns:
row variable name or null if not specified
See Also:
ITableContentProvider.setRowVariable(String)

getUnitVariable

public String getUnitVariable()
Description copied from interface: ICalendarProvider
Get the name of the request variable that current CalendarUnit will be exposed as. Used in binding expressions.

Specified by:
getUnitVariable in interface ICalendarProvider
Returns:
The name of the provider variable.

getUnitCount

public int getUnitCount()
Description copied from interface: ICalendarProvider
Get the number of calendar units in this provider.

Specified by:
getUnitCount in interface ICalendarProvider
Returns:
The number of calendar units.

setRowVariable

public void setRowVariable(String var)
Description copied from interface: ITableContentProvider

Sets row variable name to use for accessing row specific data. For example, if the provider wrapps an array of a data objects with id property and the variable name is item, then the provider implementation can access id property of each record as item.id.

This property should set only once at the provider initialization time

Specified by:
setRowVariable in interface ITableContentProvider

setUnitVariable

public void setUnitVariable(String var)
Description copied from interface: ICalendarProvider
Set the name of the request variable that current Calendar Unit will be exposed as. Used in binding expressions.

Specified by:
setUnitVariable in interface ICalendarProvider
Parameters:
var - The name of the provider variable.

getCurrentDay

public ICalendarDay getCurrentDay()
Description copied from interface: ICalendarProvider
Get the day at the current day index within the current calendar unit.

Specified by:
getCurrentDay in interface ICalendarProvider
Returns:
The current calendar day.

isDayAvailable

public boolean isDayAvailable()
Description copied from interface: ICalendarProvider
Is the day selected by setDayIndex within the start and end dates of the current calendar unit.

Specified by:
isDayAvailable in interface ICalendarProvider
Returns:
True if between the start and end dates of the current calendar unit.

setDayIndex

public void setDayIndex(int dayIndex)
Description copied from interface: ICalendarProvider
Set the index of the day within the current calendar unit.

Specified by:
setDayIndex in interface ICalendarProvider
Parameters:
dayIndex - The number of days, staring at one.

getCurrentRow

public Object getCurrentRow()
Returns current row. If no row is current, returns first row. If doesn't have first row, returns null.

Specified by:
getCurrentRow in interface ITableContentProvider
Returns:
current row object
See Also:
ITableContentProvider.isRowAvailable()

getCurrentUnit

public CalendarUnit getCurrentUnit()
Description copied from interface: ICalendarProvider
Get the current aligned calendar unit index, expressed as the number of calendar units from the provider start date

Specified by:
getCurrentUnit in interface ICalendarProvider
Returns:
The current calendar unit.
See Also:
CalendarUnit

calcIndexFromDate

protected int calcIndexFromDate(Date date)

calcUnitStartDate

protected Date calcUnitStartDate(Date date)

calcDefaultStartDate

protected Date calcDefaultStartDate()