wt.epm.util
Class EPMHelper

java.lang.Object
  extended bywt.epm.util.EPMHelper

public class EPMHelper
extends Object

The EPMHelper class provides set of static methods for sorting, filtering and indexing collections of objects.

Supported API: false

Extendable: false


Constructor Summary
EPMHelper()
           
 
Method Summary
static boolean containsInstance(WTCollection objects, Class[] classes)
          Determines whether the given collection contains at least one instance of any of the classes in the given list.
static List difference(Collection firstSet, Collection secondSet)
          Returns a List that contains all of the Persistable objects that are in the first collection but are not in the second collection.
static List extractObjects(Collection arrays, int index)
          Given a collection of arrays, extracts the object at the given index from each array.
protected static List extractObjects(Collection arrays, int index, List objects)
           
static List filterObjects(Collection objects, Class classToKeep)
          Given a collection of objects, filters out all objects except those of the given class from the collection.
protected static List filterObjects(Collection objects, Class classToKeep, List objectsToKeep)
           
static Iterator getIterator(Collection collection)
          Returns a Iterator over the given Collection.
static WTSet getPredecessors(WTCollection iterations)
          Returns the predecessor for each Iterated object in the given collection.
static String getVersionDisplay(Iterated anIteration)
          Returns the string representing the version identifier to be displayed in a message.
static Map indexById(Collection objects)
          Indexes a collection of Persistable objects by their object identifiers.
static Map indexByMaster(Collection objects)
          Indexes a collection of Iterated objects by the object identifiers of their masters.
static Map indexByVersion(Collection objects)
          Indexes a collection of Iterated objects by their version key.
static boolean inPersonalCabinet(CabinetBased object)
          Returns true if the entry resides in a personal cabinet, returns false if in an shared cabinet.
static Iterator persistableIterator(Collection collection)
          Returns "persistable" iterator if input parameter is WTCollection and regular collection iterator otherwise.
static Iterator queryKeyIterator(Collection collection)
          Returns "queryKey" iterator if input parameter is WTCollection and regular collection iterator otherwise.
static Iterator referenceIterator(Collection collection)
          Returns "reference" iterator if input parameter is WTCollection and regular collection iterator otherwise.
static List removeDuplicates(List originals)
          Removes duplicates from a list of Persistable objects or ObjectIdentifiers.
protected static List removeDuplicates(List originals, List noDuplicates)
           
static Map sortByClass(Collection objects)
          Sorts the objects based upon the concrete class that they belong to.
static List toList(WTCollection objects)
          Returns a List that contains all of the Persistable objects that are in the supplied WTCollection.
static QueryResult toQueryResult(WTCollection objects)
          Returns a QueryResult that contains all of the Persistable objects that are in the supplied WTCollection.
static Vector toVector(WTCollection objects)
          Returns a Vector that contains all of the Persistable objects that are in the supplied WTCollection.
static Collection wrapWithPersistableIterator(WTCollection c)
          Returns Collection that wraps given WTCollection and returns WTCollection persistable iterator as result of Collection iterator() method.
static Collection wrapWithQueryKeyIterator(WTCollection c)
          Returns Collection that wraps given WTCollection and returns WTCollection queryKey iterator as result of Collection iterator() method.
static Collection wrapWithReferenceIterator(WTCollection c)
          Returns Collection that wraps given WTCollection and returns WTCollection reference iterator as result of Collection iterator() method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EPMHelper

public EPMHelper()
Method Detail

extractObjects

public static List extractObjects(Collection arrays,
                                  int index)
Given a collection of arrays, extracts the object at the given index from each array.

Supported API: false

Returns:
List of objects extract from the arrays.

filterObjects

public static List filterObjects(Collection objects,
                                 Class classToKeep)
Given a collection of objects, filters out all objects except those of the given class from the collection.

Supported API: false

Returns:
List of objects of the given class.

removeDuplicates

public static List removeDuplicates(List originals)
Removes duplicates from a list of Persistable objects or ObjectIdentifiers.

Supported API: false

Returns:
List of Persistable objects or ObjectIdentifiers with duplicates removed

sortByClass

public static Map sortByClass(Collection objects)
Sorts the objects based upon the concrete class that they belong to. If the objects are QueryKeys, they are sorted by the class of the object that they identify.

Supported API: false

Returns:
Map indexed by class name of Lists where each List holds all of the objects the belong to the same concrete class.

indexById

public static Map indexById(Collection objects)
Indexes a collection of Persistable objects by their object identifiers.

Supported API: false

Returns:
Map of Persistable objects indexed by their object identifiers.

indexByMaster

public static Map indexByMaster(Collection objects)
Indexes a collection of Iterated objects by the object identifiers of their masters.

Supported API: false

Returns:
Map of Iterated objects indexed by object identifiers of their masters.

indexByVersion

public static Map indexByVersion(Collection objects)
                          throws WTException
Indexes a collection of Iterated objects by their version key.

Supported API: false

Returns:
Map of Iterated objects indexed by their version key.
Throws:
WTException

