com.ds.fw.types.data
Class FwDateInterval

java.lang.Object
  |
  +--com.ds.fw.types.FwSimpleObject
        |
        +--com.ds.fw.types.data.FwDateInterval
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable, FwCopyableIF, FwDateIntervalIF, FwDisplayableIF, FwSimpleObjectIF, java.io.Serializable

public class FwDateInterval
extends FwSimpleObject
implements FwDateIntervalIF

See Also:
Serialized Form

Field Summary
 com.ds.fw.types.data.FwDateIF _endDate
           
 boolean _endDateInclusiveIndicator
           
 com.ds.fw.types.data.FwDateIF _startDate
           
 boolean _startDateInclusiveIndicator
           
 
Fields inherited from interface com.ds.fw.types.data.FwDateIntervalIF
INFINITY
 
Constructor Summary
FwDateInterval()
           Initializes a newly created FwDateInterval object with null start and end date.
FwDateInterval(com.ds.fw.types.data.FwDateIF a, com.ds.fw.types.data.FwDateIF b)
           Initializes a newly created FwDateInterval object with a start and end date (which are inclusive)
 
Method Summary
 boolean compareDates(com.ds.fw.types.data.FwDateIF d1, com.ds.fw.types.data.FwDateIF d2)
          Compare two dates
 int compareTo(java.lang.Object e)
          Check the position of an interval compared to another interval
 boolean contains(com.ds.fw.types.data.FwDateIF d)
          Check if the date interval contains the date , given as parameter
 boolean contains(com.ds.fw.types.data.FwDateIntervalIF di)
          Verify if the date interval contains other date interval(given as parameter).
 boolean contains(com.ds.fw.types.data.FwTimestampIF ts)
          Determine if the timestamp is contained in this interval.
 boolean containsInterval(com.ds.fw.types.data.FwDateIntervalIF di)
          Verify if the date interval contains other date interval(given as parameter).
 boolean containsToday()
          Check if the date interval contains the today's date
static com.ds.fw.types.data.FwDateIntervalIF createDateInterval(com.ds.fw.types.data.FwDateIF d1)
           
static com.ds.fw.types.data.FwDateIntervalIF createDateInterval(com.ds.fw.types.data.FwDateIF a, com.ds.fw.types.data.FwDateIF b)
          Creates a date interval
