|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--sos.dated.util.AbstractDates
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(Date). 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 |
addAll(Dates series)
Adds all date ranges given by dates to this series of dates. |
Dates |
addRange(java.util.Date from,
java.util.Date to)
Adds a date range to this series of dates. |
void |
clear()
Removes all date ranges from this series of dates. |
void |
complement()
Modifies this Dates object so that it contains only the ranges not currently
in this Dates object. |
DateIterator |
dateIterator()
Returns a date iterator positioned at the first range in the series. |
abstract DateIterator |
dateIterator(java.util.Date date)
Returns an iterator over the date ranges, beginning with from,
inclusive, and ending with to, exclusive. |
boolean |
equals(java.lang.Object obj)
Indicates if this series of dates is equivalent to the specified object. |
boolean |
excludesAll(Dates dates)
Indicates if this series does not overlap another series of dates. |
boolean |
excludesRange(java.util.Date from,
java.util.Date 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(java.util.Date date)
Indicates if a date range in this series contains the specified date. |
boolean |
includesAll(Dates dates)
Indicates if this series of dates contains all the date ranges given by dates. |
boolean |
includesRange(java.util.Date from,
java.util.Date 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 |
removeAll(Dates series)
Removes all dates ranges given by dates from this series of dates. |
Dates |
removeRange(java.util.Date from,
java.util.Date to)
Removes the specified range from this series of dates. |
Dates |
retainAll(Dates series)
Removes all but the date ranges given by dates from this
series of dates. |
int |
size()
Returns the number of date ranges included in this series. |
java.util.Date[] |
toDateArray()
Converts this series of dates to an 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. |
java.util.Date[] |
toDateArray(java.util.Date[] a)
Converts this series of dates to an 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. |
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 addAll(Dates series)
dates to this series of dates.
This implementation throws an UnsupportedOperationException.
addAll in interface Datesseries - series of dates to be added
java.lang.NullPointerException - if dates is null
public Dates addRange(java.util.Date from,
java.util.Date to)
This implementation throws an UnsupportedOperationException.
addRange in interface Datesfrom - start of the date range, inclusiveto - end of the date range, exclusive
public void clear()
This implementation throws an UnsupportedOperationException.
clear in interface Datespublic void complement()
Dates object so that it contains only the ranges not currently
in this Dates object.
This implementation throws an UnsupportedOperationException.
complement in interface Datespublic DateIterator dateIterator()
dateIterator(DatedObject.MIN_DATE).
This implementation invokes dateIterator(DatedObject.MIN_DATE).
dateIterator in interface Datespublic abstract DateIterator dateIterator(java.util.Date date)
Datesfrom,
inclusive, and ending with to, exclusive.
dateIterator in interface Datespublic 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 Datesequals in class java.lang.Objectobj - object to be compared to this series of dates
true if this series equals objpublic boolean excludesAll(Dates dates)
This implementation iterates through the ranges of dates and
checks excludesRange for each range.
excludesAll in interface Datesdates - 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(java.util.Date from,
java.util.Date to)
This implementation checks if the date range (if one exists) of an iterator positioned at
from does not contain from or to.
excludesRange in interface Datesfrom - 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 rangepublic 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 DateshashCode in class java.lang.Objectpublic boolean includes(java.util.Date date)
This implementation gets a date iterator at date and checks if nextFrom
is less than or equal to date.
includes in interface Datesdate - date to test for inclusion
true if this series of dates contains the specified date
java.lang.NullPointerException - if date is nullpublic boolean includesAll(Dates dates)
dates.
This implementation iterates through the date ranges of dates, invoking
includesRange for each range.
includesAll in interface Datesdates - 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(java.util.Date from,
java.util.Date to)
This implementation checks if the first range of the iterator produced
by dateIterator(from) contains from and to.
includesRange in interface Datesfrom - 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
rangepublic boolean isEmpty()
This implementation executes
return !dateIterator().hasNext();
isEmpty in interface Datestrue if no date ranges exist in this seriespublic Dates removeAll(Dates series)
dates from this series of dates.
This implementation throws an UnsupportedOperationException.
removeAll in interface Datesseries - date ranges to be removed
public Dates removeRange(java.util.Date from,
java.util.Date to)
This implementation throws an UnsupportedOperationException.
removeRange in interface Datesfrom - start of date range to remove (inclusive)to - end of date range to remove (exclusive)
public Dates retainAll(Dates series)
dates from this
series of dates.
This implementation throws an UnsupportedOperationException.
retainAll in interface Datesseries - date ranges to retain
public int size()
This implementation counts the number of ranges returned by an iterator positioned at the beginning.
size in interface Datespublic java.util.Date[] toDateArray()
Dates
toDateArray in interface Datespublic java.util.Date[] toDateArray(java.util.Date[] a)
Dates
toDateArray in interface Datespublic java.lang.String toString()
This implementation uses a StringBuffer to form the returned string.
It first appends "{". For each range returned by an iterator
positioned at the beginning, it appends "[from,to)" where from and
to denote the start and end of the range, respectively. It separates
each range with "," and ends the string with "}".
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||