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
 void addAllMatchingOrderingChildren(PropertyCollection<?,?> parent, java.lang.String name, java.util.List<PropertyCollection<?,?>> retVal, PropertyCollection valueInstance)
          add All Matching Ordering Children
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
 boolean containsRootCollection(PropertyCollection<?,?> potentialRoot)
          test if a root collection is registered or not.
static java.lang.String getCollectionName(PropertyCollection<?,?> child)
          get Collection Name
 PropertyCollection<?,?> getNamedChild(PropertyCollection<?,?> parent, java.lang.String name)
          (non-Javadoc)
 java.util.List<PropertyCollection<?,?>> getNamedChildList(PropertyCollection<?,?> parent, java.lang.String name)
          (non-Javadoc)
static java.lang.String getOrderingName(PropertyCollection<?,?> child)
          get Ordering Name
 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)
static boolean isCollectionNameEqual(java.lang.String name, java.lang.Object nameKey, java.lang.Object child)
          is Collection Name Equal
static boolean isOrdereredListType(PropertyCollection<?,?> type)
          is ordered list type
static boolean isOrderingType(PropertyCollection<?,?> type)
          is Ordering Type
 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


containsRootCollection

public boolean containsRootCollection(PropertyCollection<?,?> potentialRoot)
test if a root collection is registered or not.

Parameters:
potentialRoot - the potential root collection
Returns:
true if the root collection is registered

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)

getOrderingName

public static java.lang.String getOrderingName(PropertyCollection<?,?> child)
get Ordering Name

Parameters:
child - the ordering collection
Returns:
the name associated with the ordering collection

getCollectionName

public static java.lang.String getCollectionName(PropertyCollection<?,?> child)
get Collection Name

Parameters:
child - collection from which to get the name
Returns:
the name of the collection

isOrdereredListType

public static boolean isOrdereredListType(PropertyCollection<?,?> type)
is ordered list type

Parameters:
type - the property collection type to test
Returns:
true if the collection type is an ordered list

isOrderingType

public static boolean isOrderingType(PropertyCollection<?,?> type)
is Ordering Type

Parameters:
type - the property collection type to test
Returns:
true if the collection type is an ordering property collection

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)

addAllMatchingOrderingChildren

public void addAllMatchingOrderingChildren(PropertyCollection<?,?> parent,
                                           java.lang.String name,
                                           java.util.List<PropertyCollection<?,?>> retVal,
                                           PropertyCollection valueInstance)
add All Matching Ordering Children

Parameters:
parent - the parent collection of the ordering children
name - name to match
retVal - list to fill with matching values
valueInstance - value instance in the ordering type

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

isCollectionNameEqual

public static boolean isCollectionNameEqual(java.lang.String name,
                                            java.lang.Object nameKey,
                                            java.lang.Object child)
is Collection Name Equal

Parameters:
name - the name to look for
nameKey - the property key to use to find the name on the collection
child - the potential collection
Returns:
true if the name matches

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