org.deduced
Class NameReferenceFinderImplementation

java.lang.Object
  extended by org.deduced.NameReferenceFinderImplementation
All Implemented Interfaces:
NameReferenceFinder

public class NameReferenceFinderImplementation
extends java.lang.Object
implements NameReferenceFinder

NameReferenceFinder : this class is used to find property collections by name. The class has a list of all the root collections. It also has a map of all the associations between the parents and the children that define which property holds the name of the child. Note that name reference finders do not monitor changes in the name of the root collections. Therefore, if a root collection name changes, the name reference finder becomes invalid.

Author:
Steve McDuff

Field Summary
private  java.util.Map<PropertyCollection<?,?>,java.lang.String> rootMapByCollection
          map that uses the root collection unique ID as a key and stores the name as a value.
private  java.util.Map<java.lang.String,PropertyCollection<?,?>> rootMapByName
          map that uses the root collection name as a key and has the root collection as a value
 
Constructor Summary
NameReferenceFinderImplementation()
          constructor
 
Method Summary
private  void addChildIfCollectionNameMatches(java.lang.String name, java.util.List<PropertyCollection<?,?>> retVal, java.lang.Object nameKey, java.lang.Object child)
          add Child If Collection Name Matches
private  void addChildIfNameMatches(PropertyCollection<?,?> parent, java.lang.String name, java.util.List<PropertyCollection<?,?>> retVal, PropertyCollection<?,?> currentInstance)
          add Child If Name Matches
 void addRootCollection(PropertyCollection<?,?> rootCollection, java.lang.String name)
          add a root collection
private static java.lang.String buildReferenceWithNoNameError(PropertyCollection<?,?> currentDependency)
          build an error message about an invalid dependency.
 void clear()
          clear the reference name finder of its root collections and child name associations
 PropertyCollection<?,?> getNamedChild(PropertyCollection<?,?> parent, java.lang.String name)
          (non-Javadoc)
 java.util.List<PropertyCollection<?,?>> getNamedChildList(PropertyCollection<?,?> parent, java.lang.String name)
          (non-Javadoc)
 java.lang.String getReferenceName(PropertyCollection<?,?> child)
          (non-Javadoc)
 PropertyCollection<?,?> getRootCollectionFromName(java.lang.String name)
          (non-Javadoc)
 java.util.Set<java.lang.String> getRootNameSet()
          (non-Javadoc)
 java.lang.String getRootReferenceName(PropertyCollection<?,?> rootCollection)
          (non-Javadoc)
 void removeRootCollection(PropertyCollection<?,?> rootCollection)
          remove a root collection
 void removeRootCollectionByName(java.lang.String name)
          Remove a root collection from a specific name
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rootMapByCollection

private java.util.Map<PropertyCollection<?,?>,java.lang.String> rootMapByCollection
map that uses the root collection unique ID as a key and stores the name as a value. Used to perform reversed search to add/remove parents.


rootMapByName

private java.util.Map<java.lang.String,PropertyCollection<?,?>> rootMapByName
map that uses the root collection name as a key and has the root collection as a value

Constructor Detail

NameReferenceFinderImplementation

public NameReferenceFinderImplementation()
constructor

Method Detail

clear

public void clear()
clear the reference name finder of its root collections and child name associations


addRootCollection

public void addRootCollection(PropertyCollection<?,?> rootCollection,
                              java.lang.String name)
add a root collection

Parameters:
rootCollection - the root collection to add
name - the name of the root collection

buildReferenceWithNoNameError

private static java.lang.String buildReferenceWithNoNameError(PropertyCollection<?,?> currentDependency)
build an error message about an invalid dependency.

Parameters:
currentDependency - the invalid dependency
Returns:
the error string

removeRootCollection

public void removeRootCollection(PropertyCollection<?,?> rootCollection)
remove a root collection

Parameters:
rootCollection - the root collection to remove

removeRootCollectionByName

public void removeRootCollectionByName(java.lang.String name)
Remove a root collection from a specific name

Parameters:
name - the name of the root collection to remove

getRootReferenceName

public java.lang.String getRootReferenceName(PropertyCollection<?,?> rootCollection)
(non-Javadoc)

Specified by:
getRootReferenceName in interface NameReferenceFinder
Parameters:
rootCollection - the root collection
Returns:
the name of the specified root collection
See Also:
NameReferenceFinder.getRootReferenceName(org.deduced.PropertyCollection)

getRootCollectionFromName

public PropertyCollection<?,?> getRootCollectionFromName(java.lang.String name)
(non-Javadoc)

Specified by:
getRootCollectionFromName in interface NameReferenceFinder
Parameters:
name - the name of the root collection
Returns:
the found root collection
See Also:
NameReferenceFinder.getRootCollectionFromName(java.lang.String)

getReferenceName

public java.lang.String getReferenceName(PropertyCollection<?,?> child)
(non-Javadoc)

Specified by:
getReferenceName in interface NameReferenceFinder
Parameters:
child - the child property collection which requires a name
Returns:
the name of the child
See Also:
NameReferenceFinder.getReferenceName(org.deduced.PropertyCollection)

getNamedChild

public PropertyCollection<?,?> getNamedChild(PropertyCollection<?,?> parent,
                                             java.lang.String name)
(non-Javadoc)

Specified by:
getNamedChild in interface NameReferenceFinder
Parameters:
parent - the parent collection
name - the name of the child
Returns:
the found child
See Also:
NameReferenceFinder.getNamedChild(org.deduced.PropertyCollection, java.lang.String)

getRootNameSet

public java.util.Set<java.lang.String> getRootNameSet()
(non-Javadoc)

Specified by:
getRootNameSet in interface NameReferenceFinder
Returns:
the set of all the Root Names
See Also:
NameReferenceFinder.getRootNameSet()

getNamedChildList

public java.util.List<PropertyCollection<?,?>> getNamedChildList(PropertyCollection<?,?> parent,
                                                                 java.lang.String name)
(non-Javadoc)

Specified by:
getNamedChildList in interface NameReferenceFinder
Parameters:
parent - the parent collection
name - the name of the child
Returns:
the found child
See Also:
NameReferenceFinder.getNamedChildList(org.deduced.PropertyCollection, java.lang.String)

addChildIfCollectionNameMatches

private void addChildIfCollectionNameMatches(java.lang.String name,
                                             java.util.List<PropertyCollection<?,?>> retVal,
                                             java.lang.Object nameKey,
                                             java.lang.Object child)
add Child If Collection Name Matches

Parameters:
name - the name to match
retVal - the list in which to add the collection if the name matches
nameKey - the name key
child - the potential child to add

addChildIfNameMatches

private void addChildIfNameMatches(PropertyCollection<?,?> parent,
                                   java.lang.String name,
                                   java.util.List<PropertyCollection<?,?>> retVal,
                                   PropertyCollection<?,?> currentInstance)
add Child If Name Matches

Parameters:
parent - the parent of the collection to add
name - the name to match
retVal - the list in which to add the child if the name matches
currentInstance - the child instance on the parent