org.jlog2.util
Class CollectionHandler

java.lang.Object
  extended by org.jlog2.util.CollectionHandler

public class CollectionHandler
extends java.lang.Object

This provides some utility functions for java.util collections or lists, etc.


Constructor Summary
CollectionHandler()
           
 
Method Summary
static void addAll(java.util.Vector addTo, java.util.Vector toAdd)
          Add all values in toAdd to addTo.
static void addAllSet(java.util.Vector addTo, java.util.Vector toAdd)
          Add all values in toAdd to addTo, but do not allow duplication of existing values.
static java.util.Vector cloneHashKeys(java.util.Hashtable toClone)
          Clone the hashtable keys and return as a list.
static java.util.Hashtable cloneHashtable(java.util.Hashtable toClone)
          Clone the hashtable list and return.
static java.util.Vector cloneHashValues(java.util.Hashtable toClone)
          Clone the hashtable values and return as a list.
static java.util.Vector cloneVector(java.util.Vector toClone)
          Clone the vector list and return.
static java.util.Vector combinedVector(java.util.Vector list1, java.util.Vector list2)
          Return a list of all elements that are in both list 1 and list 2.
static void putAll(java.util.Hashtable addTo, java.util.Hashtable toAdd)
          Add all values in toAdd to addTo.
static java.util.Vector reciprocalVector(java.util.Vector list1, java.util.Vector list2)
          Return a list of all elements that are in list 1 but not in list 2.
static void removeAll(java.util.Vector removeFrom, java.util.Vector toRemove)
          Remove all values in toRemove from removeFrom.
static java.lang.Object[] toArray(java.util.Vector toClone)
          Clone the list and return as an array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CollectionHandler

public CollectionHandler()
Method Detail

cloneVector

public static java.util.Vector cloneVector(java.util.Vector toClone)
Clone the vector list and return.

Parameters:
toClone - the list to clone.
Returns:
a light copy (clone list only) of the vector.

addAll

public static void addAll(java.util.Vector addTo,
                          java.util.Vector toAdd)
Add all values in toAdd to addTo.

Parameters:
addTo - the list to add to.
toAdd - the values to add.

addAllSet

public static void addAllSet(java.util.Vector addTo,
                             java.util.Vector toAdd)
Add all values in toAdd to addTo, but do not allow duplication of existing values.

Parameters:
addTo - the list to add to.
toAdd - the values to add.

removeAll

public static void removeAll(java.util.Vector removeFrom,
                             java.util.Vector toRemove)
Remove all values in toRemove from removeFrom.

Parameters:
removeFrom - the list to remove from.
toRemove - the list of items to remove.

combinedVector

public static java.util.Vector combinedVector(java.util.Vector list1,
                                              java.util.Vector list2)
Return a list of all elements that are in both list 1 and list 2.

Parameters:
list1 - the first list of indexes.
list2 - the second list of indexes.
Returns:
a list of all indexes in both lists.

reciprocalVector

public static java.util.Vector reciprocalVector(java.util.Vector list1,
                                                java.util.Vector list2)
Return a list of all elements that are in list 1 but not in list 2.

Parameters:
list1 - the first list of indexes.
list2 - the second list of indexes.
Returns:
a list of all indexes in list 1 but not in list 2.

toArray

public static java.lang.Object[] toArray(java.util.Vector toClone)
Clone the list and return as an array.

Parameters:
toClone - the list to clone.
Returns:
a copy of the elements in an array list.

cloneHashtable

public static java.util.Hashtable cloneHashtable(java.util.Hashtable toClone)
Clone the hashtable list and return.

Parameters:
toClone - the list to clone.
Returns:
a light copy (clone list only) of the hashtable.

cloneHashKeys

public static java.util.Vector cloneHashKeys(java.util.Hashtable toClone)
Clone the hashtable keys and return as a list.

Parameters:
toClone - the list to clone.
Returns:
a light copy (clone list only) of the hashtable keys.

cloneHashValues

public static java.util.Vector cloneHashValues(java.util.Hashtable toClone)
Clone the hashtable values and return as a list.

Parameters:
toClone - the list to clone.
Returns:
a light copy (clone list only) of the hashtable values.

putAll

public static void putAll(java.util.Hashtable addTo,
                          java.util.Hashtable toAdd)
Add all values in toAdd to addTo.

Parameters:
addTo - the hashtable to add to.
toAdd - the values to add.