org.deduced.analyzer.implementation
Class SchemaAnalyzerBuilder

java.lang.Object
  extended by org.deduced.analyzer.implementation.SchemaAnalyzerBuilder

public class SchemaAnalyzerBuilder
extends java.lang.Object

SchemaAnalyzer is used to analyze a schema and create lists of all the parent and child types for each collection type.

Author:
Steve McDuff

Nested Class Summary
protected  class SchemaAnalyzerBuilder.SchemaListener
          SchemaListener
 
Field Summary
private  java.util.Map<PropertyCollection<?,?>,RecursiveModelListener> fullSchemaMap
          map of all the schema and their recursive listeners
private static java.util.logging.Logger LOGGER
          Logger
private  PropertyCollection schemaBasedLayer
          the schema based layer being monitored
private  PropertyCollection<?,?> schemaInformation
          the schema information of the schema based layer
private  PropertyCollection<?,?> schemaList
          the schema list of the schema based layer
private  SchemaAnalyzerBuilder.SchemaListener schemaListener
          schema listener instance
private  PropertyCollection typeInfoList
          the type info list in the schema based layer
private  java.util.Map<PropertyCollection<?,?>,PropertyCollection<?,?>> typeToTypeInfoMap
          map between the types and the type info object associated with them
 
Constructor Summary
SchemaAnalyzerBuilder(PropertyCollection<?,?> setSchemaBasedLayer)
          SchemaAnalyzer Constructor
 
Method Summary
private  void addAllSchemasFromList()
          add All Schemas From List
private  void addSchema(PropertyCollection<?,?> schema)
          add schema
private  void buildCollectionReverseList(PropertyCollection<?,?> collectionType, PropertyCollection<?,?> currentParent)
          build Collection Reverse List
private  void collectionNameChanged(PropertyChangeEvent<?,?> event)
          a collection Name Changed.
private  void configureReverseDerivedMap(PropertyCollection<?,?> packageToAdd)
          configure Reverse Derived Map
private  void configureReverseDerivedMapsOnTypesInChildPackages(PropertyCollection<?,?> packageToAdd)
          configure Reverse Derived Maps On Types In the child Package
private  void configureReverseDerivedMapsOnTypesInPackage(PropertyCollection<?,?> packageToAdd)
          configure Reverse Derived Maps On Types In Package
private  void createTypeInformationIfNecessary(PropertyCollection<?,?> newValue)
          create Type Information If Necessary
private  void deleteAllUnusedTypeInformation()
          delete All unused Type Information
private  void deleteTypeInformation(PropertyCollection<?,?> collectionType)
          delete Type Information
private  void deleteTypeInformationIfNotUsed(PropertyCollection<?,?> currentTypeInfo)
          delete Type Information If Not Used
private  PropertyCollection<?,PropertyCollection<?,?>> getFlatParentListFromTypeInfo(PropertyCollection<?,?> typeInfo)
          get flat parent List From Type Info
private  PropertyCollection<?,PropertyCollection<?,?>> getReverseListFromTypeInfo(PropertyCollection<?,?> typeInfo)
          get Reverse List From Type Info
private  PropertyCollection<?,?> getSchemaFromType(PropertyCollection<?,?> collectionType)
          get the schema associated with a type
private  PropertyCollection<?,?> getSchemaInformation()
          get Schema Information
private  PropertyCollection<?,?> getSchemaList()
          get Schema List
private  PropertyCollection<?,?> getTypeInfo(PropertyCollection<?,?> type, boolean buildIfNecessary)
          get the Type Info object associated with a type
private  boolean isSchemaInUse(PropertyCollection<?,?> schema)
          test if a schema is in use
private  boolean isTypeInformationUsed(PropertyCollection<?,?> currentTypeInfo)
          test if a Type Information is still Used
private  boolean isTypeInfoUsedByChild(PropertyCollection<?,?> currentTypeInfo)
          test if a type information is used by a child that is contained by a used schema
private  boolean isTypeUsedInSchemaList(PropertyCollection<?,?> currentType)
          test if a type is used in the schema list
private  boolean isTypeValidForTypeInformation(PropertyCollection<?,?> collection)
          test if a type requires a type information object
private  void linkParentAndChild(PropertyCollection<?,?> childCollection, PropertyCollection<?,?> currentParent)
          link Parent And Child types
private  void listChanged(PropertyChangeEvent<?,?> event)
          schema List Changed
private  void parentListChanged(PropertyChangeEvent<?,?> event)
          parent List Changed
private  void rebuild()
          rebuild
private  void removeAllSchemas()
          remove All Schemas
private  void removeAllSchemasAndTypes()
          remove All Schemas and type information
private  void removeAllTypeInformation()
          remove All Type Information
private  void removeSchema(PropertyCollection<?,?> schema)
          remove Schema
