com.ds.fw.types.collections
Class FwCollectionUtility

java.lang.Object
  |
  +--com.ds.fw.types.collections.FwCollectionUtility

public class FwCollectionUtility
extends java.lang.Object

This class contains some collection utility methods.


Constructor Summary
FwCollectionUtility()
           
 
Method Summary
static boolean contains(java.util.Iterator i, java.lang.Object o)
          Checks if the list with given iterator contains an object same as o.
static int countElements(java.util.Iterator i)
          Counts elements of the collection with iterator i.
static com.ds.fw.types.FwCodeIF findCode(java.util.Iterator i, java.lang.String s)
          Finds an element of a list with iterator i, with the given code s.
static com.ds.fw.types.FwCodeIF findCode(java.util.List v, java.lang.String s)
          Finds an element of the List with the given code s.
static com.ds.fw.types.FwIdIF findId(java.util.Iterator i, java.lang.String id)
          Finds an element of a list with iterator i, with the given id.
static com.ds.fw.types.FwIdIF findId(java.util.List v, java.lang.String id)
          Finds an element of the List with the given id.
static java.lang.Object get(java.util.Iterator v, int n)
          Returns the element with index n from a collection with iterator v.
static java.util.Iterator getCopy(java.util.Iterator i)
          Makes a deep copy of the colection with iterator i and returns an iterator to the newly created copy.
static java.util.Iterator newIterator(java.lang.Object e)
          Creates a new ArrayList, adds the given object and returns an iterator for the newly created array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FwCollectionUtility

public FwCollectionUtility()
Method Detail

findId

public static com.ds.fw.types.FwIdIF findId(java.util.List v,
                                            java.lang.String id)
Finds an element of the List with the given id.

Parameters:
v - the list
id - the id to search for
Returns:
the id if found or null otherwise
See Also:
findId(Iterator,String)

findId

public static com.ds.fw.types.FwIdIF findId(java.util.Iterator i,
                                            java.lang.String id)
Finds an element of a list with iterator i, with the given id.

Parameters:
i - a list iterator
id - the id to search for
Returns:
the id if found or null otherwise

findCode

public static com.ds.fw.types.FwCodeIF findCode(java.util.List v,
                                                java.lang.String s)
Finds an element of the List with the given code s.

Parameters:
v - the list
s - the code to search for
Returns:
the code if found or null otherwise
See Also:
findCode(Iterator,String)

findCode

public static com.ds.fw.types.FwCodeIF findCode(java.util.Iterator i,
                                                java.lang.String s)
Finds an element of a list with iterator i, with the given code s.

Parameters:
i - a list iterator
s - the code to search for
Returns:
the code if found or null otherwise

contains

public static boolean contains(java.util.Iterator i,
                               java.lang.Object o)
Checks if the list with given iterator contains an object same as o.

Parameters:
i - a list iterator
o - the object to search for
Returns:
true or false

newIterator

public static java.util.Iterator newIterator(java.lang.Object e)
Creates a new ArrayList, adds the given object and returns an iterator for the newly created array.

Parameters:
e - the object to add
Returns:
an iterator of the newly created list

get

public static java.lang.Object get(java.util.Iterator v,
                                   int n)
Returns the element with index n from a collection with iterator v.

Parameters:
v - an iterator
n - the index
Returns:
the element if found or null otherwise

getCopy

public static java.util.Iterator getCopy(java.util.Iterator i)
Makes a deep copy of the colection with iterator i and returns an iterator to the newly created copy.

Parameters:
i - an iterator
Returns:
an iterator to the newly created copy

countElements

public static int countElements(java.util.Iterator i)
Counts elements of the collection with iterator i.

Parameters:
i - an iterator
Returns:
the element count