org.geworkbench.bison.datastructure.complex.panels
Class CSItemList<T extends DSNamed>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList<T>
              extended by org.geworkbench.bison.datastructure.complex.panels.CSItemList<T>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<T>, java.util.Collection<T>, java.util.List<T>, java.util.RandomAccess, DSItemList<T>, DSIdentifiable
Direct Known Subclasses:
CSPanel, CSSequentialItemList

public class CSItemList<T extends DSNamed>
extends java.util.ArrayList<T>
implements DSItemList<T>

A default DSItemList implementation that is backed by an ArrayList and a HashMap. $Id: CSItemList.java 9755 2012-07-31 16:08:09Z zji $

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
CSItemList()
           
 
Method Summary
 void add(int index, T item)
          Inserts the item at the specified index.
 boolean add(T item)
          Adds a new item to the item list, if it does not already exist.
 boolean addAll(java.util.Collection<? extends T> ts)
           
 void clear()
          Clears the contents of this item list.
 boolean equals(java.lang.Object o)
           
 T get(java.lang.String label)
          Gets an item by label, using the HashMap.
 java.lang.String getID()
          Gets the ID for this object.
 int hashCode()
           
 boolean remove(java.lang.Object item)
          Removes the object from the item list.
 T set(int index, T element)
           
 void setID(java.lang.String id)
          Sets the ID for this object.
 void setLabel(int index, java.lang.String label)
           
 
Methods inherited from class java.util.ArrayList
addAll, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, removeRange, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
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
addAll, contains, containsAll, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, removeAll, retainAll, size, subList, toArray, toArray
 

Constructor Detail

CSItemList

public CSItemList()
Method Detail

get

public T get(java.lang.String label)
Gets an item by label, using the HashMap.

Specified by:
get in interface DSItemList<T extends DSNamed>
Parameters:
label - the label of the item.
Returns:
the item found or null if not found.

add

public boolean add(T item)
Adds a new item to the item list, if it does not already exist.

Specified by:
add in interface java.util.Collection<T extends DSNamed>
Specified by:
add in interface java.util.List<T extends DSNamed>
Overrides:
add in class java.util.ArrayList<T extends DSNamed>
Parameters:
item - the item to add.
Returns:
true always.

addAll

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

add

public void add(int index,
                T item)
Inserts the item at the specified index. watkin - note: this violates the contract for List-- it does not add if index < size(), but replaces! FIXME any use of this evil method should be avoided. Known usages: CSSeqeuentialItemList.add(int,T), CSPanel.setPanel(int, DSPanel) CSSequenceSet as CSSeqeuentialItemList, CSMicroarraySet

Specified by:
add in interface java.util.List<T extends DSNamed>
Overrides:
add in class java.util.ArrayList<T extends DSNamed>
Parameters:
index - the index at which to insert the item.
item - the item to insert.

remove

public boolean remove(java.lang.Object item)
Removes the object from the item list.

Specified by:
remove in interface java.util.Collection<T extends DSNamed>
Specified by:
remove in interface java.util.List<T extends DSNamed>
Overrides:
remove in class java.util.ArrayList<T extends DSNamed>
Parameters:
item - the item to remove
Returns:
true if the item was found and removed, false if it was not found.

set

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

setLabel

public void setLabel(int index,
                     java.lang.String label)

getID

public java.lang.String getID()
Gets the ID for this object.

Specified by:
getID in interface DSIdentifiable
Returns:
the id of this item list.

setID

public void setID(java.lang.String id)
Sets the ID for this object.

Specified by:
setID in interface DSIdentifiable
Parameters:
id - the new id for this item list.

clear

public void clear()
Clears the contents of this item list.

Specified by:
clear in interface java.util.Collection<T extends DSNamed>
Specified by:
clear in interface java.util.List<T extends DSNamed>
Overrides:
clear in class java.util.ArrayList<T extends DSNamed>

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in interface java.util.Collection<T extends DSNamed>
Specified by:
equals in interface java.util.List<T extends DSNamed>
Overrides:
equals in class java.util.AbstractList<T extends DSNamed>

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Collection<T extends DSNamed>
Specified by:
hashCode in interface java.util.List<T extends DSNamed>
Overrides:
hashCode in class java.util.AbstractList<T extends DSNamed>