com.ds.fw.types.data
Interface FwDateIntervalIF

All Superinterfaces:
java.lang.Cloneable, java.lang.Comparable, FwCopyableIF, FwDisplayableIF, FwSimpleObjectIF, java.io.Serializable
All Known Implementing Classes:
FwDateInterval

public interface FwDateIntervalIF
extends FwSimpleObjectIF, java.lang.Comparable

A DateInterval describes some duration of time. The start and end dates of the date interval may be defined or undefined, or inclusive or exclusive. An undefined start or end date describes the interval as being unbounded towards negative or positive eternity. If the intervals start or end dates are described as inclusive, then that date is considered to be included within the duration, rather than simply marking its boundary. By default, a DateInterval's start and end dates are inclusive. A DateInterval must not represent a bounded span of days larger then ~5.8 million years.


Field Summary
static int INFINITY
           
 
Method Summary
 boolean contains(com.ds.fw.types.data.FwDateIF d)
          Determine if the date is contained in this interval.
 boolean contains(com.ds.fw.types.data.FwDateIntervalIF di)
          Same as containsInterval(di).
 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)
          Determine if the date interval parameter is wholly contained within this date interval.
 boolean containsToday()
          Determine if today is contained in this interval.
 java.util.Enumeration elements()
          Return an Enumeration iterating over the days contained in this DateInterval.
 boolean endsAfter(com.ds.fw.types.data.FwDateIF d)
          Determine if this date interval ends after some date.
 boolean endsBefore(com.ds.fw.types.data.FwDateIF d)
          Detemine if this date interval ends before some date.
 boolean endsOn(com.ds.fw.types.data.FwDateIF d)
          Determine if an input date is the last day contained within this DateInterval.
 boolean endsOnOrAfter(com.ds.fw.types.data.FwDateIF d)
          Determine if this interval ends on or after a date.
 com.ds.fw.types.data.FwDateIntervalIF getDateIntervalCopy()
          Get and independent copy of this date interval.
 com.ds.fw.types.data.FwDateIF getEndDate()
          Return the end date.
 com.ds.fw.types.data.FwDateIF getFirstDate()
          Return the first date contained within this interval.
 com.ds.fw.types.data.FwDateIntervalIF getIntersection(com.ds.fw.types.data.FwDateIntervalIF di)
          Get the date interval the represents the intersection of this date interval with another interval.
 com.ds.fw.types.data.FwDateIF getLastDate()
          Return the last date contained within this interval.
 int getNumberOfDays()
          Return the number of days that are contained inside of this DateInterval.
 com.ds.fw.types.data.FwDateIF getStartDate()
          Return the start date.
 com.ds.fw.types.data.FwDateIntervalIF getUnion(com.ds.fw.types.data.FwDateIntervalIF di)
          Merge my interval with di and return the result.
 boolean hasBoundedEnd()
          Determine if the end date is bounded (!null).
 boolean hasBoundedStart()
          Determine if the startDate is bounded (!null).
 boolean hasUnboundedEnd()
          Determine if the end date is unbounded (null).
 boolean hasUnboundedStart()
          Determine if the startDate is unbounded (null).
 boolean intersects(com.ds.fw.types.data.FwDateIntervalIF di)
          Same as intersectsInterval(di);
 boolean intersectsInterval(com.ds.fw.types.data.FwDateIntervalIF di)
          Determine if this date interval overlaps another date interval.
 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()
          Determine if both the start and end dates are bounded.
 boolean isEndDateInclusive()
          Return a boolean describing whether or not the end date is considered to be contained within the DateInterval.
 boolean isInfinity()
          same as isUnbounded().
 boolean isStartDateInclusive()
          Return a boolean describing whether or not the start date is considered to be contained within the DateInterval.
 boolean isUnbounded()
          Determine if both the start and end dates are unbounded.
 boolean isValid()
          Determine if the first date is less than or equal to the end date.
 java.util.Iterator iterator()
          Same as elements but return an iterator.
 void makeEndDateExclusive()
          Make the end date be exclusive.
 void makeEndDateInclusive()
          Make the end date be inclusive.
 void makeStartDateExclusive()
          Make the start date be exclusive.
 void makeStartDateInclusive()
          Make the start date be inclusive.
 boolean merge(com.ds.fw.types.data.FwDateIntervalIF di)
          Merge my interval with di.
 boolean mergeAdjacent(com.ds.fw.types.data.FwDateIntervalIF di)
          Merge my interval with di.
 void setEndDate(com.ds.fw.types.data.FwDateIF d)
          Set the end date.
 void setStartDate(com.ds.fw.types.data.FwDateIF d)
          Set the start date.
 int size()
          Same as getNumberOfDays()
 boolean startsAfter(com.ds.fw.types.data.FwDateIF d)
          Detemine if this date interval starts after some date.
 boolean startsBefore(com.ds.fw.types.data.FwDateIF d)
          Determine if this date interval starts before some date.
 boolean startsLaterThan(com.ds.fw.types.data.FwDateIntervalIF di)
          Return whether this date interval starts later than the indicated date interval.
 boolean startsOn(com.ds.fw.types.data.FwDateIF d)
          Return a boolean describing whether or not an input date is the first day contained within this DateInterval.
 boolean startsOnOrBefore(com.ds.fw.types.data.FwDateIF d)
          Determine if this interval starts on or before a date.
 
