JIDE 3.5.15

com.jidesoft.combobox
Class DefaultDateModel

java.lang.Object
  extended by com.jidesoft.combobox.DefaultDateModel
All Implemented Interfaces:
DateModel

public class DefaultDateModel
extends Object
implements DateModel

Default implementation of DateModel.


Field Summary
static DateFilter LATER_THIS_MONTH
          DateFilter for this week only.
static DateFilter NEXT_YEAR_ONLY
          DateFilter for next year only.
static DateFilter PREVIOUS_YEAR_ONLY
          DateFilter for next year only.
static DateFilter THIS_MONTH_ONLY
          DateFilter for this week only.
static DateFilter THIS_WEEK
          DateFilter for this week only.
static DateFilter THIS_YEAR_ONLY
          DateFilter for this year only.
static DateFilter WEEKDAY_ONLY
          DateFilter for week day only.
static DateFilter WEEKEND_ONLY
          DateFilter for weekend only.
 
Constructor Summary
DefaultDateModel()
          Constructs a DefaultDateModel.
DefaultDateModel(Calendar minDate, Calendar maxDate)
          Constructs a DefaultDateModel with specified minDate and maxDate.
 
Method Summary
 void addDateFilter(DateFilter filter)
          Adds a DateFilter.
 void addDateModelListener(DateModelListener l)
          Adds a listener to the list that's notified each time a change to the date model occurs.
 void addInvalidDate(Calendar date)
          Adds an invalid date.
 void clearDateFilters()
          Clear the DateFilter list.
 void clearInvalidDates()
          Clear whatever invalid dates added before.
 Calendar createCalendarInstance()
          Creates a new Calendar instance that will be used internally.
 boolean dayInRange(Calendar calendar)
          Checks if the day is in allowed range, which means if the date is no later than the maximum date and no earlier than the minimum date not comparing the time within a day.
 void fireDateModelChanged(DateModelEvent e)
          Fires the DateModelEvent.
 DateFormat getDateFormat()
          Gets the date format.
 DateModelListener[] getDateModelListeners()
          Returns an array of all the date model listeners registered on this model.
 Calendar getMaxDate()
          Gets the maximum date allowed.
 Calendar getMinDate()
          Gets the minimum date allowed.
 String getTimeFormat()
          Gets the time format used by time spinner when time is displayed.
 TimeZone getTimeZone()
          Gets the time zone.
 boolean isCompareTime()
          Get the flag indicating if the time should be compared as well while isValidDate(java.util.Calendar) is invoked.
 boolean isValidDate(Calendar calendar)
          Check if the date is a valid date.
 boolean monthInRange(Calendar calendar)
          Checks if the month is in allowed range, which means if the date is no later than the maximum date and no earlier than the minimum date.
 void removeDateFilter(DateFilter filter)
          Remove the DateFilter.
 void removeDateModelListener(DateModelListener l)
          Removes a listener from the list that's notified each time a change to the date model occurs.
 void removeInvalidDate(Calendar date)
          Removes an invalid date.
 void setCompareTime(boolean compareTime)
          Set the flag indicating if the time should be compared as well while isValidDate(java.util.Calendar) is invoked.
 void setDateFormat(DateFormat dateFormat)
          Sets the date format.
 void setMaxDate(Calendar maxDate)
          Sets the maximum date.
 void setMinDate(Calendar minDate)
          Sets the minimum date.
 void setTimeFormat(String timeFormat)
          Sets the time format used by time spinner when time is displayed.
 void setTimeZone(TimeZone timeZone)
          Sets the time zone.
 boolean timeInRange(Calendar calendar)
          Checks if the day is in allowed range, which means if the date is no later than the maximum date and no earlier than the minimum date including comparing the time within a day.
 boolean yearInRange(Calendar calendar)
          Checks if the year is in allowed range, which means if the date is no later than the maximum date and no earlier than the minimum date.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WEEKDAY_ONLY

