Class DefaultCalendarProvider

java.lang.Object
com.webmethods.caf.faces.bean.PageFlowScopeAdapter
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 Details

    • 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 com.ibm.icu.util.Calendar m_calendar
    • m_locale

      protected Locale m_locale
    • m_timeZone

      protected com.ibm.icu.util.TimeZone m_timeZone
    • m_dayVar

      protected String m_dayVar
    • UNIT_DAY

      public static final String UNIT_DAY
      See Also:
    • UNIT_WEEK

      public static final String UNIT_WEEK
      See Also:
    • UNIT_MONTH

      public static final String UNIT_MONTH
      See Also:
    • UNIT_YEAR

      public static final String UNIT_YEAR
      See Also:
    • MS_IN_DAY

      protected static final long MS_IN_DAY
      See Also:
  • Constructor Details

    • DefaultCalendarProvider

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

      public DefaultCalendarProvider(Locale locale, com.ibm.icu.util.TimeZone timeZone)
      Construct new instance using locale, time zone provided.
      Parameters:
      locale -
      timeZone -
    • DefaultCalendarProvider

      public DefaultCalendarProvider(Date startDate, Locale locale, com.ibm.icu.util.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, com.ibm.icu.util.TimeZone timeZone)
      Construct new instance using locale, time zone provided. Also set start date and end date.
      Parameters:
      startDate -
      endDate -
      locale -
      timeZone -
  • Method Details

    • 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:
    • 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 ELException, 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:
      PropertyNotFoundException - if property is not supported
      ELException
    • 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:
    • 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:
    • 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:
    • isUnitAvailable

      public boolean isUnitAvailable()
      See Also:
    • 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:
    • setRowIndex

      public void setRowIndex(int rowIndex)
      Set row index. Also reset the calendar unit member.
      Specified by:
      setRowIndex in interface ITableContentProvider
      See Also:
    • 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:
    • 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:
    • 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:
    • calcIndexFromDate

      protected int calcIndexFromDate(Date date)
    • calcUnitStartDate

      protected Date calcUnitStartDate(Date date)
    • calcDefaultStartDate

      protected Date calcDefaultStartDate()