|
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.AbstractDatedObject<D>
sos.dated.util.AbstractDatedCollection<E,D>
sos.dated.util.AbstractDatedList<E,D>
E - the type of elements maintained by this dated listD - the type of dates used by this dated listpublic abstract class AbstractDatedList<E,D>
A partial implementation of a dated list. The purpose of this class is
to make it easier to create a concrete DatedList and to
share implementation
common across concrete classes. It provides an implementation of
iterator.
To create an unmodifiable dated list, the
programmer can subclass this class and implement the dateIterator,
get, and size methods.
To create a modifiable version, the programmer must also override the
set, add, and remove methods.
AbstractDatedCollection,
DatedList,
ArrayListByDate,
ArrayListByElement| Constructor Summary | |
|---|---|
protected |
AbstractDatedList()
No-argument constructor available only to subclasses. |
| Method Summary | |
|---|---|
Dates<D> |
add(E value,
D from,
D to)
Adds the specified element to this dated collection for the specified date range (optional operation). |
void |
add(int index,
E value,
D from,
D to)
Inserts an element into this dated list for a specified date range (optional operation). |
Dates<D> |
addAll(int index,
DatedCollection<? extends E,D> datedCollection)
Inserts an entire dated collection into this dated list at the specified index (optional operation). |
protected void |
checkForComodification(int expectedModCount,
D at)
Throws a ConcurrentModificationException if the expected modification count does not equal the actual modification count for the specified date. |
void |
clear(D from,
D to)
Removes all elements from this dated collection for the specified dates (optional operation). |
protected java.lang.Object |
clone()
Creates and returns a shallow copy of this object. |
boolean |
equals(D at,
DatedObject<D> obj,
D objAt)
Indicates if this dated object at at is equal to
obj at objAt. |
abstract E |
get(int index,
D at)
Retrieves the element at the specified position on the specified date. |
int |
hashCode(D at)
Returns a hash code value of this dated object at the specified date. |
int |
indexOf(java.lang.Object value,
D at)
Returns the position of the first occurrence of the specified element in this list at the specified date, or -1 if this dated list does not contain the element at that date. |
Iterator<E,D> |
iterator(D at)
Returns an iterator over the elements of this dated collection at the specified date. |
int |
lastIndexOf(java.lang.Object value,
D at)
Returns the position of the last occurrence of the specified element in this list at the specified date, or -1 if this dated list does not contain the element at that date. |
ListIterator<E,D> |
listIterator(D at)
Returns a list iterator over the elements of this dated list at the specified date. |
ListIterator<E,D> |
listIterator(int index,
D at)
Returns a list iterator over the elements of this dated list at the specified date, starting at the specified index. |
protected int |
modCount(D at)
Returns the modification count at the specified date. |
DatedValue<E,D> |
remove(int index,
D from,
D to)
Removes from this dated list the element at the specified position for the specified date range (optional operation). |
protected void |
removeRange(int fromIndex,
int toIndex,
D from,
D to)
Removes all elements between fromIndex, inclusive, and
toIndex, exclusive, for the specified date range. |
DatedValue<E,D> |
set(int index,
E value,
D from,
D to)
Replaces the element at the specified position with the specified element for the specified date range. |
abstract int |
size(D at)
Returns the number of elements in this dated collection at the specified date. |
DatedList<E,D> |
subList(int fromIndex,
int toIndex)
Returns a view of this dated list restricted to the range fromIndex,
inclusive, to toIndex, exclusive. |
protected void |
upModCount(D from,
D to)
Increments the modification count for the specified date range. |
| Methods inherited from class sos.dated.util.AbstractDatedCollection |
|---|
addAll, contains, containsAll, containsThroughout, dateIterator, excludesThroughout, hasSizeThroughout, isEmpty, isEmptyThroughout, remove, removeAll, retainAll, toArray, toArray, toString |
| Methods inherited from class sos.dated.util.AbstractDatedObject |
|---|
dateIterator, equals, hashCode, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface sos.dated.util.DatedCollection |
|---|
addAll, contains, containsAll, containsThroughout, excludesThroughout, hasSizeThroughout, isEmpty, isEmptyThroughout, remove, removeAll, retainAll, toArray, toArray |
| Methods inherited from interface sos.dated.util.DatedObject |
|---|
dateIterator, dateIterator, equals, hashCode, toString |
| Constructor Detail |
|---|
protected AbstractDatedList()
| Method Detail |
|---|
public Dates<D> add(E value,
D from,
D 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.
This implementation throws an UnsupportedOperationException.
This implementation invokes add(int,Object,D,D) for each static window within the specified range, passing it the size of this list at the start of the window as given by size.
add in interface DatedCollection<E,D>add in class AbstractDatedCollection<E,D>value - element to addfrom - starting date (inclusive) at which the element should be addedto - ending date (exclusive) at which the element should be added
java.lang.ClassCastException - if the underlying type of value prevents it from
being added to this dated collection
java.lang.IllegalArgumentException - if from does not precede to
or if some property of value prevents it from being added to this dated collection
java.lang.NullPointerException - if from or to is null
or if value is null and this dated collection cannot hold null elements
java.lang.UnsupportedOperationException - always
public void add(int index,
E value,
D from,
D to)
add in interface DatedList<E,D>index - position to insert the elementvalue - element to insertfrom - starting date (inclusive) at which the element should be insertedto - ending date (exclusive) at which the element should be inserted
java.lang.UnsupportedOperationException - always
public Dates<D> addAll(int index,
DatedCollection<? extends E,D> datedCollection)
addAll in interface DatedList<E,D>index - index at which to insert the dated collectiondatedCollection - collection to insert into this dated list
java.lang.ClassCastException - if the type of an element of datedCollection prevents it from
being added to this dated list
java.lang.IllegalArgumentException - if some property of an element of datedCollection
prevents it from being added to this dated list
java.lang.IndexOutOfBoundsException - if index < 0 || index > size( d )
where d is a date when elements exist in datedCollection
java.lang.NullPointerException - if datedCollection is null
or if an element of datedCollection is null and this dated list
cannot hold null elements
java.lang.UnsupportedOperationException - if this implementation does not support add
protected void checkForComodification(int expectedModCount,
D at)
expectedModCount - the caller's expected modification countat - the date in question
java.util.ConcurrentModificationException - if the expected modification
count does not equal the actual modification count for the specified date
public void clear(D from,
D to)
This implementation repeatedly invokes remove
on the iterator, while iterating
through the elements at each date within the specified range.
This implementation invokes removeRange for each static window within the
specified date range, passing in the size of the list at the start of
the window, as gotten from a call to size.
clear in interface DatedCollection<E,D>clear in class AbstractDatedCollection<E,D>from - starting date (inclusive) at which this dated collection should be clearedto - ending date (exclusive) at which this dated collection should be cleared
java.lang.IllegalArgumentException - if from does not precede to
java.lang.NullPointerException - if if from or to is null
java.lang.UnsupportedOperationException - if the list iterator throws this exception on removal
protected java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone method.
clone in class java.lang.Objectjava.lang.CloneNotSupportedException - if this object's class does not
support the Cloneable interface.
public boolean equals(D at,
DatedObject<D> obj,
D objAt)
AbstractDatedObjectat is equal to
obj at objAt.
This implementation uses object identity to determine equality. In other
words, it returns true if
this == obj && date.equals( objDate )Subclasses should override this method to impose a weaker equality condition.
equals in interface DatedList<E,D>equals in interface DatedObject<D>equals in class AbstractDatedObject<D>at - date at which this object should be testedobj - the other dated object to be compared toobjAt - the date of the other dated object
true if this dated object at at equals
another dated object at objAt
java.lang.NullPointerException - if any argument is null
public abstract E get(int index,
D at)
DatedList
get in interface DatedList<E,D>index - position to retrieve an elementat - date at which this dated list is to be queried
public int hashCode(D at)
o1 and o2 and two dates
d1 and d2, if
o1.equals( d1, o2, d2 ) returns true,
then o1.hashCode( d1 )
must equal o2.hashCode( d2 ).
This implementation returns the identity hash code value of this dated
object.This implementation iterates through the elements of this dated list at the specified date, computing the hash code value as required.
hashCode in interface DatedList<E,D>hashCode in interface DatedObject<D>hashCode in class AbstractDatedObject<D>at - date to which the hash code value should correspond
java.lang.NullPointerException - if at is null
public int indexOf(java.lang.Object value,
D at)
indexOf in interface DatedList<E,D>value - element whose presence is to be testedat - date to search for the element
java.lang.NullPointerException - if at is nullpublic Iterator<E,D> iterator(D at)
UnsupportedOperationException in its remove
method because a date range is required to remove an element from
this dated collection.
This implementation returns listIterator( at ).
iterator in interface DatedCollection<E,D>iterator in class AbstractDatedCollection<E,D>at - date at which to iterate through the elements
java.lang.NullPointerException - if at is null
public int lastIndexOf(java.lang.Object value,
D at)
lastIndexOf in interface DatedList<E,D>value - element whose presence is to be testedat - date to search for the element
java.lang.NullPointerException - if at is nullpublic ListIterator<E,D> listIterator(D at)
listIterator( 0, at ).
listIterator in interface DatedList<E,D>at - date at which to iterate over the elements of this dated list
java.lang.NullPointerException - if at is null
public ListIterator<E,D> listIterator(int index,
D at)
listIterator in interface DatedList<E,D>index - position at which to start the iterationat - date at which to iterate over the elements of this dated list
java.lang.IndexOutOfBoundsException - if index < 0 || index >= size( at )
java.lang.NullPointerException - if at is nullprotected int modCount(D at)
at. If assertions are not enabled, the returned
value is always zero.
at - date to request the modification count
public DatedValue<E,D> remove(int index,
D from,
D to)
UnsupportedOperationException.
remove in interface DatedList<E,D>index - position at which to start the iterationfrom - starting date (inclusive) at which the element should be removedto - ending date (exclusive) at which the element should be removed
java.lang.UnsupportedOperationException - always
protected void removeRange(int fromIndex,
int toIndex,
D from,
D to)
fromIndex, inclusive, and
toIndex, exclusive, for the specified date range. The dated
list is constant in the date range.
This implementaion gets a list iterator at from,
starting at fromIndex. It then iterates through the
elements up to toIndex,
invoking remove(from,to). Subclasses may
override this method to make it more efficient for the particular
implementation.
fromIndex - start index of elements to removetoIndex - end index of elements to removefrom - start date (inclusive) for which the elements should be removedto - end date (exclusive) for which the elements should be removed
public DatedValue<E,D> set(int index,
E value,
D from,
D to)
set in interface DatedList<E,D>index - position of the element to replacevalue - element to place in this listfrom - starting date (inclusive) at which the position should be setto - ending date (exclusive) at which the position should be set
java.lang.UnsupportedOperationException - alwayspublic abstract int size(D at)
AbstractDatedCollectionThis implementation iterates through the elements at the specified date, counting the elements as it goes.
A subclass that can determine the size of its collection more efficiently should override this method.
size in interface DatedCollection<E,D>size in class AbstractDatedCollection<E,D>at - date at which this dated collection is to be queried
DatedCollection.hasSizeThroughout(int, D, D)
public DatedList<E,D> subList(int fromIndex,
int toIndex)
fromIndex,
inclusive, to toIndex, exclusive. Changes made to the returned
sub-list are reflected in the master list, and vice versa.
For the date ranges where the interval [fromIndex,toIndex)
is not present in this dated list, some sub-list operations will throw an
IllegalArgumentException. For example, consider the
following code, where d0, d1, etc. are consecutive dates:
DatedList list = new ArrayListByDate();
list.add( "A", d0, d2 );
list.add( "B", d1, d2 );
DatedList subList = list.subList( 1, 2 );
subList.add( "C", d1, d2 ); // successful
subList.add( "C", d0, d2 ); // fails because list does not have
// 2 elements at d0
int size = subList.size( d0 ); // returns 0
size = subList.size( d1 ); // returns 1
subList.get( 0, d0 ); // fails
Therefore, it is only safe to use the sub-list during date ranges
where the interval [fromIndex,toIndex) exists in this list.
This implementation returns a fully operational sublist. The sublist implements
RandomAccess if this dated list implements RandomAccess.
subList in interface DatedList<E,D>fromIndex - starting position of the returned view (inclusive)toIndex - ending position of the returned view (exclusive)
protected void upModCount(D from,
D to)
from - starting date (inclusive) for which to increment the countto - ending date (exclusive) for which to increment the count
|
Side of Software Dated Collections Library 2.0 |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||