Methods inherited from interface com.ds.fw.types.FwSimpleObjectIF
getClassName, getClone, getCopy, getCopy, getDeepCopy, getDisplayString, getDisplayStringFor, postCopy, toString, toStringValue
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

INFINITY

public static final int INFINITY
See Also:
Constant Field Values
Method Detail

getStartDate

public com.ds.fw.types.data.FwDateIF getStartDate()
Return the start date. The start date describes the beginning of the DateInterval. It may be either inclusive or exclusive. If it is inclusive, then the start date is considered to be contained inside of the DateInterval. If it is exclusive, it merely marks the beggining of the interval but is NOT actually a part of it.


setStartDate

public void setStartDate(com.ds.fw.types.data.FwDateIF d)
Set the start date.


getEndDate

public com.ds.fw.types.data.FwDateIF getEndDate()
Return the end date. The end date describes the end of the DateInterval. It may be either inclusive or exclusive. If it is inclusive, then the end date is considered to be contained inside of the DateInterval. If it is exclusive, it merely marks the end of the interval but is NOT actually a part of it.


setEndDate

public void setEndDate(com.ds.fw.types.data.FwDateIF d)
Set the end date.


elements

public java.util.Enumeration elements()
Return an Enumeration iterating over the days contained in this DateInterval.

See Also:
FwDateIntervalEnumerationIF

iterator

public java.util.Iterator iterator()
Same as elements but return an iterator.


getNumberOfDays

public int getNumberOfDays()
Return the number of days that are contained inside of this DateInterval.


size

public int size()
Same as getNumberOfDays()


getFirstDate

public com.ds.fw.types.data.FwDateIF getFirstDate()
Return the first date contained within this interval. If the start date in inclusive then the first date is equal to the start date. If the start date in exclusive then the first date is the day after the start date. If the start date is null then the first date is null.


getLastDate

public com.ds.fw.types.data.FwDateIF getLastDate()
Return the last date contained within this interval. If the end date is inclusive then the last date is equal to the end date. If the end date is exclusive then the last date is the day before the end date. If the end date is null then the last date is null.


isValid

public boolean isValid()
Determine if the first date is less than or equal to the end date. If either of the dates is null return true.


contains

public boolean contains(com.ds.fw.types.data.FwDateIF d)
Determine if the date is contained in this interval.


contains

public boolean contains(com.ds.fw.types.data.FwTimestampIF ts)
Determine if the timestamp is contained in this interval.


containsToday

public boolean containsToday()
Determine if today is contained in this interval.


containsInterval

public boolean containsInterval(com.ds.fw.types.data.FwDateIntervalIF di)
Determine if the date interval parameter is wholly contained within this date interval.


contains

public boolean contains(com.ds.fw.types.data.FwDateIntervalIF di)
Same as containsInterval(di).


intersectsInterval

public boolean intersectsInterval(com.ds.fw.types.data.FwDateIntervalIF di)
Determine if this date interval overlaps another date interval.


intersects