static com.ds.fw.types.data.FwDateIntervalIF createDateInterval(int i, int j)
           
 java.util.Enumeration elements()
          Gets an enumeration of the dates that the interval contains
 boolean endsAfter(com.ds.fw.types.data.FwDateIF d)
          Check if the interval ends after a given date
 boolean endsBefore(com.ds.fw.types.data.FwDateIF d)
          Check if the interval ends before a given date
 boolean endsOn(com.ds.fw.types.data.FwDateIF d)
          Check if the interval ends on a given date
 boolean endsOnOrAfter(com.ds.fw.types.data.FwDateIF d)
          Check if a date is in or after the interval
 boolean equals(java.lang.Object o)
          Check if two intervals are equals
 com.ds.fw.types.data.FwDateIntervalIF getDateIntervalCopy()
          Get and independent copy of this date interval.
 com.ds.fw.types.data.FwDateIF getEndDate()
          Gets the end date of the interval
 com.ds.fw.types.data.FwDateIF getFirstDate()
          Gets the first date of the interval
 com.ds.fw.types.data.FwDateIntervalIF getIntersection(com.ds.fw.types.data.FwDateIntervalIF di1)
          Gets the intersection interval between the date interval and the interval given as parameter
 com.ds.fw.types.data.FwDateIF getLastDate()
          Gets the last date of the interval.
 int getNumberOfDays()
          Find the number of the days for the interval
 com.ds.fw.types.data.FwDateIF getStartDate()
          Gets the start date of the interval
 com.ds.fw.types.data.FwDateIntervalIF getUnion(com.ds.fw.types.data.FwDateIntervalIF di)
          Gets the union of two intervals
 boolean hasBoundedEnd()
          Check if the interval has end date
 boolean hasBoundedStart()
          Check if the interval has start date
 boolean hasUnboundedEnd()
          Check if the interval has no end date
 boolean hasUnboundedStart()
          Check if the interval has no start date
 boolean intersects(com.ds.fw.types.data.FwDateIntervalIF di2)
          Verify if there is intersection between the date interval and the interval given as parameter
 boolean intersectsInterval(com.ds.fw.types.data.FwDateIntervalIF di)
          Verify if there is intersection between the date interval and the interval given as parameter Calls method intersects(FwDateIntervalIF di2)
 boolean isAdjacentAfter(com.ds.fw.types.data.FwDateIntervalIF di)
          Determine if my firstDate is the day after the parameter's lastDate.
 boolean isAdjacentBefore(com.ds.fw.types.data.FwDateIntervalIF di)
          Determine if my lastDate is the day before the parameter's firstDate.
 boolean isAdjacentTo(com.ds.fw.types.data.FwDateIntervalIF di)
          Determine if this interval is adjacent before or adjacent after another interval.
 boolean isBounded()
          Check if the interval has start and end date different from null
 boolean isEndDateInclusive()
          Check if the interval contains the end date or not
 boolean isInfinity()
          Check if the interval has start and end date .
 boolean isStartDateInclusive()
          Check if the interval contains the start date or not
 boolean isUnbounded()
          Check if the interval start and end date are null
 boolean isValid()
          Verify is the date interval is valid
 java.util.Iterator iterator()
          Same as elements but return an iterator.
 void makeEndDateExclusive()
          Excludes the end date from the interval
 void makeEndDateInclusive()
          Includes the end date to the interval
 void makeStartDateExclusive()
          Excluses the start date from the interval
 void makeStartDateInclusive()
          Includes the start date to the interval
 boolean merge(com.ds.fw.types.data.FwDateIntervalIF di)
          Merge two intervals
 boolean mergeAdjacent(com.ds.fw.types.data.FwDateIntervalIF di)
          Merge my interval with di.
 void postCopy()
          This should never be called directly from a client.
 void setEndDate(com.ds.fw.types.data.FwDateIF o)
          Sets the end date of the interval
 void setStartDate(com.ds.fw.types.data.FwDateIF o)
          Sets the start date of the interval
 int size()
          Gets the number of the days for the interval(the same as method getNumberOfDays).
 boolean startsAfter(com.ds.fw.types.data.FwDateIF d)
          Verify if an interval starts after a given date
 boolean startsBefore(com.ds.fw.types.data.FwDateIF d)
          Verify if an interval starts before a given date
 boolean startsLaterThan(com.ds.fw.types.data.FwDateIntervalIF di)
          Check if the interval starts later than another interval (given as parameter)
 boolean startsOn(com.ds.fw.types.data.FwDateIF d)
          Verify if an interval starts on a given date
 boolean startsOnOrBefore(com.ds.fw.types.data.FwDateIF d)
          Check if the date is before or in the interval
 java.lang.String toStringValue()
          Gets the string representation of the interval - StartDate-EndDate:X1:X2 where X1 is T if the start date is in the interval , F - otherwise X2 is T if the end date is in the interval , F - otherwise
 
Methods inherited from class com.ds.fw.types.FwSimpleObject
getClassName, getClone, getCopy, getCopy, getDeepCopy, getDisplayString, getDisplayStringFor, printStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.ds.fw.types.FwSimpleObjectIF
getClassName, getClone, getCopy, getCopy, getDeepCopy, getDisplayString, getDisplayStringFor, toString
 

Field Detail

_startDate

public com.ds.fw.types.data.FwDateIF _startDate

_endDate

public com.ds.fw.types.data.FwDateIF _endDate

_startDateInclusiveIndicator

public boolean _startDateInclusiveIndicator

_endDateInclusiveIndicator

public boolean _endDateInclusiveIndicator
Constructor Detail

FwDateInterval

public FwDateInterval()
 Initializes a newly created FwDateInterval object with null start and end date.


FwDateInterval

public FwDateInterval(com.ds.fw.types.data.FwDateIF a,
                      com.ds.fw.types.data.FwDateIF b)
 Initializes a newly created FwDateInterval object with a start and end date (which are inclusive)

Parameters:
a - - the start date
b - - the end date
Method Detail

createDateInterval

public static com.ds.fw.types.data.FwDateIntervalIF createDateInterval(com.ds.fw.types.data.FwDateIF d1)

createDateInterval

public static com.ds.fw.types.data.FwDateIntervalIF createDateInterval(com.ds.fw.types.data.FwDateIF a,
                                                                       com.ds.fw.types.data.FwDateIF b)
Creates a date interval

Parameters:
a - - the start date
b - - the end date
Returns:
the created interval

createDateInterval

public static com.ds.fw.types.data.FwDateIntervalIF createDateInterval(int i,
                                                                       int j)

getStartDate

public com.ds.fw.types.data.FwDateIF getStartDate()
Gets the start date of the interval

Specified by:
getStartDate in interface FwDateIntervalIF
Returns:
the start date

