org.geotools.util
Class CheckedArrayList

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended byjava.util.ArrayList
              extended byorg.geotools.util.CheckedArrayList
All Implemented Interfaces:
java.lang.Cloneable, org.opengis.util.Cloneable, java.util.Collection, java.util.List, java.util.RandomAccess, java.io.Serializable

public class CheckedArrayList
extends java.util.ArrayList
implements org.opengis.util.Cloneable

Acts as a typed List while we wait for Java 5.0.

Since:
2.1
Version:
$Id: CheckedArrayList.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Jody Garnett (Refractions Research), Martin Desruisseaux
See Also:
Serialized Form
To Do:
Provides synchronization facility on arbitrary lock, for use with the metadata package. The lock would be the metadata that owns this collection. Be carefull to update the lock after a clone (this work may be done in ).

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
CheckedArrayList(java.lang.Class type)
          Constructs a list of the specified type.
 
Method Summary
 void add(int index, java.lang.Object element)
          Inserts the specified element at the specified position in this list.
 boolean add(java.lang.Object element)
          Appends the specified element to the end of this list.
 boolean addAll(java.util.Collection collection)
          Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified Collection's Iterator.
 boolean addAll(int index, java.util.Collection collection)
          Inserts all of the elements in the specified collection into this list, starting at the specified position.
protected  void ensureValidType(java.lang.Object element)
          Checks the type of the specified object.
 java.lang.Object set(int index, java.lang.Object element)
          Replaces the element at the specified position in this list with the specified element.
 
Methods inherited from class java.util.ArrayList
clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, removeRange, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, remove, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.opengis.util.Cloneable
clone
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, remove, removeAll, retainAll, subList
 

Constructor Detail

CheckedArrayList

public CheckedArrayList(java.lang.Class type)
Constructs a list of the specified type.

Parameters:
type - The element type (should not be null).
Method Detail

ensureValidType

protected void ensureValidType(java.lang.Object element)
                        throws java.lang.IllegalArgumentException
Checks the type of the specified object. The default implementation ensure that the object is assignable to the type specified at construction time.

Parameters:
element - the object to check, or .
Throws:
java.lang.IllegalArgumentException - if the specified element is not of the expected type.

set

public java.lang.Object set(int index,
                            java.lang.Object element)
Replaces the element at the specified position in this list with the specified element.

Specified by:
set in interface java.util.List
Parameters:
index - index of element to replace.
element - element to be stored at the specified position.
Returns:
the element previously at the specified position.
Throws:
java.lang.IndexOutOfBoundsException - if index out of range.
java.lang.IllegalArgumentException - if the specified element is not of the expected type.

add

public boolean add(java.lang.Object element)
Appends the specified element to the end of this list.

Specified by:
add in interface java.util.List
Parameters:
element - element to be appended to this list.
Returns:
always .
Throws:
java.lang.IllegalArgumentException - if the specified element is not of the expected type.

add

public void add(int index,
                java.lang.Object element)
Inserts the specified element at the specified position in this list.

Specified by:
add in interface java.util.List
Parameters:
index - index at which the specified element is to be inserted.
element - element to be inserted.
Throws:
java.lang.IndexOutOfBoundsException - if index out of range.
java.lang.IllegalArgumentException - if the specified element is not of the expected type.

addAll

public boolean addAll(java.util.Collection collection)
Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified Collection's Iterator.

Specified by:
addAll in interface java.util.List
Parameters:
collection - the elements to be inserted into this list.
Returns:
if this list changed as a result of the call.
Throws:
java.lang.IllegalArgumentException - if at least one element is not of the expected type.

addAll

public boolean addAll(int index,
                      java.util.Collection collection)
Inserts all of the elements in the specified collection into this list, starting at the specified position.

Specified by:
addAll in interface java.util.List
Parameters:
index - index at which to insert first element fromm the specified collection.
collection - elements to be inserted into this list.
Returns:
if this list changed as a result of the call.
Throws:
java.lang.IllegalArgumentException - if at least one element is not of the expected type.


Copyright © GeoTools. All Rights Reserved.