private  void removeSchemaIfNotInUse(PropertyCollection<?,?> schema)
          remove Schema if not in use
private  void removeSchemaListener(PropertyCollection<?,?> schema)
          remove a Schema Listener
private  void resetSchemaBasedLayer()
          reset Schema Based Layer
private  void schemaAddParentLinkIfNecessary(PropertyChangeEvent<?,?> event)
          schema Add Parent Link Event
private  void schemaBasedLayerChanged(PropertyChangeEvent<?,?> event)
          schema Based Layer Changed
protected  void schemaChanged(PropertyChangeEvent<?,?> event)
          schema Changed
private  void schemaListChanged(PropertyChangeEvent<?,?> event)
          schema List Changed
private  void schemaRemoveParentLinkIfNecessary(PropertyChangeEvent<?,?> event)
          schema Remove Parent Link Event
private  void unlinkParentFromChild(PropertyCollection<?,?> currentChild, PropertyCollection<?,?> currentParent)
          unlink a Parent From a Child type
private  void updateSchemaInfo()
          update Schema Info
private  void updateSchemaList()
          update Schema List
private  void updateTypeInfoList()
          update Type Info List
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

private static final java.util.logging.Logger LOGGER
Logger


schemaListener

private SchemaAnalyzerBuilder.SchemaListener schemaListener
schema listener instance


fullSchemaMap

private java.util.Map<PropertyCollection<?,?>,RecursiveModelListener> fullSchemaMap
map of all the schema and their recursive listeners


typeToTypeInfoMap

private java.util.Map<PropertyCollection<?,?>,PropertyCollection<?,?>> typeToTypeInfoMap
map between the types and the type info object associated with them


schemaBasedLayer

private PropertyCollection schemaBasedLayer
the schema based layer being monitored


typeInfoList

private PropertyCollection typeInfoList
the type info list in the schema based layer


schemaList

private PropertyCollection<?,?> schemaList
the schema list of the schema based layer


schemaInformation

private PropertyCollection<?,?> schemaInformation
the schema information of the schema based layer

Constructor Detail

SchemaAnalyzerBuilder

public SchemaAnalyzerBuilder(PropertyCollection<?,?> setSchemaBasedLayer)
SchemaAnalyzer Constructor

Parameters:
setSchemaBasedLayer - layer to monitor
Method Detail

updateTypeInfoList

private void updateTypeInfoList()
update Type Info List


updateSchemaInfo

private void updateSchemaInfo()
update Schema Info


getSchemaInformation

private PropertyCollection<?,?> getSchemaInformation()
get Schema Information

Returns:
the schema information

rebuild

private void rebuild()
rebuild


updateSchemaList

private void updateSchemaList()
update Schema List


getSchemaList

private PropertyCollection<?,?> getSchemaList()
get Schema List

Returns:
the schema list

addAllSchemasFromList

private void addAllSchemasFromList()
add All Schemas From List


removeAllSchemasAndTypes

private void removeAllSchemasAndTypes()
remove All Schemas and type information


deleteAllUnusedTypeInformation

private void deleteAllUnusedTypeInformation()
delete All unused Type Information


deleteTypeInformationIfNotUsed

private void deleteTypeInformationIfNotUsed(PropertyCollection<?,?> currentTypeInfo)
delete Type Information If Not Used

Parameters:
currentTypeInfo - the type info to delete if it's not in use

isTypeInformationUsed

private boolean isTypeInformationUsed(PropertyCollection<?,?> currentTypeInfo)
test if a Type Information is still Used

Parameters:
currentTypeInfo - the type information to test
Returns:
true if the type information is in use

isTypeUsedInSchemaList

private boolean isTypeUsedInSchemaList(PropertyCollection<?,?> currentType)
test if a type is used in the schema list

Parameters:
currentType - the type to test
Returns:
true if the type is contained in the schema list

isSchemaInUse

private boolean isSchemaInUse(PropertyCollection<?,?> schema)
test if a schema is in use

Parameters:
schema - the schema to test
Returns:
true if the schema is used in the schema list

isTypeInfoUsedByChild

private boolean isTypeInfoUsedByChild(PropertyCollection<?,?> currentTypeInfo)
test if a type information is used by a child that is contained by a used schema

Parameters:
currentTypeInfo - the type information to test
Returns:
true if the type information is used

getSchemaFromType

private PropertyCollection<?,?> getSchemaFromType(PropertyCollection<?,?> collectionType)
get the schema associated with a type

Parameters:
collectionType - the collection type
Returns:
the associated schema

removeAllTypeInformation

private void removeAllTypeInformation()
remove All Type Information


removeAllSchemas

private void removeAllSchemas()
remove All Schemas


configureReverseDerivedMap

private void configureReverseDerivedMap(PropertyCollection<?,?> packageToAdd)
configure Reverse Derived Map

Parameters:
packageToAdd - the package to scan to configure the derived map

