com.collation.platform.model.util
Class NamingUtilityExternal

java.lang.Object
  extended by com.collation.platform.model.util.NamingUtilityExternal
All Implemented Interfaces:
NamingUtility
Direct Known Subclasses:
GeneralMigrationNamingUtility, NamingUtilityInternal

public class NamingUtilityExternal
extends java.lang.Object
implements NamingUtility

NamingUtility class is used to provide a mapping of Object pointers to unique Guids for the names of the objects


Field Summary
protected  NamingUtilityCache cache
           
protected static java.lang.String hexString_
           
protected static com.collation.platform.logger.Logger log_
           
protected static java.lang.String NAMESPACE
           
protected static byte[] NAMESPACE_GUID
           
protected  java.lang.String preFix
           
 
Constructor Summary
protected NamingUtilityExternal(java.util.List objectClassList, java.lang.String name)
          Constructor accepts a list of ObjectClass objects and initializes the meta cache and the internal guid and name maps
 
Method Summary
 java.util.List computeGuidResults(ModelObject mo, java.util.HashMap dependencyMap)
          computeGuidResults is used to compute the Guids for a given object tree.
 java.util.List computeGuidResults(ModelObject mo, java.util.HashMap dependencyMap, long version)
          computeGuidResults is used to compute the Guids for a given object tree.
protected static Guid getGUID(byte[] nameSpaceGuid, java.lang.String name)
          convert a name space GUID and a qualified name into a GUID that can be used as an instance identifier
protected static boolean isLastEnabledAttribute(NamingRuleAttribute[] attrs, int currAttr)
          islastEnabledAttribute checks remaining attributes in a naming rule to see if any more are enabled.
protected static java.lang.String transform(java.lang.String input)
          transform changes URI reserved characters into their escaped equivalents.
protected static java.lang.String transformChar(char ch)
          transformChar converts a single character into its escaped representation.
protected  void traverseAllRules(java.lang.String objCls, ModelObject mo, java.util.HashMap dependencyMap, java.util.HashMap guidMap, java.util.HashMap nameMap, ModelObject parentPtr, java.util.HashSet traversedList, java.util.ArrayList returnList, java.util.HashMap sanCheck, long version)
          traverseAllRules traverses all the rules idenitified for this class and all the classes in its hierarchy.
protected  void traversePointers(java.lang.String objCls, ModelObject mo, java.util.HashMap dependencyMap, java.util.HashMap guidMap, java.util.HashMap nameMap, java.util.HashSet traversedList, java.util.HashSet traversedChildList, java.util.ArrayList returnList, java.util.HashMap sanCheck, long version)
          traversePointers checks if a given ModelObject has any contained objects For each such contained element, it calls traverseRules
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cache

protected NamingUtilityCache cache

log_

protected static com.collation.platform.logger.Logger log_

preFix

protected java.lang.String preFix

NAMESPACE

protected static final java.lang.String NAMESPACE
See Also:
Constant Field Values

NAMESPACE_GUID

protected static final byte[] NAMESPACE_GUID

hexString_

protected static final java.lang.String hexString_
See Also:
Constant Field Values
Constructor Detail

NamingUtilityExternal

protected NamingUtilityExternal(java.util.List objectClassList,
                                java.lang.String name)
Constructor accepts a list of ObjectClass objects and initializes the meta cache and the internal guid and name maps

Parameters:
objectClassList:ArrayList - - An ArrayList of ObjectClass objects
name:String - - Name of this instance of NamingUtility
Method Detail

computeGuidResults

public java.util.List computeGuidResults(ModelObject mo,
                                         java.util.HashMap dependencyMap)
computeGuidResults is used to compute the Guids for a given object tree. The function accepts the modelObject and a pointer to a HashMap that is used to store the Guid to object pointers dependency list. The ModelObject may be a single object or a tree of ModelObjects. The function traverses the object looking for contained objects and stores the list of Guids per object in a GuidResult object. As each Guid is formed, a dependency list is also maintained which is then used by the caller to determine the objects that were used to form this Guid

Specified by:
computeGuidResults in interface NamingUtility
Parameters:
mo:ModelObject - - ModelObject tree
dependencyMap:HashMap - - Map of Guid to object pointers used
Returns:
List - List of GuidResult objects