setStartDate

public void setStartDate(com.ds.fw.types.data.FwDateIF o)
Sets the start date of the interval

Specified by:
setStartDate in interface FwDateIntervalIF
Parameters:
o - - the new start date

getEndDate

public com.ds.fw.types.data.FwDateIF getEndDate()
Gets the end date of the interval

Specified by:
getEndDate in interface FwDateIntervalIF
Returns:
the end date

setEndDate

public void setEndDate(com.ds.fw.types.data.FwDateIF o)
Sets the end date of the interval

Specified by:
setEndDate in interface FwDateIntervalIF
Parameters:
o - - the new end date

elements

public java.util.Enumeration elements()
Gets an enumeration of the dates that the interval contains

Specified by:
elements in interface FwDateIntervalIF
Returns:
enumeration of the elements of the interval
See Also:
FwDateIntervalEnumerationIF

iterator

public java.util.Iterator iterator()
Description copied from interface: FwDateIntervalIF
Same as elements but return an iterator.

Specified by:
iterator in interface FwDateIntervalIF

getNumberOfDays

public int getNumberOfDays()
Find the number of the days for the interval

Specified by:
getNumberOfDays in interface FwDateIntervalIF
Returns:
the number of the days

size

public int size()
Gets the number of the days for the interval(the same as method getNumberOfDays).

Specified by:
size in interface FwDateIntervalIF
Returns:
the size of the interval(the number of the days)

getFirstDate

public com.ds.fw.types.data.FwDateIF getFirstDate()
Gets the first date of the interval

Specified by:
getFirstDate in interface FwDateIntervalIF
Returns:
the first date of the interval , null if it has not start date

getLastDate

public com.ds.fw.types.data.FwDateIF getLastDate()
Gets the last date of the interval.

Specified by:
getLastDate in interface FwDateIntervalIF
Returns:
the last date of the interval , null if it has not last date

isValid

public boolean isValid()
Verify is the date interval is valid

Specified by:
isValid in interface FwDateIntervalIF
Returns:

contains

public boolean contains(com.ds.fw.types.data.FwDateIF d)
Check if the date interval contains the date , given as parameter

Specified by:
contains in interface FwDateIntervalIF
Parameters:
d - - the date
Returns:
true if it is in the interval and false - otherwise

contains

public boolean contains(com.ds.fw.types.data.FwTimestampIF ts)
Description copied from interface: FwDateIntervalIF
Determine if the timestamp is contained in this interval.

Specified by:
contains in interface FwDateIntervalIF

containsToday

public boolean containsToday()
Check if the date interval contains the today's date

Specified by:
containsToday in interface FwDateIntervalIF
Returns:
true if the interval contains the today's date, false - otherwise

contains

public boolean contains(com.ds.fw.types.data.FwDateIntervalIF di)
Verify if the date interval contains other date interval(given as parameter). Calls method containsInterval(FwDateIntervalIF di)

Specified by:
contains in interface FwDateIntervalIF
Parameters:
di -
Returns:
true if the date interval contains the other(given as parameter to the method), false - otherwise

containsInterval

public boolean containsInterval(com.ds.fw.types.data.FwDateIntervalIF di)
Verify if the date interval contains other date interval(given as parameter).

Specified by:
containsInterval in interface FwDateIntervalIF
Parameters:
di -
Returns:
true if the date interval contains the other(given as parameter to the method), false - otherwise

intersectsInterval

public boolean intersectsInterval(com.ds.fw.types.data.FwDateIntervalIF di)
Verify if there is intersection between the date interval and the interval given as parameter Calls method intersects(FwDateIntervalIF di2)

Specified by:
intersectsInterval in interface FwDateIntervalIF
Parameters:
di -
Returns:
true - if there is intersection, false - otherwise

intersects

public boolean intersects(com.ds.fw.types.data.FwDateIntervalIF di2)
Verify if there is intersection between the date interval and the interval given as parameter

Specified by:
intersects in interface FwDateIntervalIF
Parameters:
di2 -
Returns:
true - if there is intersection, false - otherwise

getIntersection

public com.ds.fw.types.data.FwDateIntervalIF getIntersection(com.ds.fw.types.data.FwDateIntervalIF di1)
Gets the intersection interval between the date interval and the interval given as parameter

Specified by:
getIntersection in interface FwDateIntervalIF
Parameters:
di1 -
Returns:
the intersection interval , null if there isn't intersection

getUnion

public com.ds.fw.types.data.FwDateIntervalIF getUnion(com.ds.fw.types.data.FwDateIntervalIF di)
Gets the union of two intervals