configureReverseDerivedMapsOnTypesInPackage

private void configureReverseDerivedMapsOnTypesInPackage(PropertyCollection<?,?> packageToAdd)
configure Reverse Derived Maps On Types In Package

Parameters:
packageToAdd - the package from which to add all the types

isTypeValidForTypeInformation

private boolean isTypeValidForTypeInformation(PropertyCollection<?,?> collection)
test if a type requires a type information object

Parameters:
collection - the type being verified
Returns:
true if a type is required

configureReverseDerivedMapsOnTypesInChildPackages

private void configureReverseDerivedMapsOnTypesInChildPackages(PropertyCollection<?,?> packageToAdd)
configure Reverse Derived Maps On Types In the child Package

Parameters:
packageToAdd - the package from which to add all the child package types

buildCollectionReverseList

private void buildCollectionReverseList(PropertyCollection<?,?> collectionType,
                                        PropertyCollection<?,?> currentParent)
build Collection Reverse List

Parameters:
collectionType - the type to parse and build
currentParent - current parent of the collection type

linkParentAndChild

private void linkParentAndChild(PropertyCollection<?,?> childCollection,
                                PropertyCollection<?,?> currentParent)
link Parent And Child types

Parameters:
childCollection - the child collection
currentParent - the parent collection

getReverseListFromTypeInfo

private PropertyCollection<?,PropertyCollection<?,?>> getReverseListFromTypeInfo(PropertyCollection<?,?> typeInfo)
get Reverse List From Type Info

Parameters:
typeInfo - the type information object
Returns:
the reverse list

getFlatParentListFromTypeInfo

private PropertyCollection<?,PropertyCollection<?,?>> getFlatParentListFromTypeInfo(PropertyCollection<?,?> typeInfo)
get flat parent List From Type Info

Parameters:
typeInfo - the type information object
Returns:
the flat parent list

getTypeInfo

private PropertyCollection<?,?> getTypeInfo(PropertyCollection<?,?> type,
                                            boolean buildIfNecessary)
get the Type Info object associated with a type

Parameters:
type - the type to look for
buildIfNecessary - option to build the type information if necessary
Returns:
the Type Info object associated with a type

schemaChanged

protected void schemaChanged(PropertyChangeEvent<?,?> event)
schema Changed

Parameters:
event - the event description

schemaListChanged

private void schemaListChanged(PropertyChangeEvent<?,?> event)
schema List Changed

Parameters:
event - the change event

schemaBasedLayerChanged

private void schemaBasedLayerChanged(PropertyChangeEvent<?,?> event)
schema Based Layer Changed

Parameters:
event - the change event

collectionNameChanged

private void collectionNameChanged(PropertyChangeEvent<?,?> event)
a collection Name Changed. Verify if we need to update a type information name

Parameters:
event - the change event

resetSchemaBasedLayer

private void resetSchemaBasedLayer()
reset Schema Based Layer


listChanged

private void listChanged(PropertyChangeEvent<?,?> event)
schema List Changed

Parameters:
event - the event description

createTypeInformationIfNecessary

private void createTypeInformationIfNecessary(PropertyCollection<?,?> newValue)
create Type Information If Necessary

Parameters:
newValue - the collection type from which to fetch the type information

parentListChanged

private void parentListChanged(PropertyChangeEvent<?,?> event)
parent List Changed

Parameters:
event - the event description

schemaAddParentLinkIfNecessary

private void schemaAddParentLinkIfNecessary(PropertyChangeEvent<?,?> event)
schema Add Parent Link Event

Parameters:
event - the event description

schemaRemoveParentLinkIfNecessary

private void schemaRemoveParentLinkIfNecessary(PropertyChangeEvent<?,?> event)
schema Remove Parent Link Event

Parameters:
event - the event description

unlinkParentFromChild

private void unlinkParentFromChild(PropertyCollection<?,?> currentChild,
                                   PropertyCollection<?,?> currentParent)
unlink a Parent From a Child type

Parameters:
currentChild - the child type to unlink
currentParent - the parent type to unlink

addSchema

private void addSchema(PropertyCollection<?,?> schema)
add schema

Parameters:
schema - new schema to monitor

removeSchemaIfNotInUse

private void removeSchemaIfNotInUse(PropertyCollection<?,?> schema)
remove Schema if not in use

Parameters:
schema - the schema to remove if it isn't in use

removeSchema

private void removeSchema(PropertyCollection<?,?> schema)
remove Schema

Parameters:
schema - the schema to remove

deleteTypeInformation

private void deleteTypeInformation(PropertyCollection<?,?> collectionType)
delete Type Information

Parameters:
collectionType - the type to remove

removeSchemaListener

private void removeSchemaListener(PropertyCollection<?,?> schema)
remove a Schema Listener

Parameters:
schema - the schema on which to remove the listener