org.beanfabrics.samples.timespan
Class TimeSpanPM

java.lang.Object
  extended by org.beanfabrics.AbstractBean
      extended by org.beanfabrics.ValidatableBean
          extended by org.beanfabrics.model.AbstractPM
              extended by org.beanfabrics.samples.timespan.TimeSpanPM
All Implemented Interfaces:
Bean, ContextOwner, HasComparable, PresentationModel, Supportable, Validatable

public class TimeSpanPM
extends AbstractPM

The TimeSpanPM is a presentation model for editing a period of time. The start date must be before or equal the end date.


Nested Class Summary
 
Nested classes/interfaces inherited from class org.beanfabrics.model.AbstractPM
AbstractPM.PropertiesValidationRule
 
Field Summary
 IntegerPM days
           
 DatePM end
           
 DatePM start
           
 
Fields inherited from class org.beanfabrics.model.AbstractPM
KEY_MESSAGE_ONE_OR_MORE_INVALID
 
Constructor Summary
TimeSpanPM()
           
TimeSpanPM(java.util.Date startDate, java.util.Date endDate)
           
 
Method Summary
 java.util.Date getEndDate()
           
 java.util.Date getStartDate()
           
 boolean isPositivePeriod()
          Validates start date and end date if their time span is a positive period.
 void setEndDate(java.util.Date endDate)
           
 void setStartDate(java.util.Date startDate)
           
 void updateDays()
          Calculates the number of days between start and end date, and updates the "days" field with this value.
 
Methods inherited from class org.beanfabrics.model.AbstractPM
getComparable, getContext, getSupportMap, revalidateProperties
 
Methods inherited from class org.beanfabrics.ValidatableBean
getValidationState, getValidator, isValid, revalidate, setValidationState
 
Methods inherited from class org.beanfabrics.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, equals, getPropertyChangeSupport, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.beanfabrics.Bean
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeSupport, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from interface org.beanfabrics.validation.Validatable
getValidationState, getValidator, isValid, revalidate
 

Field Detail

start

public final DatePM start

end

public final DatePM end

days

public final IntegerPM days
Constructor Detail

TimeSpanPM

public TimeSpanPM()

TimeSpanPM

public TimeSpanPM(java.util.Date startDate,
                  java.util.Date endDate)
Method Detail

isPositivePeriod

public boolean isPositivePeriod()
Validates start date and end date if their time span is a positive period.

Returns:
true, if the time span is a positive period

updateDays

public void updateDays()
Calculates the number of days between start and end date, and updates the "days" field with this value. This method is called automatically when any of the date fields change.


getStartDate

public java.util.Date getStartDate()

setStartDate

public void setStartDate(java.util.Date startDate)

getEndDate

public java.util.Date getEndDate()

setEndDate

public void setEndDate(java.util.Date endDate)