net.mtu.eggplant.util.gui
Class SortedListModel<E>

java.lang.Object
  extended by javax.swing.AbstractListModel
      extended by net.mtu.eggplant.util.gui.SortedListModel<E>
Type Parameters:
E - type of elements in the table model
All Implemented Interfaces:
Serializable, ListModel

public class SortedListModel<E>
extends AbstractListModel

A ListModel that orders the objects according to a comparator and does sorted insert. The comparator must be able to handle all objects in the list.

Version:
$Revision$
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
SortedListModel(Comparator<E> comparator)
          Create a SortedListModel with comparator.
SortedListModel(Comparator<E> comparator, Collection<E> collection)
          Create a SortedListModel with comparator and initalize with the list of objects in collection.
 
Method Summary
 void add(E o)
          Add o to the list.
 E getElementAt(int index)
           
 int getSize()
           
 void remove(E o)
          Remove the first occurrance of o from the list.
 
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SortedListModel

public SortedListModel(Comparator<E> comparator)
Create a SortedListModel with comparator.

PreConditions
(comparator != null)

SortedListModel

public SortedListModel(Comparator<E> comparator,
                       Collection<E> collection)
Create a SortedListModel with comparator and initalize with the list of objects in collection.

PreConditions
(comparator != null), (collection != null)
Method Detail

getSize

public int getSize()

getElementAt

public E getElementAt(int index)

add

public void add(E o)
Add o to the list. Sorted insert.


remove

public void remove(E o)
Remove the first occurrance of o from the list.