PIP.Collections.Persistent
Class SArrayList<T>

java.lang.Object
  extended by PIP.Collections.Persistent.AbstractCollection<E>
      extended by PIP.Collections.Persistent.AbstractList<T>
          extended by PIP.Collections.Persistent.SArrayList<T>
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<T>, java.util.Collection<T>, java.util.List<T>

public class SArrayList<T>
extends AbstractList<T>
implements java.io.Serializable

JDO requires classes to be enhanced in order to serialise those objects. However, JDO explicitly recognises the collection classes so that they can be used as member variables without being enhanced and also so that they map cleanly to referential structures. However, this mechanism does not allow collections to be persisted in other circumstances such when they are used as values in a map or collections of collections. In order to persist use collections a first class persistence capable object I have created a new set of classes prefixed by S that mirror those contained with the Java.utils package. This has pattern has also been provided directly in other JDO implementations. Therefore, this class if an exact replication of the standard Java jdk ArrayList class

See Also:
Serialized Form

Constructor Summary
SArrayList()
           
SArrayList(int n)
           
 
Method Summary
 boolean add(T t)
          Appends the specified element to the end of this List (optional operation).
 T get(int index)
          Returns the element at the specified position in this list.
 T remove(int index)
          Removes the element at the specified position in this list (optional operation).
 T set(int index, T element)
          Replaces the element at the specified position in this list with the specified element (optional operation).
 int size()
          Returns the number of elements in this collection.
 
Methods inherited from class PIP.Collections.Persistent.AbstractList
add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, subList
 
Methods inherited from class PIP.Collections.Persistent.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

SArrayList

public SArrayList()

SArrayList

public SArrayList(int n)
Method Detail

add

public boolean add(T t)
Description copied from class: AbstractList
Appends the specified element to the end of this List (optional operation).

This implementation calls add(size(), o).

Note that this implementation throws an UnsupportedOperationException unless add(int, Object) is overridden.

Specified by:
add in interface java.util.Collection<T>
Specified by:
add in interface java.util.List<T>
Overrides:
add in class AbstractList<T>
Parameters:
t - element to be appended to this list.
Returns:
true (as per the general contract of Collection.add).

remove

public T remove(int index)
Description copied from class: AbstractList
Removes the element at the specified position in this list (optional operation). Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.

This implementation always throws an UnsupportedOperationException.

Specified by:
remove in interface java.util.List<T>
Overrides:
remove in class AbstractList<T>
Parameters:
index - the index of the element to remove.
Returns:
the element previously at the specified position.

set

public T set(int index,
             T element)
Description copied from class: AbstractList
Replaces the element at the specified position in this list with the specified element (optional operation).

This implementation always throws an UnsupportedOperationException.

Specified by:
set in interface java.util.List<T>
Overrides:
set in class AbstractList<T>
Parameters:
index - index of element to replace.
element - element to be stored at the specified position.
Returns:
the element previously at the specified position.

size

public int size()
Description copied from class: AbstractCollection
Returns the number of elements in this collection. If the collection contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Specified by:
size in interface java.util.Collection<T>
Specified by:
size in interface java.util.List<T>
Specified by:
size in class AbstractCollection<T>
Returns:
the number of elements in this collection.

get

public T get(int index)
Description copied from class: AbstractList
Returns the element at the specified position in this list.

Specified by:
get in interface java.util.List<T>
Specified by:
get in class AbstractList<T>
Parameters:
index - index of element to return.
Returns:
the element at the specified position in this list.