Specified by:
getUnion in interface FwDateIntervalIF
Parameters:
di - - the second date interval
Returns:
an interval which is the union between two interval null - if they are equals or they have no intersection

merge

public boolean merge(com.ds.fw.types.data.FwDateIntervalIF di)
Merge two intervals

Specified by:
merge in interface FwDateIntervalIF
Parameters:
di - - the second interval (which we want to merge to our)
Returns:
true if the operation was successful , false if there are equals or they have no intersection

mergeAdjacent

public boolean mergeAdjacent(com.ds.fw.types.data.FwDateIntervalIF di)
Description copied from interface: FwDateIntervalIF
Merge my interval with di. If I am not intersecting or adjacent to di then do nothing and return false. Return true iff I am modified.

Specified by:
mergeAdjacent in interface FwDateIntervalIF

startsOn

public boolean startsOn(com.ds.fw.types.data.FwDateIF d)
Verify if an interval starts on a given date

Specified by:
startsOn in interface FwDateIntervalIF
Parameters:
d - - the date
Returns:
true if the interval starts on the date given as parameter, false - otherwise

startsBefore

public boolean startsBefore(com.ds.fw.types.data.FwDateIF d)
Verify if an interval starts before a given date

Specified by:
startsBefore in interface FwDateIntervalIF
Parameters:
d - - the date for which we check
Returns:
true if the date is before the given interval

startsAfter

public boolean startsAfter(com.ds.fw.types.data.FwDateIF d)
Verify if an interval starts after a given date

Specified by:
startsAfter in interface FwDateIntervalIF
Parameters:
d - - the date for which we check
Returns:
true if the date is after the given interval

startsOnOrBefore

public boolean startsOnOrBefore(com.ds.fw.types.data.FwDateIF d)
Check if the date is before or in the interval

Specified by:
startsOnOrBefore in interface FwDateIntervalIF
Parameters:
d - - the date we check for
Returns:
true if the date is in the interval or before it, false - otherwise
See Also:
startsOn(), startsBefore()

endsOn

public boolean endsOn(com.ds.fw.types.data.FwDateIF d)
Check if the interval ends on a given date

Specified by:
endsOn in interface FwDateIntervalIF
Parameters:
d - - the date for which we check
Returns:
true if the interval ends on the given as parameter date , false - otherwise

endsAfter

public boolean endsAfter(com.ds.fw.types.data.FwDateIF d)
Check if the interval ends after a given date

Specified by:
endsAfter in interface FwDateIntervalIF
Parameters:
d - - the date for which we check
Returns:
true if it end after the given as parameter date, false - otherwise

endsBefore

public boolean endsBefore(com.ds.fw.types.data.FwDateIF d)
Check if the interval ends before a given date

Specified by:
endsBefore in interface FwDateIntervalIF
Parameters:
d - - the date for which we check
Returns:
true if the interval ends before the given as parameter date , false - otherwise

endsOnOrAfter

public boolean endsOnOrAfter(com.ds.fw.types.data.FwDateIF d)
Check if a date is in or after the interval

Specified by:
endsOnOrAfter in interface FwDateIntervalIF
Parameters:
d - - the date for which we check
Returns:
true if the date is in or it is after the interval , false - otherwise
See Also:
endsOn(), endsAfter()

isStartDateInclusive

public boolean isStartDateInclusive()
Check if the interval contains the start date or not

Specified by:
isStartDateInclusive in interface FwDateIntervalIF
Returns:
true if it contains the start date

isEndDateInclusive

public boolean isEndDateInclusive()
Check if the interval contains the end date or not

Specified by:
isEndDateInclusive in interface FwDateIntervalIF
Returns:
true if it contains the end date

startsLaterThan

public boolean startsLaterThan(com.ds.fw.types.data.FwDateIntervalIF di)
Check if the interval starts later than another interval (given as parameter)

Specified by:
startsLaterThan in interface FwDateIntervalIF
Parameters:
di -
Returns:
true if the interval starts later than the interval , given as parameter false - otherwise

hasBoundedStart

public boolean hasBoundedStart()
Check if the interval has start date

Specified by:
hasBoundedStart in interface FwDateIntervalIF
Returns:
true - if there is a start date , false if the start date is null
See Also:
hasUnboundedStart()

hasUnboundedStart

public boolean hasUnboundedStart()
Check if the interval has no start date

Specified by:
hasUnboundedStart in interface FwDateIntervalIF
Returns:
true if the start date is null , false - otherwise
See Also:
hasUnboundedStart()

