be.ugent.caagt.swirl.lists
Class ArrayListModel<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<E>
              extended by be.ugent.caagt.swirl.lists.ArrayListModel<E>
All Implemented Interfaces:
TypedListModel<E>, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.List<E>, java.util.RandomAccess, javax.swing.ListModel

public class ArrayListModel<E>
extends java.util.ArrayList<E>
implements TypedListModel<E>

Implementation of ListModel that behaves like an ArrayList and implements the interface List from the collections API.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
ArrayListModel()
          Constructs an empty list with an initial capacity of ten.
ArrayListModel(java.util.Collection<? extends E> c)
          Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's iterator.
ArrayListModel(int initialCapacity)
          Constructs an empty list with the specified initial capacity.
 
Method Summary
 boolean add(E o)
           
 void add(int index, E element)
           
 boolean addAll(java.util.Collection<? extends E> c)
           
 boolean addAll(int index, java.util.Collection<? extends E> c)
           
 void addListDataListener(javax.swing.event.ListDataListener l)
           
 void clear()
           
protected  void fireContentsChanged(java.lang.Object source, int index0, int index1)
          Called after one or more elements of the list change.
protected  void fireIntervalAdded(java.lang.Object source, int index0, int index1)
          Called after one or more elements are added to the model.
protected  void fireIntervalRemoved(java.lang.Object source, int index0, int index1)
          Called after one or more elements are removed from the model.
 java.lang.Object getElementAt(int index)
           
 int getSize()
           
 E remove(int index)
           
 boolean remove(java.lang.Object obj)
           
 void removeListDataListener(javax.swing.event.ListDataListener l)
           
protected  void removeRange(int fromIndex, int toIndex)
           
 E set(int index, E element)
           
 
Methods inherited from class java.util.ArrayList
clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, 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, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, removeAll, retainAll, size, subList, toArray, toArray
 

Constructor Detail

ArrayListModel

public ArrayListModel(int initialCapacity)
Constructs an empty list with the specified initial capacity.


ArrayListModel

public ArrayListModel()
Constructs an empty list with an initial capacity of ten.


ArrayListModel

public ArrayListModel(java.util.Collection<? extends E> c)
Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's iterator. The ArrayListModel instance has an initial capacity of 110% the size of the specified collection.

Parameters:
c - the collection whose elements are to be placed into this list.
Throws:
java.lang.NullPointerException - if the specified collection is null.
Method Detail

removeListDataListener

public void removeListDataListener(javax.swing.event.ListDataListener l)
Specified by:
removeListDataListener in interface javax.swing.ListModel

addListDataListener

public void addListDataListener(javax.swing.event.ListDataListener l)
Specified by:
addListDataListener in interface javax.swing.ListModel

fireIntervalRemoved

protected void fireIntervalRemoved(java.lang.Object source,
                                   int index0,
                                   int index1)
Called after one or more elements are removed from the model. index0 and index1 are the end points of the interval that's been removed. Note that index0 need not be less than or equal to index1.

Parameters:
source - the ArrayListModel that changed, typically "this"
index0 - one end of the removed interval, including index0
index1 - the other end of the removed interval, including index1
See Also:
AbstractListModel

fireIntervalAdded

protected void fireIntervalAdded(java.lang.Object source,
                                 int index0,
                                 int index1)
Called after one or more elements are added to the model. The new elements are specified by a closed interval index0, index1 (endpoints included). Note that index0 need not be less than or equal to index1.

Parameters:
source - the ArrayListModel that changed, typically "this"
index0 - one end of the new interval
index1 - the other end of the new interval
See Also:
AbstractListModel

fireContentsChanged

protected void fireContentsChanged(java.lang.Object source,
                                   int index0,
                                   int index1)
Called after one or more elements of the list change. The changed elements are specified by the closed interval index0, index1 (endpoints included). Note that index0 need not be less than or equal to index1.

Parameters:
source - the ArrayListModel that changed, typically "this"
index0 - one end of the interval
index1 - the other end of the interval
See Also:
AbstractListModel

getSize

public int getSize()
Specified by:
getSize in interface javax.swing.ListModel

getElementAt

public java.lang.Object getElementAt(int index)
Specified by:
getElementAt in interface javax.swing.ListModel

add

public boolean add(E o)
Specified by:
add in interface java.util.Collection<E>
Specified by:
add in interface java.util.List<E>
Overrides:
add in class java.util.ArrayList<E>

add

public void add(int index,
                E element)
Specified by:
add in interface java.util.List<E>
Overrides:
add in class java.util.ArrayList<E>

addAll

public boolean addAll(java.util.Collection<? extends E> c)
Specified by:
addAll in interface java.util.Collection<E>
Specified by:
addAll in interface java.util.List<E>
Overrides:
addAll in class java.util.ArrayList<E>

addAll

public boolean addAll(int index,
                      java.util.Collection<? extends E> c)
Specified by:
addAll in interface java.util.List<E>
Overrides:
addAll in class java.util.ArrayList<E>

clear

public void clear()
Specified by:
clear in interface java.util.Collection<E>
Specified by:
clear in interface java.util.List<E>
Overrides:
clear in class java.util.ArrayList<E>

remove

public boolean remove(java.lang.Object obj)
Specified by:
remove in interface java.util.Collection<E>
Specified by:
remove in interface java.util.List<E>
Overrides:
remove in class java.util.ArrayList<E>

remove

public E remove(int index)
Specified by:
remove in interface java.util.List<E>
Overrides:
remove in class java.util.ArrayList<E>

removeRange

protected void removeRange(int fromIndex,
                           int toIndex)
Overrides:
removeRange in class java.util.ArrayList<E>

set

public E set(int index,
             E element)
Specified by:
set in interface java.util.List<E>
Overrides:
set in class java.util.ArrayList<E>