public static final DateFilter WEEKDAY_ONLY
DateFilter for week day only. It will return false when it's weekend and true otherwise.


THIS_WEEK

public static final DateFilter THIS_WEEK
DateFilter for this week only. It will return true if the date passed in is the same week as today, and false otherwise.


THIS_MONTH_ONLY

public static final DateFilter THIS_MONTH_ONLY
DateFilter for this week only. It will return true if the date passed in is the same month as today, and false otherwise.


LATER_THIS_MONTH

public static final DateFilter LATER_THIS_MONTH
DateFilter for this week only. It will return true if the date passed in is the same month but after today, and false otherwise.


WEEKEND_ONLY

public static final DateFilter WEEKEND_ONLY
DateFilter for weekend only. It will return true when it's weekend and false otherwise.


THIS_YEAR_ONLY

public static final DateFilter THIS_YEAR_ONLY
DateFilter for this year only. It will return true if the date passed in is the same year as today, and false otherwise.


NEXT_YEAR_ONLY

public static final DateFilter NEXT_YEAR_ONLY
DateFilter for next year only. It will return true if the date passed in is the next year of today, and false otherwise.


PREVIOUS_YEAR_ONLY

public static final DateFilter PREVIOUS_YEAR_ONLY
DateFilter for next year only. It will return true if the date passed in is the next year of today, and false otherwise.

Constructor Detail

DefaultDateModel

public DefaultDateModel()
Constructs a DefaultDateModel.


DefaultDateModel

public DefaultDateModel(Calendar minDate,
                        Calendar maxDate)
Constructs a DefaultDateModel with specified minDate and maxDate.

Parameters:
minDate - the minimum date
maxDate - the maximum date
Method Detail

getMinDate

public Calendar getMinDate()
Description copied from interface: DateModel
Gets the minimum date allowed.

Specified by:
getMinDate in interface DateModel
Returns:
the minimum date.

setMinDate

public void setMinDate(Calendar minDate)
Description copied from interface: DateModel
Sets the minimum date.

Specified by:
setMinDate in interface DateModel
Parameters:
minDate - the minimum date.

getMaxDate

public Calendar getMaxDate()
Description copied from interface: DateModel
Gets the maximum date allowed.

Specified by:
getMaxDate in interface DateModel
Returns:
the maximum date.

setMaxDate

public void setMaxDate(Calendar maxDate)
Description copied from interface: DateModel
Sets the maximum date.

Specified by:
setMaxDate in interface DateModel
Parameters:
maxDate - the maximum date.

timeInRange

public boolean timeInRange(Calendar calendar)
Description copied from interface: DateModel
Checks if the day is in allowed range, which means if the date is no later than the maximum date and no earlier than the minimum date including comparing the time within a day.

Specified by:
timeInRange in interface DateModel
Parameters:
calendar - date to be checked.
Returns:
true if the calendar is in the allowed range.

dayInRange

public boolean dayInRange(Calendar calendar)
Description copied from interface: DateModel
Checks if the day is in allowed range, which means if the date is no later than the maximum date and no earlier than the minimum date not comparing the time within a day.

Specified by:
dayInRange in interface DateModel
Parameters:
calendar - date to be checked.
Returns:
true if the calendar is in the allowed range.

monthInRange

public boolean monthInRange(Calendar calendar)
Description copied from interface: DateModel
Checks if the month is in allowed range, which means if the date is no later than the maximum date and no earlier than the minimum date.

Specified by:
monthInRange in interface DateModel
Parameters:
calendar - month to be checked.
Returns:
true if the month value in calendar is in the range.

yearInRange

public boolean yearInRange(Calendar calendar)
Description copied from interface: DateModel
Checks if the year is in allowed range, which means if the date is no later than the maximum date and no earlier than the minimum date.

Specified by:
yearInRange in interface DateModel
Parameters:
calendar - year to be checked.
Returns:
true if the year value in calendar is in the range.

clearDateFilters