hasBoundedEnd

public boolean hasBoundedEnd()
Check if the interval has end date

Specified by:
hasBoundedEnd in interface FwDateIntervalIF
Returns:
true if it has an end date, false if the end date is null
See Also:
hasUnboundedEnd()

hasUnboundedEnd

public boolean hasUnboundedEnd()
Check if the interval has no end date

Specified by:
hasUnboundedEnd in interface FwDateIntervalIF
Returns:
true if the end date is null , false - otherwise
See Also:
hasBoundedEnd()

isBounded

public boolean isBounded()
Check if the interval has start and end date different from null

Specified by:
isBounded in interface FwDateIntervalIF
Returns:
true if the start and the end date are not null, false - otherwise

isUnbounded

public boolean isUnbounded()
Check if the interval start and end date are null

Specified by:
isUnbounded in interface FwDateIntervalIF
Returns:
true if the start and the end date are null, false - otherwise

isInfinity

public boolean isInfinity()
Check if the interval has start and end date . Calls method isUnbounded

Specified by:
isInfinity in interface FwDateIntervalIF
Returns:
true if there is no start and end date

isAdjacentTo

public boolean isAdjacentTo(com.ds.fw.types.data.FwDateIntervalIF di)
Description copied from interface: FwDateIntervalIF
Determine if this interval is adjacent before or adjacent after another interval.

Specified by:
isAdjacentTo in interface FwDateIntervalIF
See Also:
isAdjacentAfter(), isAdjacentBefore()

isAdjacentAfter

public boolean isAdjacentAfter(com.ds.fw.types.data.FwDateIntervalIF di)
Description copied from interface: FwDateIntervalIF
Determine if my firstDate is the day after the parameter's lastDate.

Specified by:
isAdjacentAfter in interface FwDateIntervalIF

isAdjacentBefore

public boolean isAdjacentBefore(com.ds.fw.types.data.FwDateIntervalIF di)
Description copied from interface: FwDateIntervalIF
Determine if my lastDate is the day before the parameter's firstDate.

Specified by:
isAdjacentBefore in interface FwDateIntervalIF

makeStartDateInclusive

public void makeStartDateInclusive()
Includes the start date to the interval

Specified by:
makeStartDateInclusive in interface FwDateIntervalIF

makeStartDateExclusive

public void makeStartDateExclusive()
Excluses the start date from the interval

Specified by:
makeStartDateExclusive in interface FwDateIntervalIF

makeEndDateInclusive

public void makeEndDateInclusive()
Includes the end date to the interval

Specified by:
makeEndDateInclusive in interface FwDateIntervalIF

makeEndDateExclusive

public void makeEndDateExclusive()
Excludes the end date from the interval

Specified by:
makeEndDateExclusive in interface FwDateIntervalIF

equals

public boolean equals(java.lang.Object o)
Check if two intervals are equals

Overrides:
equals in class java.lang.Object
Parameters:
o - - the second interval
Returns:
true if they are equals , false - otherwise

compareTo

public int compareTo(java.lang.Object e)
Check the position of an interval compared to another interval

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
e - - the second interval
Returns:
0 - if they are equals, -1 if the interval starts before the interval , given as parameter 1 - if the interval starts after the other interval (given as parameter)

compareDates

public boolean compareDates(com.ds.fw.types.data.FwDateIF d1,
                            com.ds.fw.types.data.FwDateIF d2)
Compare two dates

Parameters:
d1 - - the first date
d2 - - the second date
Returns:
true if they are both null , or they are equals, false - otherwise

toStringValue

public java.lang.String toStringValue()
Gets the string representation of the interval - StartDate-EndDate:X1:X2 where X1 is T if the start date is in the interval , F - otherwise X2 is T if the end date is in the interval , F - otherwise

Specified by:
toStringValue in interface FwSimpleObjectIF
Overrides:
toStringValue in class FwSimpleObject
Returns:
the string representation of the interval

getDateIntervalCopy

public com.ds.fw.types.data.FwDateIntervalIF getDateIntervalCopy()
Description copied from interface: FwDateIntervalIF
Get and independent copy of this date interval. Any changes to the copy or its dates should not affect the original.

Specified by:
getDateIntervalCopy in interface FwDateIntervalIF

postCopy

public void postCopy()
Description copied from interface: FwCopyableIF
This should never be called directly from a client. This method is used to make a clone independent from its original. Subclasses that override this method should always call super.postCopy().

Specified by:
postCopy in interface FwSimpleObjectIF
Overrides:
postCopy in class FwSimpleObject