|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<E>
org.geotools.util.CheckedArrayList<E>
E
- The type of elements in the list.public class CheckedArrayList<E>
A checked and synchronized List
. Type checks are performed at run-time in addition of
compile-time checks. The synchronization lock can be modified at runtime by overriding the
getLock()
method.
This class is similar to using the wrappers provided in Collections
, minus the cost
of indirection levels and with the addition of overrideable methods.
Collections.checkedList(java.util.List, java.lang.Class)
,
Collections.synchronizedList(java.util.List)
,
Serialized FormField Summary |
---|
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
CheckedArrayList(java.lang.Class<E> type)
Constructs a list of the specified type. |
|
CheckedArrayList(java.lang.Class<E> type,
int capacity)
Constructs a list of the specified type and initial capacity. |
Method Summary | ||
---|---|---|
boolean |
add(E element)
Appends the specified element to the end of this list. |
|
void |
add(int index,
E element)
Inserts the specified element at the specified position in this list. |
|
boolean |
addAll(java.util.Collection<? extends E> 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<? extends E> collection)
Inserts all of the elements in the specified collection into this list, starting at the specified position. |
|
protected void |
checkWritePermission()
Checks if changes in this collection are allowed. |
|
void |
clear()
Removes all of the elements from this list. |
|
CheckedArrayList<E> |
clone()
Returns a shallow copy of this list. |
|
boolean |
contains(java.lang.Object o)
Returns true if this list contains the specified element. |
|
void |
ensureCapacity(int minCapacity)
Increases the capacity, if necessary, to ensure that it can hold the given number of elements. |
|
protected void |
ensureValidType(E element)
Checks the type of the specified object. |
|
boolean |
equals(java.lang.Object o)
Compares the specified object with this list for equality. |
|
E |
get(int index)
Returns the element at the specified position in this list. |
|
java.lang.Class<E> |
getElementType()
Returns the element type given at construction time. |
|
protected java.lang.Object |
getLock()
Returns the synchronization lock. |
|
int |
hashCode()
Returns the hash code value for this list. |
|
int |
indexOf(java.lang.Object o)
Returns the index of the first occurrence of the specified element in this list, or -1 if none. |
|
boolean |
isEmpty()
Returns true if this list contains no elements. |
|
java.util.Iterator<E> |
iterator()
Returns an iterator over the elements in this list. |
|
int |
lastIndexOf(java.lang.Object o)
Returns the index of the last occurrence of the specified element in this list, or -1 if none. |
|
E |
remove(int index)
Removes the element at the specified position in this list. |
|
boolean |
remove(java.lang.Object o)
Removes the first occurrence of the specified element from this list. |
|
boolean |
removeAll(java.util.Collection<?> c)
Removes all of this list's elements that are also contained in the specified collection. |
|
boolean |
retainAll(java.util.Collection<?> c)
Retains only the elements in this list that are contained in the specified collection. |
|
E |
set(int index,
E element)
Replaces the element at the specified position in this list with the specified element. |
|
int |
size()
Returns the number of elements in this list. |
|
java.lang.Object[] |
toArray()
Returns an array containing all of the elements in this list. |
|
|
toArray(T[] a)
Returns an array containing all of the elements in this list in proper sequence. |
|
java.lang.String |
toString()
Returns a string representation of this list. |
|
void |
trimToSize()
Trims the capacity to the list's current size. |
Methods inherited from class java.util.ArrayList |
---|
listIterator, listIterator, removeRange, subList |
Methods inherited from class java.util.AbstractCollection |
---|
containsAll |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Collection |
---|
containsAll |
Methods inherited from interface java.util.List |
---|
containsAll |
Constructor Detail |
---|
public CheckedArrayList(java.lang.Class<E> type)
type
- The element type (should not be null).public CheckedArrayList(java.lang.Class<E> type, int capacity)
type
- The element type (should not be null).capacity
- The initial capacity.Method Detail |
---|
public java.lang.Class<E> getElementType()
getElementType
in interface CheckedCollection<E>
protected void ensureValidType(E element) throws java.lang.IllegalArgumentException
element
- the object to check, or null
.
java.lang.IllegalArgumentException
- if the specified element is not of the expected type.protected void checkWritePermission() throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
- if this collection is unmodifiable.protected java.lang.Object getLock()
this
.
Subclasses that override this method should be careful to update the lock reference
when this list is cloned.
public java.util.Iterator<E> iterator()
iterator
in interface java.lang.Iterable<E>
iterator
in interface java.util.Collection<E>
iterator
in interface java.util.List<E>
iterator
in class java.util.ArrayList<E>
public int size()
size
in interface java.util.Collection<E>
size
in interface java.util.List<E>
size
in class java.util.ArrayList<E>
public boolean isEmpty()
true
if this list contains no elements.
isEmpty
in interface java.util.Collection<E>
isEmpty
in interface java.util.List<E>
isEmpty
in class java.util.ArrayList<E>
public boolean contains(java.lang.Object o)
true
if this list contains the specified element.
contains
in interface java.util.Collection<E>
contains
in interface java.util.List<E>
contains
in class java.util.ArrayList<E>
public int indexOf(java.lang.Object o)
indexOf
in interface java.util.List<E>
indexOf
in class java.util.ArrayList<E>
public int lastIndexOf(java.lang.Object o)
lastIndexOf
in interface java.util.List<E>
lastIndexOf
in class java.util.ArrayList<E>
public E get(int index)
get
in interface java.util.List<E>
get
in class java.util.ArrayList<E>
public E set(int index, E element) throws java.lang.IllegalArgumentException, java.lang.UnsupportedOperationException
set
in interface java.util.List<E>
set
in class java.util.ArrayList<E>
index
- index of element to replace.element
- element to be stored at the specified position.
java.lang.IndexOutOfBoundsException
- if index out of range.
java.lang.IllegalArgumentException
- if the specified element is not of the expected type.
java.lang.UnsupportedOperationException
- if this collection is unmodifiable.public boolean add(E element) throws java.lang.IllegalArgumentException, java.lang.UnsupportedOperationException
add
in interface java.util.Collection<E>
add
in interface java.util.List<E>
add
in class java.util.ArrayList<E>
element
- element to be appended to this list.
true
.
java.lang.IllegalArgumentException
- if the specified element is not of the expected type.
java.lang.UnsupportedOperationException
- if this collection is unmodifiable.public void add(int index, E element) throws java.lang.IllegalArgumentException, java.lang.UnsupportedOperationException
add
in interface java.util.List<E>
add
in class java.util.ArrayList<E>
index
- index at which the specified element is to be inserted.element
- element to be inserted.
java.lang.IndexOutOfBoundsException
- if index out of range.
java.lang.IllegalArgumentException
- if the specified element is not of the expected type.
java.lang.UnsupportedOperationException
- if this collection is unmodifiable.public boolean addAll(java.util.Collection<? extends E> collection) throws java.lang.IllegalArgumentException, java.lang.UnsupportedOperationException
addAll
in interface java.util.Collection<E>
addAll
in interface java.util.List<E>
addAll
in class java.util.ArrayList<E>
collection
- the elements to be inserted into this list.
true
if this list changed as a result of the call.
java.lang.IllegalArgumentException
- if at least one element is not of the expected type.
java.lang.UnsupportedOperationException
- if this collection is unmodifiable.public boolean addAll(int index, java.util.Collection<? extends E> collection) throws java.lang.IllegalArgumentException, java.lang.UnsupportedOperationException
addAll
in interface java.util.List<E>
addAll
in class java.util.ArrayList<E>
index
- index at which to insert first element fromm the specified collection.collection
- elements to be inserted into this list.
true
if this list changed as a result of the call.
java.lang.IllegalArgumentException
- if at least one element is not of the expected type.
java.lang.UnsupportedOperationException
- if this collection is unmodifiable.public E remove(int index) throws java.lang.UnsupportedOperationException
remove
in interface java.util.List<E>
remove
in class java.util.ArrayList<E>
java.lang.UnsupportedOperationException
- if this collection is unmodifiable.public boolean remove(java.lang.Object o) throws java.lang.UnsupportedOperationException
remove
in interface java.util.Collection<E>
remove
in interface java.util.List<E>
remove
in class java.util.ArrayList<E>
java.lang.UnsupportedOperationException
- if this collection is unmodifiable.public boolean removeAll(java.util.Collection<?> c) throws java.lang.UnsupportedOperationException
removeAll
in interface java.util.Collection<E>
removeAll
in interface java.util.List<E>
removeAll
in class java.util.ArrayList<E>
java.lang.UnsupportedOperationException
- if this collection is unmodifiable.public boolean retainAll(java.util.Collection<?> c) throws java.lang.UnsupportedOperationException
retainAll
in interface java.util.Collection<E>
retainAll
in interface java.util.List<E>
retainAll
in class java.util.ArrayList<E>
java.lang.UnsupportedOperationException
- if this collection is unmodifiable.public void trimToSize()
trimToSize
in class java.util.ArrayList<E>
public void ensureCapacity(int minCapacity)
ensureCapacity
in class java.util.ArrayList<E>
public void clear() throws java.lang.UnsupportedOperationException
clear
in interface java.util.Collection<E>
clear
in interface java.util.List<E>
clear
in class java.util.ArrayList<E>
java.lang.UnsupportedOperationException
- if this collection is unmodifiable.public java.lang.Object[] toArray()
toArray
in interface java.util.Collection<E>
toArray
in interface java.util.List<E>
toArray
in class java.util.ArrayList<E>
public <T> T[] toArray(T[] a)
toArray
in interface java.util.Collection<E>
toArray
in interface java.util.List<E>
toArray
in class java.util.ArrayList<E>
T
- The type of array elements.public java.lang.String toString()
toString
in class java.util.AbstractCollection<E>
public boolean equals(java.lang.Object o)
equals
in interface java.util.Collection<E>
equals
in interface java.util.List<E>
equals
in class java.util.AbstractList<E>
public int hashCode()
hashCode
in interface java.util.Collection<E>
hashCode
in interface java.util.List<E>
hashCode
in class java.util.AbstractList<E>
public CheckedArrayList<E> clone()
clone
in class java.util.ArrayList<E>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |