Side of Software
Dated Collections Library 2.0

sos.dated.util
Class AbstractSequentialDatedList<E,D>

java.lang.Object
  extended by sos.dated.util.AbstractDatedObject<D>
      extended by sos.dated.util.AbstractDatedCollection<E,D>
          extended by sos.dated.util.AbstractDatedList<E,D>
              extended by sos.dated.util.AbstractSequentialDatedList<E,D>
Type Parameters:
E - the type of elements maintained by this dated list
D - the type of dates used by this dated list
All Implemented Interfaces:
DatedCollection<E,D>, DatedList<E,D>, DatedObject<D>

public abstract class AbstractSequentialDatedList<E,D>
extends AbstractDatedList<E,D>

A partial implementation of a dated list that does not provide random access to its elements at a given date. The purpose of this class is to make it easier to implement a sequential dated list. All of the methods implemented in this class operate on the list iterator, which is defined by a subclass.

To create an unmodifiable list, the programmer can subclass this class and implement listIterator(int). The list iterator returned by this method need only define the query methods: hasNext, hasPrevious, next, nextIndex, previous, and previousIndex. The remaining methods should throw UnsupportedOperationExceptions.

To create a modifiable list, the programmer must implement the above methods that throw UnsupportedOperationExceptions.

Upon subclassing this class, the programmer may wish to override those methods that can be implemented more efficiently with knowledge of the underlying data structure.

This class is not Serializable or Cloneable. Subclasses are free to decide if they wish to implement these interfaces.

Since:
1.0
See Also:
AbstractDatedList, DatedList

Constructor Summary
protected AbstractSequentialDatedList()
          No-argument constructor available only to subclasses.
 
Method Summary
 void add(int index, E value, D from, D to)
          Inserts an element into this dated list for a specified date range (optional operation).
 E get(int index, D date)
          Retrieves the element at the specified position on the specified date.
abstract  ListIterator<E,D> listIterator(int index, D date)
          Returns a list iterator over the elements of this dated list at the specified date, starting at the specified index.
 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).
 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.
 
Methods inherited from class sos.dated.util.AbstractDatedList
add, addAll, checkForComodification, clear, clone, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, modCount, removeRange, size, subList, upModCount
 
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

AbstractSequentialDatedList

protected AbstractSequentialDatedList()
No-argument constructor available only to subclasses.

Method Detail

add

public void add(int index,
                E value,
                D from,
                D to)
Inserts an element into this dated list for a specified date range (optional operation). This implementation throws an UnsupportedOperationException. This implementation invokes the list iterator's add method for each list iterator at a change date between from and to.

Specified by:
add in interface DatedList<E,D>
Overrides:
add in class AbstractDatedList<E,D>
Parameters:
index - position to insert the element
value - element to insert
from - starting date (inclusive) at which the element should be inserted
to - ending date (exclusive) at which the element should be inserted
Throws:
java.lang.ClassCastException - if the underlying type of value prevents it from being added to this dated list
java.lang.IllegalArgumentException - if from does not precede to or if some property of value prevents it from being added to this dated list
java.lang.IndexOutOfBoundsException - if index < 0 || index > size( d ) where d is a date between from and to
java.lang.NullPointerException - if from or to is null or if value is null and this dated list cannot hold null elements
java.lang.UnsupportedOperationException - if the list iterator does not support add

get

public E get(int index,
             D date)
Retrieves the element at the specified position on the specified date. This implementation uses the list iterator at date and positioned at index to retrieve the element.

Specified by:
get in interface DatedList<E,D>
Specified by:
get in class AbstractDatedList<E,D>
Parameters:
index - position to retrieve an element
date - date at which this dated list is to be queried
Returns:
the element at the specified position on the specified date
Throws:
java.lang.IndexOutOfBoundsException - if index < 0 || index >= size( at )
java.lang.NullPointerException - if at is null

listIterator

public abstract ListIterator<E,D> listIterator(int index,
                                               D date)
Description copied from class: AbstractDatedList
Returns a list iterator over the elements of this dated list at the specified date, starting at the specified index. This implementation creates a fully functional list iterator, positioned at the element given by index and date. The list iterator's update operations call this dated list's add(int,Object,Date,Date), remove(int,Date,Date), and set(int,Object,Date,Date).

Specified by:
listIterator in interface DatedList<E,D>
Overrides:
listIterator in class AbstractDatedList<E,D>
Parameters:
index - position at which to start the iteration
date - date at which to iterate over the elements of this dated list
Returns:
a list iterator at the specified date with the specified index as its starting position

remove

public 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). This implementation throws an UnsupportedOperationException. This implementation invokes remove on the list iterator at each change date between from and to.

Specified by:
remove in interface DatedList<E,D>
Overrides:
remove in class AbstractDatedList<E,D>
Parameters:
index - position at which to start the iteration
from - starting date (inclusive) at which the element should be removed
to - ending date (exclusive) at which the element should be removed
Returns:
the elements previously at the specified index from this list for the specified date range.
Throws:
java.lang.IllegalArgumentException - if from does not precede to
java.lang.IndexOutOfBoundsException - if index < 0 || index >= size( d ) where d is a date within the specified range
java.lang.NullPointerException - if from or to is null
java.lang.UnsupportedOperationException - if the list iterator does not support remove

set

public 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. This implementation throws an UnsupportedOperationException. This implementation invokes set on the list iterator at each change date between from and to.

Specified by:
set in interface DatedList<E,D>
Overrides:
set in class AbstractDatedList<E,D>
Parameters:
index - position of the element to replace
value - element to place in this list
from - starting date (inclusive) at which the position should be set
to - ending date (exclusive) at which the position should be set
Throws:
java.lang.ClassCastException - if the underlying type of value prevents it from being added to this dated list
java.lang.IllegalArgumentException - if from does not precede to or if some property of value prevents it from being added to this dated list
java.lang.IndexOutOfBoundsException - if this dated list does not contain index + 1 elements throughout the specified date range
java.lang.NullPointerException - if from or to is null or if value is null and this dated list cannot hold null elements
java.lang.UnsupportedOperationException - if the list iterator does not support set

Side of Software
Dated Collections Library 2.0

Copyright 2003-09 Side of Software (SOS). All rights reserved.