|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
A collection of elements over time. A dated collection
represents a group of elements during various date ranges. It provides an interface
similar to java.util.Collection with the requirement that either
a date or a date range be specified, depending on the type of method. A method
that changes the collection requires a date range, while a method that queries
the collection requires either a date or a date range. A non-dated
collection is equivalent to a dated collection in which all elements
appear from the beginning of time to the end of time.
The Dated Collections library does not provide any direct implementations of this class. Instead, it provides implementations of subinterfaces.
This interface does not extend java.util.Collection directly
because at least one date is needed. To make a dated collection appear
like a non-dated collection, use Adapters.asCollection(DatedCollection,Date).
Similarly, to treat a non-dated collection as dated, use
Adapters.asDatedCollection(Collection,Date,Date).
At the instant of MAX_DATE, the collection is always empty.
For example, to add an element from the current time to the end of time, one may use the following code:
DatedCollection datedCollection = ... Date currentDate = new Date(); datedCollection.add( value, currentDate, DatedObject.MAX_DATE );To iterate through the elements at the current time, one may then do the following:
Iterator iter = datedCollection.iterator( currentDate );
while( iter.hasNext() ) {
Object element = iter.next();
...
}
This interface contains additional methods that do not correspond to a method
in java.util.Collection:
- containsThroughout(Object,Date,Date)
- excludesThroughout(Object,Date,Date)
- get(Object)
- hasSizeThroughout(int,Date,Date)
- isEmptyThroughout(Date,Date)
DatedList,
DatedSet,
DatedMap,
DatedSortedSet,
DatedSortedMap,
DatedCollections,
Adapters.asCollection(DatedCollection,Date),
Adapters.asDatedCollection(Collection,Date,Date)| Field Summary |
| Fields inherited from interface sos.dated.util.DatedObject |
MAX_DATE, MIN_DATE |
| Method Summary | |
Dates |
add(java.lang.Object value,
java.util.Date from,
java.util.Date to)
Adds the specified element to this collection for the specified date range (optional operation). |
Dates |
addAll(DatedCollection datedCollection)
Adds a dated collection of elements to this dated collection (optional operation). |
void |
clear(java.util.Date from,
java.util.Date to)
Removes all elements from this dated collection for the specified dates (optional operation). |
boolean |
contains(java.lang.Object value,
java.util.Date date)
Returns true if this collection contains the specified element
on the specified date. |
boolean |
containsAll(DatedCollection datedCollection)
Returns true if this dated collection contains all elements of
the specified collection. |
boolean |
containsThroughout(java.lang.Object value,
java.util.Date from,
java.util.Date to)
Returns true if this collection contains the specified element
throughout the specified date range. |
boolean |
excludesThroughout(java.lang.Object value,
java.util.Date from,
java.util.Date to)
Returns true if this collection does not contain the specified
element at any date within the specified date range. |
boolean |
hasSizeThroughout(int size,
java.util.Date from,
java.util.Date to)
Returns true if the number of elements in this collection is
greater than or equal to the specified size throughout the specified
date range. |
boolean |
isEmpty(java.util.Date date)
Returns true if this collection contains no elements on the
specified date. |
boolean |
isEmptyThroughout(java.util.Date from,
java.util.Date to)
Returns true if this collection contains no elements throughout the
specified date range. |
Iterator |
iterator(java.util.Date date)
Returns an iterator over the elements of this dated collection at the specified date. |
Dates |
remove(java.lang.Object value,
java.util.Date from,
java.util.Date to)
Removes an instance of the specified element from this collection for the specified date range (optional operation). |
Dates |
removeAll(DatedCollection datedCollection)
Removes the elements in this collection that are contained in the specified collection (optional operation). |
Dates |
retainAll(DatedCollection datedCollection)
Retains in this dated collection only the the elements in the specified collection (optional operation). |
int |
size(java.util.Date date)
Returns the number of elements in this collection at the specified date. |
java.lang.Object[] |
toArray(java.util.Date date)
Moves the elements of this dated collection at the specified date to a newly created array. |
java.lang.Object[] |
toArray(java.lang.Object[] a,
java.util.Date date)
Moves the elements of this dated collection at the specified date either to the specified array or to a new array with the same type as the specified array. |
| Methods inherited from interface sos.dated.util.DatedObject |
dateIterator, dateIterator, equals, equals, hashCode, hashCode, toString |
| Method Detail |
public Dates add(java.lang.Object value,
java.util.Date from,
java.util.Date to)
The returned value indicates when this dated collection 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 dated collection.
value - element to addfrom - starting date at which the element should be addedto - ending date at which the element should be added
java.lang.NullPointerException - if from or to is null
java.lang.UnsupportedOperationException - if this collection does not support addpublic Dates addAll(DatedCollection datedCollection)
this
as the parameter. The returned value indicates when this dated collection 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 dated collection.
datedCollection - elements to add
java.lang.NullPointerException - if datedCollection is null
public void clear(java.util.Date from,
java.util.Date to)
from - date to start clearing the collection, inclusiveto - date to finish clearing the collection, exclusive
java.lang.NullPointerException - if from or to is null
java.lang.IllegalArgumentException - if from does not precede to
public boolean contains(java.lang.Object value,
java.util.Date date)
true if this collection contains the specified element
on the specified date.
value - element whose presence is to be testeddate - date at which this collection is to be queried
true if this collection contains the specified element
on the specified date
java.lang.NullPointerException - if date is nullpublic boolean containsAll(DatedCollection datedCollection)
true if this dated collection contains all elements of
the specified collection.
datedCollection - elements and date to test for containment
true if this dated collection contains all elements of
the specified collection
java.lang.NullPointerException - if datedCollection is null
public boolean containsThroughout(java.lang.Object value,
java.util.Date from,
java.util.Date to)
true if this collection contains the specified element
throughout the specified date range.
value - element whose presence is to be testedfrom - starting date (inclusive) at which containment should be testedto - ending date (exclusive) at which containment should be tested
true if this collection contains the specified element
throughout the specified date range
java.lang.NullPointerException - if from or to is null
java.lang.IllegalArgumentException - if from does not precede to
public boolean excludesThroughout(java.lang.Object value,
java.util.Date from,
java.util.Date to)
true if this collection does not contain the specified
element at any date within the specified date range.
value - element whose presence is to be testedfrom - starting date (inclusive) at which exclusion should be testedto - ending date (exclusive) at which exclusion should be tested
true if this collection does not contain value
at any date between from and to
java.lang.NullPointerException - if from or to is null
java.lang.IllegalArgumentException - if from does not precede to
public boolean hasSizeThroughout(int size,
java.util.Date from,
java.util.Date to)
true if the number of elements in this collection is
greater than or equal to the specified size throughout the specified
date range.
size - number of elements in questionfrom - starting date (inclusive) at which the size is to be comparedto - ending date (exclusive) at which the size is to be compared
true if this collection has at least the specified size
throughout the specified date range.
java.lang.NullPointerException - if from or to is null
java.lang.IllegalArgumentException - if size < 0 or if from
does not precede topublic boolean isEmpty(java.util.Date date)
true if this collection contains no elements on the
specified date.
date - date at which this collection is to be queried
true if this collection contains no elements on the
specified date
java.lang.NullPointerException - if date is null
public boolean isEmptyThroughout(java.util.Date from,
java.util.Date to)
true if this collection contains no elements throughout the
specified date range.
from - starting date at which this collection is to be queriedto - ending date at which this collection is to be queried
true if this collection contains no elements throughout the
specified date range.
java.lang.NullPointerException - if from or to is null
java.lang.IllegalArgumentException - if from does not precede topublic Iterator iterator(java.util.Date date)
UnsupportedOperationException in its remove
method because a date range is required to remove an element from
this dated collection.
date - date at which to iterate through the elements
java.lang.NullPointerException - if date is null
public Dates remove(java.lang.Object value,
java.util.Date from,
java.util.Date to)
The returned value indicates when this dated collection 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 dated collection.
value - element to removefrom - starting date at which the element should be removedto - ending date at which the element should be removed
java.lang.IllegalArgumentException - if from does not precede to
java.lang.NullPointerException - if from or to is null
java.lang.UnsupportedOperationException - if this collection does not support removepublic Dates removeAll(DatedCollection datedCollection)
The returned value indicates when this dated collection 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 dated collection.
datedCollection - elements and date ranges to remove
java.lang.NullPointerException - if datedCollection is nullpublic Dates retainAll(DatedCollection datedCollection)
The returned value indicates when this dated collection 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 dated collection.
datedCollection - elements and date ranges to remove
java.lang.NullPointerException - if datedCollection is nullpublic int size(java.util.Date date)
date - date at which this collection is to be queried
java.lang.NullPointerException - if date is nullpublic java.lang.Object[] toArray(java.util.Date date)
date - date of elements in this collection
java.lang.NullPointerException - if date is null
public java.lang.Object[] toArray(java.lang.Object[] a,
java.util.Date date)
a - array to hold the elements, if possibledate - date of elements in this collection
java.lang.NullPointerException - if date is null
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||