computeGuidResults

public java.util.List computeGuidResults(ModelObject mo,
                                         java.util.HashMap dependencyMap,
                                         long version)
computeGuidResults is used to compute the Guids for a given object tree. The function accepts the modelObject and a pointer to a HashMap that is used to store the Guid to object pointers dependency list. The ModelObject may be a single object or a tree of ModelObjects. The function traverses the object looking for contained objects and stores the list of Guids per object in a GuidResult object. As each Guid is formed, a dependency list is also maintained which is then used by the caller to determine the objects that were used to form this Guid

Specified by:
computeGuidResults in interface NamingUtility
Parameters:
mo:ModelObject - - ModelObject tree
dependencyMap:HashMap - - Map of Guid to object pointers used
version:long - - Version of the guid aliases to use
Returns:
List - List of GuidResult objects

traverseAllRules

protected void traverseAllRules(java.lang.String objCls,
                                ModelObject mo,
                                java.util.HashMap dependencyMap,
                                java.util.HashMap guidMap,
                                java.util.HashMap nameMap,
                                ModelObject parentPtr,
                                java.util.HashSet traversedList,
                                java.util.ArrayList returnList,
                                java.util.HashMap sanCheck,
                                long version)
traverseAllRules traverses all the rules idenitified for this class and all the classes in its hierarchy. When a rule that is valid is found a Guid is formed for the name string and the Guid is stored in an ArrayList. When all the Guids have been traversed, the guidMap HashMap is updated.

Parameters:
objCls:String - - Class name of the ModelObject
mo:ModelObject - - The ModelObject for which we want to calculate Guids
dependencyMap:HashMap - - Map of Guid to object pointers used
guidMap:HashMap - - Map of object pointer to Guid List
nameMap:HashMap - - Map of object pointer to Names List
parentPtr:ModelObject - - The parent of the ModelObject mo
traversedList:HashSet - - Set containing object pointers for which traverseAllRules has already been called
version:long - - Version of the alias guids to use

traversePointers

protected void traversePointers(java.lang.String objCls,
                                ModelObject mo,
                                java.util.HashMap dependencyMap,
                                java.util.HashMap guidMap,
                                java.util.HashMap nameMap,
                                java.util.HashSet traversedList,
                                java.util.HashSet traversedChildList,
                                java.util.ArrayList returnList,
                                java.util.HashMap sanCheck,
                                long version)
traversePointers checks if a given ModelObject has any contained objects For each such contained element, it calls traverseRules

Parameters:
objCls:String - - Class name of the ModelObject
mo:ModelObject - - The ModelObject for which we want to check for contained objects
dependencyMap:HashMap - - Map of Guid to object pointers used
guidMap:HashMap - - Map of object pointer to Guid List
nameMap:HashMap - - Map of object pointer to Names List
traversedList:HashSet - - Set containing object pointers for which traverseAllRules has already been called
traversedChildList:HashSet - - Set containing object pointers for which traversePointers has already been called
version:long - - Version of the alias guids to use

getGUID

protected static Guid getGUID(byte[] nameSpaceGuid,
                              java.lang.String name)
convert a name space GUID and a qualified name into a GUID that can be used as an instance identifier

Parameters:
nameSpaceGuid:byte[] - - The IBM CDM name space GUID.
name:String - - Name
Returns:
Guid

transform

protected static java.lang.String transform(java.lang.String input)
transform changes URI reserved characters into their escaped equivalents.

Parameters:
input - The name to be escaped.
Returns:
Escaped string.

transformChar

protected static java.lang.String transformChar(char ch)
transformChar converts a single character into its escaped representation.

Parameters:
ch - The character to be escaped.
Returns:
A String containing the escaped version of the character.

isLastEnabledAttribute

protected static boolean isLastEnabledAttribute(NamingRuleAttribute[] attrs,
                                                int currAttr)
islastEnabledAttribute checks remaining attributes in a naming rule to see if any more are enabled. If any naming rule attributes that are left are enabled, then return true. Otherwise return false.

Parameters:
attrs - NamingRuleAttribute array passed in.
currAttr - Current NamingRuleAttribute we are looking at.
Returns:
A boolean indicating if any remaining attributes are enabled.