Drools :: Compiler 6.2.0.Final

org.drools.compiler.builder.impl
Class ClassHierarchyManager

java.lang.Object
  extended by org.drools.compiler.builder.impl.ClassHierarchyManager

public class ClassHierarchyManager
extends Object


Field Summary
protected  KnowledgeBuilderImpl kbuilder
           
protected  List<AbstractClassTypeDeclarationDescr> sortedDescriptors
           
protected  Map<QualifiedName,Collection<QualifiedName>> taxonomy
           
 
Constructor Summary
ClassHierarchyManager(Collection<AbstractClassTypeDeclarationDescr> unsortedDescrs, KnowledgeBuilderImpl kbuilder)
           
 
Method Summary
 void addDeclarationToPackagePreservingOrder(org.drools.core.rule.TypeDeclaration type, AbstractClassTypeDeclarationDescr typeDescr, org.drools.core.definitions.InternalKnowledgePackage tgtPackage, Map<String,PackageRegistry> pkgRegistryMap)
           
protected  TypeFieldDescr buildInheritedFieldDescrFromDefinition(org.kie.api.definition.type.FactField fld, TypeDeclarationDescr typeDescr)
           
 List<AbstractClassTypeDeclarationDescr> getSortedDescriptors()
           
protected static boolean hasCircularDependency(QualifiedName name, QualifiedName typeName, Map<QualifiedName,Collection<QualifiedName>> taxonomy)
           
 void inheritFields(PackageRegistry pkgRegistry, AbstractClassTypeDeclarationDescr typeDescr, Collection<AbstractClassTypeDeclarationDescr> sortedTypeDescriptors, List<org.drools.compiler.builder.impl.TypeDefinition> unresolvedTypes, Map<String,AbstractClassTypeDeclarationDescr> unprocessableDescrs)
           
protected  boolean mergeFields(String simpleSuperTypeName, String superTypePackageName, String fullSuper, TypeDeclarationDescr typeDescr, List<org.drools.compiler.builder.impl.TypeDefinition> unresolvedTypes, Map<String,AbstractClassTypeDeclarationDescr> unprocessableDescrs, org.drools.core.base.TypeResolver resolver)
           
protected  boolean mergeInheritedFields(TypeDeclarationDescr typeDescr, List<org.drools.compiler.builder.impl.TypeDefinition> unresolvedTypes, Map<String,AbstractClassTypeDeclarationDescr> unprocessableDescrs, org.drools.core.base.TypeResolver typeResolver)
          In order to build a declared class, the fields inherited from its superclass(es) are added to its declaration.
protected  List<AbstractClassTypeDeclarationDescr> sortByHierarchy(Collection<AbstractClassTypeDeclarationDescr> unsortedDescrs, KnowledgeBuilderImpl kbuilder)
          Utility method to sort declared beans.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

kbuilder

protected KnowledgeBuilderImpl kbuilder

sortedDescriptors

protected List<AbstractClassTypeDeclarationDescr> sortedDescriptors

taxonomy

protected Map<QualifiedName,Collection<QualifiedName>> taxonomy
Constructor Detail

ClassHierarchyManager

public ClassHierarchyManager(Collection<AbstractClassTypeDeclarationDescr> unsortedDescrs,
                             KnowledgeBuilderImpl kbuilder)
Method Detail

getSortedDescriptors

public List<AbstractClassTypeDeclarationDescr> getSortedDescriptors()

sortByHierarchy

protected List<AbstractClassTypeDeclarationDescr> sortByHierarchy(Collection<AbstractClassTypeDeclarationDescr> unsortedDescrs,
                                                                  KnowledgeBuilderImpl kbuilder)
Utility method to sort declared beans. Linearizes the hierarchy, i.e.generates a sequence of declaration such that, if Sub is subclass of Sup, then the index of Sub will be > than the index of Sup in the resulting collection. This ensures that superclasses are processed before their subclasses


hasCircularDependency

protected static boolean hasCircularDependency(QualifiedName name,
                                               QualifiedName typeName,
                                               Map<QualifiedName,Collection<QualifiedName>> taxonomy)

inheritFields

public void inheritFields(PackageRegistry pkgRegistry,
                          AbstractClassTypeDeclarationDescr typeDescr,
                          Collection<AbstractClassTypeDeclarationDescr> sortedTypeDescriptors,
                          List<org.drools.compiler.builder.impl.TypeDefinition> unresolvedTypes,
                          Map<String,AbstractClassTypeDeclarationDescr> unprocessableDescrs)

mergeInheritedFields

protected boolean mergeInheritedFields(TypeDeclarationDescr typeDescr,
                                       List<org.drools.compiler.builder.impl.TypeDefinition> unresolvedTypes,
                                       Map<String,AbstractClassTypeDeclarationDescr> unprocessableDescrs,
                                       org.drools.core.base.TypeResolver typeResolver)
In order to build a declared class, the fields inherited from its superclass(es) are added to its declaration. Inherited descriptors are marked as such to distinguish them from native ones. Various scenarioes are possible. (i) The superclass has been declared in the DRL as well : the fields are cloned as inherited (ii) The superclass is imported (external), but some of its fields have been tagged with metadata (iii) The superclass is imported. The search for field descriptors is carried out in the order. (i) and (ii+iii) are mutually exclusive. The search is as such: (i) The superclass' declared fields are used to build the base class additional fields (iii) The superclass is inspected to discover its (public) fields, from which descriptors are generated (ii) Both (i) and (iii) are applied, but the declared fields override the inspected ones

Parameters:
typeDescr - The base class descriptor, to be completed with the inherited fields descriptors
Returns:
true if all went well

mergeFields

protected boolean mergeFields(String simpleSuperTypeName,
                              String superTypePackageName,
                              String fullSuper,
                              TypeDeclarationDescr typeDescr,
                              List<org.drools.compiler.builder.impl.TypeDefinition> unresolvedTypes,
                              Map<String,AbstractClassTypeDeclarationDescr> unprocessableDescrs,
                              org.drools.core.base.TypeResolver resolver)

buildInheritedFieldDescrFromDefinition

protected TypeFieldDescr buildInheritedFieldDescrFromDefinition(org.kie.api.definition.type.FactField fld,
                                                                TypeDeclarationDescr typeDescr)

addDeclarationToPackagePreservingOrder

public void addDeclarationToPackagePreservingOrder(org.drools.core.rule.TypeDeclaration type,
                                                   AbstractClassTypeDeclarationDescr typeDescr,
                                                   org.drools.core.definitions.InternalKnowledgePackage tgtPackage,
                                                   Map<String,PackageRegistry> pkgRegistryMap)

Drools :: Compiler 6.2.0.Final

Copyright © 2001-2015 JBoss by Red Hat. All Rights Reserved.