public boolean intersects(com.ds.fw.types.data.FwDateIntervalIF di)
Same as intersectsInterval(di);


getIntersection

public com.ds.fw.types.data.FwDateIntervalIF getIntersection(com.ds.fw.types.data.FwDateIntervalIF di)
Get the date interval the represents the intersection of this date interval with another interval. If the two date intervals do not intersect return null.


getUnion

public com.ds.fw.types.data.FwDateIntervalIF getUnion(com.ds.fw.types.data.FwDateIntervalIF di)
Merge my interval with di and return the result. This does not mutate myself or the di parameter. If I do not intersect di then return null.


merge

public boolean merge(com.ds.fw.types.data.FwDateIntervalIF di)
Merge my interval with di. If I do not intersect with di then do nothing and return false. Return true iff I am modified.


mergeAdjacent

public boolean mergeAdjacent(com.ds.fw.types.data.FwDateIntervalIF di)
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.


startsOn

public boolean startsOn(com.ds.fw.types.data.FwDateIF d)
Return a boolean describing whether or not an input date is the first day contained within this DateInterval.


startsBefore

public boolean startsBefore(com.ds.fw.types.data.FwDateIF d)
Determine if this date interval starts before some date. If d == null return false.


startsAfter

public boolean startsAfter(com.ds.fw.types.data.FwDateIF d)
Detemine if this date interval starts after some date. If d == null return firstDate != null.


endsOn

public boolean endsOn(com.ds.fw.types.data.FwDateIF d)
Determine if an input date is the last day contained within this DateInterval.


endsBefore

public boolean endsBefore(com.ds.fw.types.data.FwDateIF d)
Detemine if this date interval ends before some date. If d == null return lastDate != null.


endsAfter

public boolean endsAfter(com.ds.fw.types.data.FwDateIF d)
Determine if this date interval ends after some date. If d == null return false.


startsOnOrBefore

public boolean startsOnOrBefore(com.ds.fw.types.data.FwDateIF d)
Determine if this interval starts on or before a date.

See Also:
startsOn(), startsBefore()

endsOnOrAfter

public boolean endsOnOrAfter(com.ds.fw.types.data.FwDateIF d)
Determine if this interval ends on or after a date.

See Also:
endsOn(), endsAfter()

hasBoundedStart

public boolean hasBoundedStart()
Determine if the startDate is bounded (!null).


hasUnboundedStart

public boolean hasUnboundedStart()
Determine if the startDate is unbounded (null).


hasBoundedEnd

public boolean hasBoundedEnd()
Determine if the end date is bounded (!null).


hasUnboundedEnd

public boolean hasUnboundedEnd()
Determine if the end date is unbounded (null).


isBounded

public boolean isBounded()
Determine if both the start and end dates are bounded. Note that isBounded is not guaranteed to be equals to !isUnbounded()


isUnbounded

public boolean isUnbounded()
Determine if both the start and end dates are unbounded. Note that isBounded is not guaranteed to be equals to !isUnbounded()


isInfinity

public boolean isInfinity()
same as isUnbounded().


isStartDateInclusive

public boolean isStartDateInclusive()
Return a boolean describing whether or not the start date is considered to be contained within the DateInterval. The start date is contained within the DateInterval if it is inclusive.

Returns:
boolean

isEndDateInclusive

public boolean isEndDateInclusive()
Return a boolean describing whether or not the end date is considered to be contained within the DateInterval. The end date is contained within the DateInterval if it is inclusive.

Returns:
boolean

startsLaterThan

public boolean startsLaterThan(com.ds.fw.types.data.FwDateIntervalIF di)
Return whether this date interval starts later than the indicated date interval.

Returns:
boolean

isAdjacentTo

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

See Also:
isAdjacentAfter(), isAdjacentBefore()

isAdjacentAfter

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


isAdjacentBefore

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


makeStartDateInclusive

public void makeStartDateInclusive()
Make the start date be inclusive.


makeStartDateExclusive

public void makeStartDateExclusive()
Make the start date be exclusive.


makeEndDateInclusive

public void makeEndDateInclusive()
Make the end date be inclusive.


makeEndDateExclusive

public void makeEndDateExclusive()
Make the end date be exclusive.


getDateIntervalCopy

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