Class CheckedArrayList<E>

Object
AbstractCollection<E>
AbstractList<E>
ArrayList<E>
CheckedArrayList<E>
Type Parameters:
E - The type of elements in the list.
All Implemented Interfaces:
Serializable, Cloneable, Iterable<E>, Collection<E>, List<E>, RandomAccess, Cloneable, CheckedCollection<E>
Direct Known Subclasses:
XPathUtil.StepList

public class CheckedArrayList<E> extends ArrayList<E> implements CheckedCollection<E>, Cloneable
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.

Since:
2.1
Author:
Jody Garnett (Refractions Research), Martin Desruisseaux (IRD)
See Also:
  • Field Summary

    Fields inherited from class AbstractList

    modCount
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a list of the specified type.
    CheckedArrayList(Class<E> type, int capacity)
    Constructs a list of the specified type and initial capacity.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(int index, E element)
    Inserts the specified element at the specified position in this list.
    boolean
    add(E element)
    Appends the specified element to the end of this list.
    boolean
    addAll(int index, Collection<? extends E> collection)
    Inserts all of the elements in the specified collection into this list, starting at the specified position.
    boolean
    addAll(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.
    protected void
    Checks if changes in this collection are allowed.
    void
    Removes all of the elements from this list.
    Returns a shallow copy of this list.
    boolean
    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
    Compares the specified object with this list for equality.
    get(int index)
    Returns the element at the specified position in this list.
    Returns the element type given at construction time.
    protected Object
    Returns the synchronization lock.
    int
    Returns the hash code value for this list.
    int
    Returns the index of the first occurrence of the specified element in this list, or -1 if none.
    boolean
    Returns true if this list contains no elements.
    Returns an iterator over the elements in this list.
    int
    Returns the index of the last occurrence of the specified element in this list, or -1 if none.
    remove(int index)
    Removes the element at the specified position in this list.
    boolean
    Removes the first occurrence of the specified element from this list.
    boolean
    Removes all of this list's elements that are also contained in the specified collection.
    boolean
    Retains only the elements in this list that are contained in the specified collection.
    set(int index, E element)
    Replaces the element at the specified position in this list with the specified element.
    int
    Returns the number of elements in this list.
    Returns an array containing all of the elements in this list.
    <T> T[]
    toArray(T[] a)
    Returns an array containing all of the elements in this list in proper sequence.
    Returns a string representation of this list.
    void
    Trims the capacity to the list's current size.

    Methods inherited from class AbstractCollection

    containsAll

    Methods inherited from class Object

    finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface Collection

    parallelStream, removeIf, stream, toArray

    Methods inherited from interface Iterable

    forEach

    Methods inherited from interface List

    containsAll