com.ebasetech.ufs.utility
Class CollectionUtil

java.lang.Object
  extended bycom.ebasetech.ufs.utility.CollectionUtil

public class CollectionUtil
extends java.lang.Object

class for static handy colleciton methods


Constructor Summary
CollectionUtil()
           
 
Method Summary
static void addArrayToArrayList(java.lang.Object[] array, java.util.ArrayList arrayList)
          I don't understand why this function is not in java.util.Collections.
static int[] findFirstCommonElement(java.util.List one, java.util.List two)
          find the first element that is in both lists.
static int[] findLastCommonElement(java.util.List one, java.util.List two)
          find the last element that is in both lists.
static java.lang.String getValueFromMap_upperORlower(java.util.Map map, java.lang.String string)
          I've seen this so many times.
static boolean isEmptyOrNull(java.lang.Object[] array)
          see if an array has zero length or is set null
static boolean isValidIndex(java.lang.Object[] array, int index)
           
static java.lang.Object[] makeArrayFromList(java.util.List list)
           
static java.util.ArrayList makeArraylistFromArray(java.lang.Object[] array)
          I don't understand why this function is not in java.util.Collections.
static java.lang.Integer[] makeIntegerArray(int[] ints)
          make an Integer array out of an int array
static java.util.Vector makeVectorFromArray(java.lang.Object[] array)
          I don't understand why this function is not in java.util.Collections.
static boolean mapContainsString_upperORlower(java.util.Map map, java.lang.String string)
          I've seen this so many times.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CollectionUtil

public CollectionUtil()
Method Detail

mapContainsString_upperORlower

public static boolean mapContainsString_upperORlower(java.util.Map map,
                                                     java.lang.String string)
I've seen this so many times. Made a handy function for it

Parameters:
map - the map to look in
string - the string to look for
Returns:
true if the map contains string.toLowerCase or string.toUpperCase

getValueFromMap_upperORlower

public static java.lang.String getValueFromMap_upperORlower(java.util.Map map,
                                                            java.lang.String string)
I've seen this so many times. Made a handy function for it This uses containsKey, therefore if the map contains a entry with a null entry for the uppercase key, null will get returned.

Parameters:
map - the map to look in
string - the string to look for
Returns:
object from the map

makeArraylistFromArray

public static java.util.ArrayList makeArraylistFromArray(java.lang.Object[] array)
I don't understand why this function is not in java.util.Collections. Perhaps it is, but I can't find it.

Parameters:
array - the array to copy
Returns:
an ArrayList

addArrayToArrayList

public static void addArrayToArrayList(java.lang.Object[] array,
                                       java.util.ArrayList arrayList)
I don't understand why this function is not in java.util.Collections. Perhaps it is, but I can't find it.

Parameters:
array - the array to add to arrayList
arrayList - the ArrayList to be added to

makeVectorFromArray

public static java.util.Vector makeVectorFromArray(java.lang.Object[] array)
I don't understand why this function is not in java.util.Collections. Perhaps it is, but I can't find it.

Parameters:
array - the array to copy
Returns:
a Vector.

makeArrayFromList

public static java.lang.Object[] makeArrayFromList(java.util.List list)

isEmptyOrNull

public static boolean isEmptyOrNull(java.lang.Object[] array)
see if an array has zero length or is set null


isValidIndex

public static boolean isValidIndex(java.lang.Object[] array,
                                   int index)

makeIntegerArray

public static java.lang.Integer[] makeIntegerArray(int[] ints)
make an Integer array out of an int array


findFirstCommonElement

public static int[] findFirstCommonElement(java.util.List one,
                                           java.util.List two)
find the first element that is in both lists. could be optimised to go through the larger list, (indexOf is an expensive operation!)

Returns:
index of common element in 'one'

findLastCommonElement

public static int[] findLastCommonElement(java.util.List one,
                                          java.util.List two)
find the last element that is in both lists. could be optimised to go through the larger list, (indexOf is an expensive operation!)

Returns:
index of common element in 'one'