Class DefaultCalendarViewController

  • All Implemented Interfaces:
    CalendarViewController, ViewController

    public abstract class DefaultCalendarViewController
    extends java.lang.Object
    implements CalendarViewController

    A default implementation of the CalendarViewController that is independent of the presentation technology. This class is capable to render a yearly calendar with items and related links.

    It accepts a single path parameter year with selects a given year; otherwise the current year is used.

    Supported properties of the SiteNode:

    • P_ENTRIES: a property with XML format that describes the entries;
    • P_SELECTED_YEAR: the year to render (optional, otherwise the current year is used);
    • P_FIRST_YEAR: the first available year;
    • P_LAST_YEAR: the last available year ;
    • P_TITLE: the page title (optional);
    • P_COLUMNS: the number of columns of the table to render (optional, defaults to 4).

    The property P_ENTRIES must have the following structure:

     <?xml version="1.0" encoding="UTF-8"?>
     <calendar>
         <year id="2004">
             <month id="jan">
                 <item name="Provence" type="major" link="/diary/2004/01/02/"/>
                 <item name="Bocca di Magra" link="/diary/2004/01/24/"/>
                 <item name="Maremma" link="/diary/2004/01/31/"/>
             </month>
             ...
         </year>
         ...
     </calendar>
     

    Concrete implementations must provide one method for rendering the calendar:

    • #render(int, int, int, java.util.Map)
    Author:
    Fabrizio Giudici
    • Constructor Detail

      • DefaultCalendarViewController

        public DefaultCalendarViewController()
    • Method Detail

      • render

        protected abstract void render​(@Nonnull
                                       java.util.Optional<java.lang.String> title,
                                       @Nonnegative
                                       int year,
                                       @Nonnegative
                                       int firstYear,
                                       @Nonnegative
                                       int lastYear,
                                       @Nonnull
                                       java.util.SortedMap<java.lang.Integer,​java.util.List<DefaultCalendarViewController.Entry>> byMonth,
                                       int columns)
        Renders the diary.
        Parameters:
        title - a title for the page (optional)
        year - the current year
        firstYear - the first available year
        lastYear - the last available year
        byMonth - a map of entries for the current year indexed by month
        columns - the number of columns of the table to render
      • createYearLink

        @Nonnull
        protected final java.lang.String createYearLink​(int year)
        Creates a link for the current year.
        Parameters:
        year - the year
        Returns:
        the link