difference

public static List difference(Collection firstSet,
                              Collection secondSet)
Returns a List that contains all of the Persistable objects that are in the first collection but are not in the second collection.

Supported API: false

Returns:
List of Persistable objects that are in the first set but not the second

getIterator

public static Iterator getIterator(Collection collection)
Returns a Iterator over the given Collection. WTCollections support three types of Iterators, one that returns Persistables, one that returns QueryKeys and one that returns WTReferences. Its iterator() method returns a WTReference Iterator. Many methods that pre-date WTCollections work with java Collections that hold Persistable objects. The WTCollection.iterator() method is not compatible with these methods since it returns WTReferences. In order to adapt these methods to work with WTCollections, this method returns a Persistable Iterator for WTCollections.

Supported API: false

Returns:
Iterator over the Collection that returns Persistable objects

containsInstance

public static boolean containsInstance(WTCollection objects,
                                       Class[] classes)
Determines whether the given collection contains at least one instance of any of the classes in the given list.

Supported API: false

Returns:
true if the collection contains at least one instance of any of the classes otherwise false

getPredecessors

public static WTSet getPredecessors(WTCollection iterations)
                             throws WTException
Returns the predecessor for each Iterated object in the given collection. If the predecessor reference is inflated, the predecessor object is added to the WTSet otherwise its QueryKey is.

Supported API: false

Returns:
WTSet of predecessors
Throws:
WTException

toList

public static List toList(WTCollection objects)
                   throws WTException
Returns a List that contains all of the Persistable objects that are in the supplied WTCollection. Note: This is a temporary method to help ease the transition to WTCollections.

Supported API: false

Returns:
List of Persistable objects that are in the WTCollection
Throws:
WTException

toVector

public static Vector toVector(WTCollection objects)
                       throws WTException
Returns a Vector that contains all of the Persistable objects that are in the supplied WTCollection. Note: This is a temporary method to help ease the transition to WTCollections.

Supported API: false

Returns:
Vector of Persistable objects that are in the WTCollection
Throws:
WTException

toQueryResult

public static QueryResult toQueryResult(WTCollection objects)
                                 throws WTException
Returns a QueryResult that contains all of the Persistable objects that are in the supplied WTCollection. Note: This is a temporary method to help ease the transition to WTCollections.

Supported API: false

Returns:
QueryResult of Persistable objects that are in the WTCollection
Throws:
WTException

persistableIterator

public static Iterator persistableIterator(Collection collection)
                                    throws WTException
Returns "persistable" iterator if input parameter is WTCollection and regular collection iterator otherwise.

Parameters:
collection - object collection
Returns:
input collection iterator
Throws:
WTException

referenceIterator

public static Iterator referenceIterator(Collection collection)
                                  throws WTException
Returns "reference" iterator if input parameter is WTCollection and regular collection iterator otherwise.

Parameters:
collection - object collection
Returns:
input collection iterator
Throws:
WTException

queryKeyIterator

public static Iterator queryKeyIterator(Collection collection)
                                 throws WTException
Returns "queryKey" iterator if input parameter is WTCollection and regular collection iterator otherwise.

Parameters:
collection - object collection
Returns:
input collection iterator
Throws:
WTException

wrapWithPersistableIterator

public static Collection wrapWithPersistableIterator(WTCollection c)
Returns Collection that wraps given WTCollection and returns WTCollection persistable iterator as result of Collection iterator() method.

Parameters:
c - WTCollection object
Returns:
collection

wrapWithReferenceIterator

public static Collection wrapWithReferenceIterator(WTCollection c)
Returns Collection that wraps given WTCollection and returns WTCollection reference iterator as result of Collection iterator() method.

Parameters:
c - WTCollection object
Returns:
collection

wrapWithQueryKeyIterator

public static Collection wrapWithQueryKeyIterator(WTCollection c)
Returns Collection that wraps given WTCollection and returns WTCollection queryKey iterator as result of Collection iterator() method.

Parameters:
c - WTCollection object
Returns:
collection

inPersonalCabinet

public static boolean inPersonalCabinet(CabinetBased object)
                                 throws WTException
Returns true if the entry resides in a personal cabinet, returns false if in an shared cabinet. If the entry is a shortcut, the test is done on the cabinet of shortcut's parent folder.

Parameters:
object -
Returns:
boolean
Throws:
WTException

extractObjects

protected static List extractObjects(Collection arrays,
                                     int index,
                                     List objects)

filterObjects

protected static List filterObjects(Collection objects,
                                    Class classToKeep,
                                    List objectsToKeep)

removeDuplicates

protected static List removeDuplicates(List originals,
                                       List noDuplicates)

getVersionDisplay

public static String getVersionDisplay(Iterated anIteration)
                                throws VersionControlException
Returns the string representing the version identifier to be displayed in a message. The string is of the form A.1, A-1.1, or 1 depending on whether the object is Versioned, OneOffVersioned, or Iterated.

Parameters:
anIteration - Iterated
Returns:
String
Throws:
VersionControlException