|
Side of Software Dated Collections Library 2.0 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectsos.dated.util.AbstractDates<D>
D - the type of dates used in this seriespublic abstract class AbstractDates<D>
A partial implementation of a series of date ranges. The purpose of this class
is to make it easier to implement the Dates interface. To
create an unmodifiable date range series, the programmer should subclass this
class and define dateIterator(D). To create a fully modifiable date range
series, the programmer must also define addAll, addRange,
clear, removeAll, removeRange, and retainAll.
TreeDates,
Dates| Constructor Summary | |
|---|---|
protected |
AbstractDates()
No-argument constructor available only to subclasses. |
| 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. |
|
abstract 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 date)
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> series)
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> series)
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. |
|
java.lang.String |
toString()
Returns a string representation of this series of dates. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
protected AbstractDates()
| Method Detail |
|---|
public 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.
This implementation throws an UnsupportedOperationException.
addAll in interface Dates<D>dates - series of dates to be added
java.lang.UnsupportedOperationException - always
public 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.
This implementation throws an UnsupportedOperationException.
addRange in interface Dates<D>from - start of the date range, inclusiveto - end of the date range, exclusive
java.lang.UnsupportedOperationException - alwayspublic void clear()
UnsupportedOperationException.
clear in interface Dates<D>java.lang.UnsupportedOperationException - always
public void complement(D from,
D to)
Dates object so that it contains only the ranges not currently
in this Dates object (optional operation).
This implementation throws an UnsupportedOperationException.
complement in interface Dates<D>java.lang.UnsupportedOperationException - alwayspublic DateIterator<D> dateIterator()
dateIterator( null ).
This implementation invokes dateIterator( null ).
dateIterator in interface Dates<D>public abstract DateIterator<D> dateIterator(D at)
Datesnull as the argument will return an iterator positioned
at the beginning of the series.
dateIterator in interface Dates<D>at - date to position the iteration
public boolean equals(java.lang.Object obj)
This implementation first checks reference equality and then casts obj
to another Dates object. Finally, it iterates through the ranges of each,
checking for equal ranges.
equals in interface Dates<D>equals in class java.lang.Objectobj - object to be compared to this series of dates
true if this series equals objpublic boolean excludesAll(Dates<D> dates)
dates and
checks excludesRange for each range.
excludesAll in interface Dates<D>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
public boolean excludesRange(D from,
D to)
from does not contain from or to.
excludesRange in interface Dates<D>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 nullpublic int hashCode()
DatesDates
object is defined to be
hashCode += 31 * ( from.hashCode() + to.hashCode() );for each range [from,to) in this object.
hashCode in interface Dates<D>hashCode in class java.lang.Objectpublic boolean includes(D date)
This implementation gets a date iterator at date and checks if nextFrom
is less than or equal to date.
includes in interface Dates<D>date - date to test for inclusion
true if this series of dates contains the specified date
java.lang.NullPointerException - if at is nullpublic boolean includesAll(Dates<D> dates)
dates.
This implementation iterates through the date ranges of dates, invoking
includesRange for each range.
includesAll in interface Dates<D>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
public boolean includesRange(D from,
D to)
This implementation checks if the first range of the iterator produced
by dateIterator(from) contains from and to.
includesRange in interface Dates<D>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 nullpublic boolean isEmpty()
This implementation executes
return !dateIterator().hasNext();
isEmpty in interface Dates<D>true if no date ranges exist in this seriespublic Dates<D> removeAll(Dates<D> series)
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.
This implementation throws an UnsupportedOperationException.
removeAll in interface Dates<D>series - date ranges to be removed
java.lang.UnsupportedOperationException - always
public 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.
This implementation throws an UnsupportedOperationException.
removeRange in interface Dates<D>from - start of date range to remove (inclusive)to - end of date range to remove (exclusive)
java.lang.UnsupportedOperationException - alwayspublic Dates<D> retainAll(Dates<D> series)
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.
This implementation throws an UnsupportedOperationException.
retainAll in interface Dates<D>series - date ranges to retain
java.lang.UnsupportedOperationException - alwayspublic int size()
This implementation counts the number of ranges returned by an iterator positioned at the beginning.
size in interface Dates<D>public java.lang.Object[] toDateArray()
Dates
toDateArray in interface Dates<D>public <T> T[] toDateArray(T[] a)
Dates
toDateArray in interface Dates<D>public java.lang.String toString()
toString in class java.lang.Object
|
Side of Software Dated Collections Library 2.0 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||