sos.dated.util
Class ArrayListByElement

java.lang.Object
  |
  +--sos.dated.util.AbstractDatedObject
        |
        +--sos.dated.util.AbstractDatedCollection
              |
              +--sos.dated.util.AbstractDatedList
                    |
                    +--sos.dated.util.ArrayListByElement
All Implemented Interfaces:
java.lang.Cloneable, DatedCollection, DatedList, DatedObject, java.util.RandomAccess, java.io.Serializable

public class ArrayListByElement
extends AbstractDatedList
implements DatedList, java.io.Serializable, java.lang.Cloneable, java.util.RandomAccess

An implementation of DatedList that uses a single java.util.ArrayList to efficiently add and set values.

This implementation is serializable and cloneable; however, it is not synchronized. To use it safely in a multi-threaded situation, wrap an instance of the dated list with a call to DatedCollections.synchronizedDatedList.

Since:
1.0
See Also:
ArrayListByDate, DatedList, DatedCollections.synchronizedDatedList(DatedList)

Field Summary
 
Fields inherited from interface sos.dated.util.DatedObject
MAX_DATE, MIN_DATE
 
Constructor Summary
ArrayListByElement()
          Creates a new instance of ArrayListByElement
ArrayListByElement(DatedCollection datedCollection)
           
ArrayListByElement(int initialCapacity)
           
 
Method Summary
 void add(int index, java.lang.Object value, java.util.Date from, java.util.Date to)
          Inserts an element into the list for a specified date range (optional operation).
 java.lang.Object clone()
          Creates and returns a copy of this object.
 DateIterator dateIterator(java.util.Date date)
          Returns an iterator of the date ranges of when this dated type has changed.
 java.lang.Object get(int index, java.util.Date date)
          Retrieves the element at the specified position on the specified date.
 DatedValue remove(int index, java.util.Date from, java.util.Date to)
          Removes from this list the element at the specified position for the specified date range (optional operation).
 DatedValue set(int index, java.lang.Object value, java.util.Date from, java.util.Date to)
          Replaces the element at the specified position with the specified element for the specified date range.
 int size(java.util.Date date)
          Returns the number of elements in this collection at the specified date.
 
Methods inherited from class sos.dated.util.AbstractDatedList
add, addAll, checkForComodification, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, modCount, removeRange, subList, upModCount
 
Methods inherited from class sos.dated.util.AbstractDatedCollection
addAll, contains, containsAll, containsThroughout, 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.DatedList
addAll, equals, hashCode, indexOf, lastIndexOf, listIterator, listIterator, subList
 
Methods inherited from interface sos.dated.util.DatedCollection
add, addAll, clear, contains, containsAll, containsThroughout, excludesThroughout, hasSizeThroughout, isEmpty, isEmptyThroughout, iterator, remove, removeAll, retainAll, toArray, toArray
 
Methods inherited from interface sos.dated.util.DatedObject
dateIterator, equals, hashCode, toString
 

Constructor Detail

ArrayListByElement

public ArrayListByElement()
Creates a new instance of ArrayListByElement


ArrayListByElement

public ArrayListByElement(DatedCollection datedCollection)

ArrayListByElement

public ArrayListByElement(int initialCapacity)
Method Detail

add

public void add(int index,
                java.lang.Object value,
                java.util.Date from,
                java.util.Date to)
Description copied from interface: DatedList
Inserts an element into the list for a specified date range (optional operation).

Specified by:
add in interface DatedList
Overrides:
add in class AbstractDatedList
Parameters:
index - position to insert the element
value - element to insert
from - starting date at which the element should be inserted
to - ending date at which the element should be inserted

clone

public java.lang.Object clone()
Description copied from class: AbstractDatedList
Creates and returns a copy of this object. Subclasses that wish to be cloneable should override this method but first call their parent's clone method.

Overrides:
clone in class AbstractDatedList
Returns:
a copy of this dated list

dateIterator

public DateIterator dateIterator(java.util.Date date)
Returns an iterator of the date ranges of when this dated type has changed. Throughout a range returned by the iterator, the state of the dated object must be the same. Also, the states of the dated object must be different in two consecutive ranges returned by the iterator. There are no gaps in the ranges returned by the iterator. That is, if a previous date range exists, then a call to nextFrom returns the same date as previousTo.

Specified by:
dateIterator in interface DatedObject
Specified by:
dateIterator in class AbstractDatedCollection
Parameters:
date - date to position the iteration
Returns:
an iterator of the dates of when this dated type has changed.
Throws:
java.lang.IllegalArgumentException - if from does not precede to

get

public java.lang.Object get(int index,
                            java.util.Date date)
Retrieves the element at the specified position on the specified date.

Specified by:
get in interface DatedList
Specified by:
get in class AbstractDatedList
Parameters:
index - position to retrieve an element
date - date at which this list is to be queried
Returns:
the element at the specified position on the specified date
Throws:
java.lang.NullPointerException - if date is null
java.lang.IllegalArgumentException - if index < 0

set

public DatedValue set(int index,
                      java.lang.Object value,
                      java.util.Date from,
                      java.util.Date to)
Description copied from interface: DatedList
Replaces the element at the specified position with the specified element for the specified date range.

Specified by:
set in interface DatedList
Overrides:
set in class AbstractDatedList
Parameters:
index - position to place the element
value - element to place in this list
from - starting date at which the position should be set
to - ending date at which the position should be set

size

public int size(java.util.Date date)
Description copied from interface: DatedCollection
Returns the number of elements in this collection at the specified date.

Specified by:
size in interface DatedCollection
Specified by:
size in class AbstractDatedList
Parameters:
date - date at which this collection is to be queried
Returns:
the number of elements on the specified date

remove

public DatedValue remove(int index,
                         java.util.Date from,
                         java.util.Date to)
Description copied from interface: DatedList
Removes from this list the element at the specified position for the specified date range (optional operation).

Specified by:
remove in interface DatedList
Overrides:
remove in class AbstractDatedList
Parameters:
index - position at which to start the iteration
from - starting date at which the element should be removed
to - ending date at which the element should be removed
Returns:
the element at the specified index from this list for the specified date range.


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