public void clearDateFilters()
Clear the DateFilter list.


addDateFilter

public void addDateFilter(DateFilter filter)
Adds a DateFilter.

Parameters:
filter - the filter

removeDateFilter

public void removeDateFilter(DateFilter filter)
Remove the DateFilter.

Parameters:
filter - the filter

isValidDate

public boolean isValidDate(Calendar calendar)
Check if the date is a valid date.

Specified by:
isValidDate in interface DateModel
Parameters:
calendar - the calendar to validate
Returns:
true if the date is not in invalid dates list and passed all date filters and in the range of minDate - maxDate.

clearInvalidDates

public void clearInvalidDates()
Clear whatever invalid dates added before.


addInvalidDate

public void addInvalidDate(Calendar date)
Adds an invalid date.

Parameters:
date - the invalid date

removeInvalidDate

public void removeInvalidDate(Calendar date)
Removes an invalid date.

Parameters:
date - the invalid date

getTimeFormat

public String getTimeFormat()
Description copied from interface: DateModel
Gets the time format used by time spinner when time is displayed.

Specified by:
getTimeFormat in interface DateModel
Returns:
the time format.

setTimeFormat

public void setTimeFormat(String timeFormat)
Description copied from interface: DateModel
Sets the time format used by time spinner when time is displayed.

Specified by:
setTimeFormat in interface DateModel
Parameters:
timeFormat - the new time format

getTimeZone

public TimeZone getTimeZone()
Description copied from interface: DateModel
Gets the time zone.

Specified by:
getTimeZone in interface DateModel
Returns:
the time zone.

setTimeZone

public void setTimeZone(TimeZone timeZone)
Description copied from interface: DateModel
Sets the time zone.

Specified by:
setTimeZone in interface DateModel
Parameters:
timeZone - the time zone.

getDateFormat

public DateFormat getDateFormat()
Description copied from interface: DateModel
Gets the date format.

Specified by:
getDateFormat in interface DateModel
Returns:
the date format.

setDateFormat

public void setDateFormat(DateFormat dateFormat)
Description copied from interface: DateModel
Sets the date format.

Specified by:
setDateFormat in interface DateModel
Parameters:
dateFormat - the date format.

createCalendarInstance

public Calendar createCalendarInstance()
Creates a new Calendar instance that will be used internally.

Specified by:
createCalendarInstance in interface DateModel
Returns:
a Calendar instance.

addDateModelListener

public void addDateModelListener(DateModelListener l)
Adds a listener to the list that's notified each time a change to the date model occurs. We will not add the listener if it is already added.

Specified by:
addDateModelListener in interface DateModel
Parameters:
l - the DateModelListener

removeDateModelListener

public void removeDateModelListener(DateModelListener l)
Removes a listener from the list that's notified each time a change to the date model occurs.

Specified by:
removeDateModelListener in interface DateModel
Parameters:
l - the DateModelListener

getDateModelListeners

public DateModelListener[] getDateModelListeners()
Returns an array of all the date model listeners registered on this model.

Returns:
all of this model's DateModelListeners or an empty array if no date model listeners are currently registered

fireDateModelChanged

public void fireDateModelChanged(DateModelEvent e)
Fires the DateModelEvent.

Parameters:
e - the event

isCompareTime

public boolean isCompareTime()
Get the flag indicating if the time should be compared as well while isValidDate(java.util.Calendar) is invoked.

By default, the flag is false. DateComboBox will set this flag while DateComboBox.setTimeDisplayed(boolean) is invoked.

Specified by:
isCompareTime in interface DateModel
Returns:
true if time need to be compared. Otherwise false.

setCompareTime

public void setCompareTime(boolean compareTime)
Set the flag indicating if the time should be compared as well while isValidDate(java.util.Calendar) is invoked.

Specified by:
setCompareTime in interface DateModel
Parameters:
compareTime - the flag
See Also:
isCompareTime()

JIDE 3.5.15