|
Side of Software Dated Collections Library 2.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
D
- the type of dates used in this seriespublic interface Dates<D>
An ordered list of non-overlapping date ranges. Each date range is a pair of date objects representing an interval with a closed start and open end, [d1,d2). Date d2 must be greater than date d1. Programmers may use implementations of this interface to perform date range arithmetic, such as unioning and differencing.
To union date ranges, use addRange
to add a single date range
and addAll
to add any number of date ranges. The following diagram
shows the result of adding a Dates
object with four
ranges to a Dates
object with three ranges through a
call to addAll
.
[ ) [ ) [ ) + [ ) [ ) [ ) [ ) --------------------------------------------- [ ) [ ) [ ) [ )To find the difference between date ranges, use
removeRange
,
removeAll
, or retainAll
. The following digram
shows the result of removing a Dates
object with two ranges from a Dates
object with three ranges through
a call to removeAll
.
[ ) [ ) [ ) - [ ) [ ] ---------------------------------------------------- [ ) [ ) [ ) [ )
TreeDates
Method Summary | ||
---|---|---|
Dates<D> |
addAll(Dates<D> dates)
Adds all date ranges given by dates to this series of dates
(optional operation). |
|
Dates<D> |
addRange(D from,
D to)
Adds a date range to this series of dates (optional operation). |
|
void |
clear()
Removes all date ranges from this series of dates (optional operation). |
|
void |
complement(D from,
D to)
Modifies this Dates object so that it contains only the ranges not currently
in this Dates object (optional operation). |
|
DateIterator<D> |
dateIterator()
Returns a date iterator positioned at the first range in the series. |
|
DateIterator<D> |
dateIterator(D at)
Returns an iterator over the date ranges, starting at the range that contains the specified date. |
|
boolean |
equals(java.lang.Object obj)
Indicates if this series of dates is equivalent to the specified object. |
|
boolean |
excludesAll(Dates<D> dates)
Indicates if this series does not overlap another series of dates. |
|
boolean |
excludesRange(D from,
D to)
Indicates if no date range in this series overlaps the specified date range. |
|
int |
hashCode()
Returns the hash code value of this series of dates. |
|
boolean |
includes(D at)
Indicates if a date range in this series contains the specified date. |
|
boolean |
includesAll(Dates<D> dates)
Indicates if this series of dates contains all the date ranges given by dates . |
|
boolean |
includesRange(D from,
D to)
Indicates if a date range in this series contains the specified date range. |
|
boolean |
isEmpty()
Indicates if this series of dates is empty. |
|
Dates<D> |
removeAll(Dates<D> dates)
Removes all dates ranges given by dates from this series of dates
(optional operation). |
|
Dates<D> |
removeRange(D from,
D to)
Removes the specified range from this series of dates (optional operation). |
|
Dates<D> |
retainAll(Dates<D> dates)
Removes all but the date ranges given by dates from this
series of dates (optional operation). |
|
int |
size()
Returns the number of date ranges included in this series. |
|
java.lang.Object[] |
toDateArray()
Moves this series of dates to a newly created array of dates, where a date at an even index represents the start (inclusive) of a range and a date at an odd index represents the end (exclusive) of a range. |
|
|
toDateArray(T[] a)
Moves this series of dates to either the specified array or to a new array with the same type as the specified array, where a date at an even index represents the start (inclusive) of a range and a date at an odd index represents the end (exclusive) of a range. |
Method Detail |
---|
Dates<D> addAll(Dates<D> dates)
dates
to this series of dates
(optional operation).
The returned value indicates when this series of date ranges changed as
a result of the call and is applicable only for the specified date range.
It may be read-only, and it is not tied to this Dates
object.
dates
- series of dates to be added
java.lang.NullPointerException
- if dates
is null
java.lang.UnsupportedOperationException
- if this series of dates does not support addAll
Dates<D> addRange(D from, D to)
The returned value indicates when this series of date ranges changed as
a result of the call and is applicable only for the specified date range.
It may be read-only, and it is not tied to this Dates
object.
from
- start of the date range, inclusiveto
- end of the date range, exclusive
java.lang.IllegalArgumentException
- if from
does not precede to
java.lang.NullPointerException
- if from
or to
is null
java.lang.UnsupportedOperationException
- if this series of dates does not support addRange
void clear()
java.lang.UnsupportedOperationException
- if this series of dates does not support clear
void complement(D from, D to)
Dates
object so that it contains only the ranges not currently
in this Dates
object (optional operation).
java.lang.IllegalArgumentException
- if from
does not precede to
java.lang.NullPointerException
- if from
or to
is null
java.lang.UnsupportedOperationException
- if this series of dates does not support complement
DateIterator<D> dateIterator()
dateIterator( null )
.
DateIterator<D> dateIterator(D at)
null
as the argument will return an iterator positioned
at the beginning of the series.
at
- date to position the iteration
boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- object to be compared to this series of dates
true
if this series equals obj
boolean excludesAll(Dates<D> dates)
dates
- date ranges to test for exclusion
true
if no date range of this series overlaps
a date range of the specified series
java.lang.NullPointerException
- if dates
is null
boolean excludesRange(D from, D to)
from
- start of date range (inclusive) to test for exclusionto
- end of date range (exclusive) to test for exclusion
true
if no date range of this series overlaps
the specified date range
java.lang.IllegalArgumentException
- if from
does not precede to
java.lang.NullPointerException
- if from
or to
is null
int hashCode()
Dates
object is defined to be
hashCode += 31 * ( from.hashCode() + to.hashCode() );for each range [from,to) in this object.
hashCode
in class java.lang.Object
boolean includes(D at)
at
- date to test for inclusion
true
if this series of dates contains the specified date
java.lang.NullPointerException
- if at
is null
boolean includesAll(Dates<D> dates)
dates
.
dates
- date ranges to test for inclusion
true
if this series of dates contains all of
the specified date ranges
java.lang.NullPointerException
- if dates
is null
boolean includesRange(D from, D to)
from
- start of date range (inclusive) to test for inclusionto
- end of date range (exclusive) to test for inclusion
true
if this series of dates contains the specified date range
java.lang.IllegalArgumentException
- if from
does not precede to
java.lang.NullPointerException
- if from
or to
is null
boolean isEmpty()
true
if no date ranges exist in this seriesDates<D> removeAll(Dates<D> dates)
dates
from this series of dates
(optional operation).
The returned value indicates when this series of date ranges changed as
a result of the call and is applicable only for the specified date range.
It may be read-only, and it is not tied to this Dates
object.
dates
- date ranges to be removed
java.lang.NullPointerException
- if dates
is null
java.lang.UnsupportedOperationException
- if this series of dates does not support removeAll
Dates<D> removeRange(D from, D to)
The returned value indicates when this series of date ranges changed as
a result of the call and is applicable only for the specified date range.
It may be read-only, and it is not tied to this Dates
object.
from
- start of date range to remove (inclusive)to
- end of date range to remove (exclusive)
java.lang.IllegalArgumentException
- if from
does not precede to
java.lang.NullPointerException
- if from
or to
is null
java.lang.UnsupportedOperationException
- if this series of dates does not support removeRange
Dates<D> retainAll(Dates<D> dates)
dates
from this
series of dates (optional operation).
The returned value indicates when this series of date ranges changed as
a result of the call and is applicable only for the specified date range.
It may be read-only, and it is not tied to this Dates
object.
dates
- date ranges to retain
java.lang.NullPointerException
- if dates
is null
java.lang.UnsupportedOperationException
- if this series of dates does not support removeAll
int size()
java.lang.Object[] toDateArray()
<T> T[] toDateArray(T[] a)
java.lang.ArrayStoreException
- if the runtime type of the specified array is
not a supertype of the runtime type of the dates in this series
java.lang.NullPointerException
- if a
is null
|
Side of Software Dated Collections Library 2.0 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |