com.ds.fw.types.collections
Interface FwListIF

All Superinterfaces:
java.lang.Cloneable, java.util.Collection, FwCopyableIF, FwDisplayableIF, java.util.List
All Known Implementing Classes:
FwList

public interface FwListIF
extends java.util.List, FwCopyableIF, FwDisplayableIF

I subclass the JFC ArrayList and add on a bunch of convenience methods. I do not add any new core functionality to ArrayList.


Method Summary
 void addAll(java.util.Iterator i)
          Append all of the elements in the iterator to this list.
 boolean addAssociation(java.lang.Object key, java.lang.Object value)
          Create a new FwAssocationIF with this key and value and add it to the list.
 boolean addInt(int value)
          Append an integer to the list.
 boolean containsInt(int value)
          Determine if this list contains this integer value.
 com.ds.fw.types.collections.FwCursorIteratorIF cursorIterator()
           
 com.ds.fw.types.FwCodeIF findCode(java.lang.String s)
          Get the first object in the list with a specific code.
 com.ds.fw.types.FwIdIF findId(java.lang.String s)
          Get the first object that has the id.
 java.lang.Object getCopy()
          I return a shallow copy.
 java.lang.Object getDeepCopy()
          I return a deep copy.
 java.lang.Object getFirst()
          Return the first element in the list.
 java.lang.String getFullDisplayString()
          Return the toString() value of every element in the list, separated by commas.
 int getIntAt(int index)
          Determine the integer value stored at this index.
 java.lang.Object getLast()
          Return the last element in the list.
 java.lang.String getString(int i)
          Get the element at i cast as a String.
 boolean hasCode(java.lang.String s)
          Determine if any of the elements in the list have the specified code.
 boolean hasId(java.lang.String s)
          Determine if any of the elements in the list have the specified id.
 boolean matches(java.util.Collection c)
          Determine if two collections match: the collections contain the same set of elements but not necessarily in the same order.
 void removeDuplicateInstances()
          If the list contains multiple elements that are the same instance (o1 == o2) then remove all occurances of the instances except for the first occurance.
 boolean removeInt(int value)
          Find the first occurance of this integer.
 boolean reorderIds(java.util.List v)
          Sort the list of objects by their ids.
 void replaceAll(java.util.Collection c)
          Remove all elements from my list and then add all of the elements from c.
 void replaceAll(java.util.Iterator i)
          Remove all elements from my list and then add all of the elements from the iterator.
 void reverse()
          Reverse the order of the elements in the list.
 java.util.Iterator reverseIterator()
           
 void setIntAt(int index, int value)
          Set the element at this index to be an integer value.
 void shuffle()
          Reorder the elements of the list into a 'random' order.
 void sort()
          Sort the elements in the list.
 void sort(java.util.Comparator c)
          Sort all of the elements in this list using the Comparator.
 
Methods inherited from interface java.util.List
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArray
 
Methods inherited from interface com.ds.fw.types.FwCopyableIF
getClone, getCopy, postCopy
 
Methods inherited from interface com.ds.fw.types.FwDisplayableIF
getClassName, getDisplayString, getDisplayStringFor, toString, toStringValue
 

Method Detail

getString

public java.lang.String getString(int i)
Get the element at i cast as a String.


getFirst

public java.lang.Object getFirst()
Return the first element in the list. If the list is empty throw an IndexOutOfBoundsException.


getLast

public java.lang.Object getLast()
Return the last element in the list. If the list is empty throw an IndexOutOfBoundsException.


addInt

public boolean addInt(int value)
Append an integer to the list.


removeInt

public boolean removeInt(int value)
Find the first occurance of this integer.


containsInt

public boolean containsInt(int value)
Determine if this list contains this integer value.


getIntAt

public int getIntAt(int index)
Determine the integer value stored at this index. Assume that the element an this index is an instance of Integer. If the element at this index is not an instance of Integer a ClassCastException will be thrown.


setIntAt

public void setIntAt(int index,
                     int value)
Set the element at this index to be an integer value.


findId

public com.ds.fw.types.FwIdIF findId(java.lang.String s)
Get the first object that has the id. Assumes that all objects in the list implement FwIdIF. Return null if not found.


findCode

public com.ds.fw.types.FwCodeIF findCode(java.lang.String s)
Get the first object in the list with a specific code. Assumes that all elements in the list implement FwCodeIF. Return null if not found.


cursorIterator

public com.ds.fw.types.collections.FwCursorIteratorIF cursorIterator()

reverseIterator

public java.util.Iterator reverseIterator()

hasId

public boolean hasId(java.lang.String s)
Determine if any of the elements in the list have the specified id. Assume all elements in the list implement FwIdIF.


hasCode

public boolean hasCode(java.lang.String s)
Determine if any of the elements in the list have the specified code. Assume all elements in the list implement FwCodeIF.


matches

public boolean matches(java.util.Collection c)
Determine if two collections match: the collections contain the same set of elements but not necessarily in the same order. (Contrast with ArrayList.equals() for which the elements must also be in the same order).


reverse

public void reverse()
Reverse the order of the elements in the list. Swap the positions of the elements: 0, n-1; 1, n-2, ...


replaceAll

public void replaceAll(java.util.Collection c)
Remove all elements from my list and then add all of the elements from c. This is equivalent to a call to clear() followed by a call to addAll().


replaceAll

public void replaceAll(java.util.Iterator i)
Remove all elements from my list and then add all of the elements from the iterator. This methods mutates the state of the iterator by calling hasNext() and next() until the iterator reaches its end. This method is equivalent to calling clear() followed by addAll().


addAll

public void addAll(java.util.Iterator i)
Append all of the elements in the iterator to this list. This method mutates the state of the iterator by calling hasNext() and next() until the iterator has no more elements.


sort

public void sort()
Sort the elements in the list. This method assumes that all of the elements in the list implement Comparable and that all of the elements are homogenous with respect to their implementations of Comparable.


sort

public void sort(java.util.Comparator c)
Sort all of the elements in this list using the Comparator. Assume that all of the elements in the are compatible with the Comparator.


shuffle

public void shuffle()
Reorder the elements of the list into a 'random' order.


reorderIds

public boolean reorderIds(java.util.List v)
Sort the list of objects by their ids. Assumes all my elements implement FwIdIF. Assumes the parameter list is a list of Strings which are the ids. The size of the parameter list must match my size. Every id passed in must match exactly one of the elements in my list.


addAssociation

public boolean addAssociation(java.lang.Object key,
                              java.lang.Object value)
Create a new FwAssocationIF with this key and value and add it to the list.


removeDuplicateInstances

public void removeDuplicateInstances()
If the list contains multiple elements that are the same instance (o1 == o2) then remove all occurances of the instances except for the first occurance. NOTE that this method uses identity comparison rather than the equals() method to compare instances.


getCopy

public java.lang.Object getCopy()
I return a shallow copy.

Specified by:
getCopy in interface FwCopyableIF
See Also:
FwCopyableIF

getDeepCopy

public java.lang.Object getDeepCopy()
I return a deep copy. Assume that all elements in the list implement FwCopyableIF.

Specified by:
getDeepCopy in interface FwCopyableIF
See Also:
FwCopyableIF

getFullDisplayString

public java.lang.String getFullDisplayString()
Return the toString() value of every element in the list, separated by commas. Null values are converted to "null".