org.calendartag.decorator
Class DefaultCalendarDecorator

java.lang.Object
  extended byorg.calendartag.decorator.DefaultCalendarDecorator
All Implemented Interfaces:
CalendarDecorator

public class DefaultCalendarDecorator
extends java.lang.Object
implements CalendarDecorator

Since:
Aug 23, 2004
Author:
James Smith
See Also:
org.calendartag.decorators.CalendarDecorator The default implementation of CalendarDecorator used when a decorator is not defined.

Field Summary
protected  java.util.Calendar calendar
           
protected  java.lang.String[] days
           
protected  java.util.Calendar end
           
protected  java.lang.String[] months
           
protected  javax.servlet.jsp.PageContext pageContext
           
protected  java.util.Calendar start
           
 
Constructor Summary
DefaultCalendarDecorator()
           
 
Method Summary
 java.lang.String getCalendarTitle()
          Returns the calendar's title using the month names and years.
 java.lang.String getDay(java.lang.String url)
          Returns a string representing the day of the month.
 java.lang.String getDayStyleClass(boolean isOddMonth, boolean isSelectedDay)
          Returns an appropriate style class depending on whether the day is selected or unselected.
 java.lang.String getEmptyDay()
          Returns empty content
 java.lang.String getNextLink(java.lang.String url)
          Returns a ">>" hyperlink using the passed url
 java.lang.String getPreviousLink(java.lang.String url)
          Returns a "<<" hyperlink using the passed url
 java.lang.String getWeekdayTitle(int day)
          Returns the weekday title as assigned to the protected days array.
 void initializeCalendar()
          Empty implementation
 void setCalendar(java.util.Calendar calendar)
          Sets the calendar to the variable calendar
 void setEnd(java.util.Calendar end)
          Sets the end calendar to the variable end
 void setPageContext(javax.servlet.jsp.PageContext pageContext)
          Sets the page context to the variable pageContext
 void setStart(java.util.Calendar start)
          Sets the start calendar to the variable start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

months

protected java.lang.String[] months

days

protected java.lang.String[] days

pageContext

protected javax.servlet.jsp.PageContext pageContext

calendar

protected java.util.Calendar calendar

start

protected java.util.Calendar start

end

protected java.util.Calendar end
Constructor Detail

DefaultCalendarDecorator

public DefaultCalendarDecorator()
Method Detail

getDayStyleClass

public java.lang.String getDayStyleClass(boolean isOddMonth,
                                         boolean isSelectedDay)
Returns an appropriate style class depending on whether the day is selected or unselected. If the day is selected calendarActiveDayStyle is returned. If they day is not selected either calendarOddMonthStyle or calendarEvenMonthStyle is returned depending on CalendarTag's internal record. By default the month is considered odd.

Specified by:
getDayStyleClass in interface CalendarDecorator
Parameters:
isOddMonth - true if the month is odd
isSelectedDay - true if the day is selected
Returns:
the string representing the css class to display.
See Also:
CalendarDecorator.getDayStyleClass(boolean, boolean)

initializeCalendar

public void initializeCalendar()
Empty implementation

Specified by:
initializeCalendar in interface CalendarDecorator
See Also:
CalendarDecorator.initializeCalendar()

getPreviousLink

public java.lang.String getPreviousLink(java.lang.String url)
Returns a "<<" hyperlink using the passed url

Specified by:
getPreviousLink in interface CalendarDecorator
Parameters:
url - the url that the previous link should point to
Returns:
the previous link
See Also:
CalendarDecorator.getPreviousLink(java.lang.String)

getNextLink

public java.lang.String getNextLink(java.lang.String url)
Returns a ">>" hyperlink using the passed url

Specified by:
getNextLink in interface CalendarDecorator
Parameters:
url - the url that the next link should point to
Returns:
the next link
See Also:
CalendarDecorator.getNextLink(java.lang.String)

getCalendarTitle

public java.lang.String getCalendarTitle()
Returns the calendar's title using the month names and years. It uses the protected months array to generate text for each month indexed from 0 to 11

Specified by:
getCalendarTitle in interface CalendarDecorator
Returns:
the calendar's title as HTML
See Also:
CalendarDecorator.getCalendarTitle()

getWeekdayTitle

public java.lang.String getWeekdayTitle(int day)
Returns the weekday title as assigned to the protected days array. By default the array consists of S, M, T, W, T, F, S and is protected so it can be easily overridden by your implementation. The array is index from 1 to 7

Specified by:
getWeekdayTitle in interface CalendarDecorator
Parameters:
day - the day as an integer, 1-7 monday-friday
Returns:
the day of the week's abreviation as HTML
See Also:
CalendarDecorator.getWeekdayTitle(int)

getEmptyDay

public java.lang.String getEmptyDay()
Returns empty content

Specified by:
getEmptyDay in interface CalendarDecorator
Returns:
the contents of an empty day as HTML
See Also:
CalendarDecorator.getEmptyDay()

getDay

public java.lang.String getDay(java.lang.String url)
Returns a string representing the day of the month. If the calendar's start and end range span multiple months it also returns the month of the year. The date is a hyperlink using the url passed

Specified by:
getDay in interface CalendarDecorator
Parameters:
url - the url that can be used to set the current day to focus
Returns:
the contents of an unempty day as HTML
See Also:
CalendarDecorator.getDay(java.lang.String)

setPageContext

public void setPageContext(javax.servlet.jsp.PageContext pageContext)
Sets the page context to the variable pageContext

Specified by:
setPageContext in interface CalendarDecorator
Parameters:
pageContext - the pageContext of the HttpServletRequest
See Also:
CalendarDecorator.setPageContext(javax.servlet.jsp.PageContext)

setCalendar

public void setCalendar(java.util.Calendar calendar)
Sets the calendar to the variable calendar

Specified by:
setCalendar in interface CalendarDecorator
Parameters:
calendar - a Calendar object
See Also:
CalendarDecorator.setCalendar(java.util.Calendar)

setStart

public void setStart(java.util.Calendar start)
Sets the start calendar to the variable start

Specified by:
setStart in interface CalendarDecorator
Parameters:
start - the start date
See Also:
CalendarDecorator.setStart(java.util.Calendar)

setEnd

public void setEnd(java.util.Calendar end)
Sets the end calendar to the variable end

Specified by:
setEnd in interface CalendarDecorator
Parameters:
end - the end date
See Also:
CalendarDecorator.setEnd(java.util.Calendar)


Copyright © 2004-2005 Sourceforge. All Rights Reserved.