Drools :: Core 6.2.0.CR4

org.drools.core.definitions.impl
Class KnowledgePackageImpl

java.lang.Object
  extended by org.drools.core.definitions.impl.KnowledgePackageImpl
All Implemented Interfaces:
Externalizable, Serializable, InternalKnowledgePackage, org.kie.api.definition.KiePackage, org.kie.internal.definition.KnowledgePackage

public class KnowledgePackageImpl
extends Object
implements InternalKnowledgePackage, Externalizable

See Also:
Serialized Form

Constructor Summary
KnowledgePackageImpl()
           
KnowledgePackageImpl(String name)
          Construct.
 
Method Summary
 void addAccumulateFunction(String name, org.kie.api.runtime.rule.AccumulateFunction function)
           
 void addEntryPointId(String id)
           
 void addFactTemplate(FactTemplate factTemplate)
           
 void addFunction(Function function)
           
 void addGlobal(String identifier, Class<?> clazz)
           
 void addImport(ImportDeclaration importDecl)
           
 void addProcess(org.kie.api.definition.process.Process process)
          Add a rule flow to this package.
 void addRule(RuleImpl rule)
          Add a Rule to this Package.
 void addStaticImport(String functionImport)
           
 void addTypeDeclaration(TypeDeclaration typeDecl)
           
 void addWindowDeclaration(WindowDeclaration window)
           
 void checkValidity()
          This will throw an exception if the package is not valid
 void clear()
           
 KnowledgePackageImpl deepCloneIfAlreadyInUse(ClassLoader classLoader)
           
 boolean equals(Object object)
           
 Map<String,org.kie.api.runtime.rule.AccumulateFunction> getAccumulateFunctions()
           
 ClassFieldAccessorStore getClassFieldAccessorStore()
           
 DialectRuntimeRegistry getDialectRuntimeRegistry()
           
 Set<String> getEntryPointIds()
           
 String getErrorSummary()
          This will return the error summary (if any) if the package is invalid.
 FactTemplate getFactTemplate(String name)
           
 org.kie.api.definition.type.FactType getFactType(String typeName)
           
 Collection<org.kie.api.definition.type.FactType> getFactTypes()
           
 Map<String,org.kie.api.definition.type.FactType> getFactTypesMap()
           
 Function getFunction(String name)
           
 Collection<String> getFunctionNames()
           
 Map<String,Function> getFunctions()
           
 List<Function> getFunctionsGeneratedFromResource(org.kie.api.io.Resource resource)
           
 Map<String,String> getGlobals()
           
 Collection<org.kie.api.definition.rule.Global> getGlobalVariables()
           
 Map<String,ImportDeclaration> getImports()
           
 String getName()
          Retrieve the name of this Package.
 ClassLoader getPackageClassLoader()
           
 Collection<org.kie.api.definition.process.Process> getProcesses()
           
 List<org.kie.api.definition.process.Process> getProcessesGeneratedFromResource(org.kie.api.io.Resource resource)
           
 Collection<org.kie.api.definition.rule.Query> getQueries()
           
 Map<org.kie.api.io.ResourceType,org.kie.internal.io.ResourceTypePackage> getResourceTypePackages()
           
 RuleImpl getRule(String name)
          Retrieve a Rule by name.
 Map<String,org.kie.api.definition.process.Process> getRuleFlows()
          Get the rule flows for this package.
 Collection<org.kie.api.definition.rule.Rule> getRules()
           
 List<RuleImpl> getRulesGeneratedFromResource(org.kie.api.io.Resource resource)
           
 Set<String> getStaticImports()
           
 TraitRegistry getTraitRegistry()
           
 TypeDeclaration getTypeDeclaration(Class<?> clazz)
           
 TypeDeclaration getTypeDeclaration(String type)
           
 Map<String,TypeDeclaration> getTypeDeclarations()
           
 TypeResolver getTypeResolver()
           
 List<TypeDeclaration> getTypesGeneratedFromResource(org.kie.api.io.Resource resource)
           
 Map<String,WindowDeclaration> getWindowDeclarations()
           
 int hashCode()
           
 boolean hasTraitRegistry()
           
 boolean isEvent(Class clazz)
          Returns true if clazz is imported as an Event class in this package
 boolean isValid()
           
 boolean needsStreamMode()
           
 void readExternal(ObjectInput stream)
          Handles the read serialization of the Package.
 void removeFunction(String functionName)
           
 void removeFunctionImport(String functionImport)
           
 List<Function> removeFunctionsGeneratedFromResource(org.kie.api.io.Resource resource)
           
 void removeGlobal(String identifier)
           
 void removeImport(String importEntry)
           
 boolean removeObjectsGeneratedFromResource(org.kie.api.io.Resource resource)
           
 List<org.kie.api.definition.process.Process> removeProcessesGeneratedFromResource(org.kie.api.io.Resource resource)
           
 void removeRule(RuleImpl rule)
           
 void removeRuleFlow(String id)
          Rule flows can be removed by ID.
 List<RuleImpl> removeRulesGeneratedFromResource(org.kie.api.io.Resource resource)
           
 void removeTypeDeclaration(String type)
           
 void resetErrors()
          Once this is called, the package will be marked as invalid
 void setClassFieldAccessorCache(ClassFieldAccessorCache classFieldAccessorCache)
           
 void setDialectRuntimeRegistry(DialectRuntimeRegistry dialectRuntimeRegistry)
           
 void setError(String summary)
          Once this is called, the package will be marked as invalid
 void setNeedStreamMode()
           
 void setTypeResolver(TypeResolver typeResolver)
           
 void setWindowDeclarations(Map<String,WindowDeclaration> windowDeclarations)
           
 String toString()
           
 void writeExternal(ObjectOutput stream)
          Handles the write serialization of the Package.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

KnowledgePackageImpl

public KnowledgePackageImpl()

KnowledgePackageImpl

public KnowledgePackageImpl(String name)
Construct.

Parameters:
name - The name of this Package.
Method Detail

getResourceTypePackages

public Map<org.kie.api.io.ResourceType,org.kie.internal.io.ResourceTypePackage> getResourceTypePackages()
Specified by:
getResourceTypePackages in interface InternalKnowledgePackage

getRules

public Collection<org.kie.api.definition.rule.Rule> getRules()
Specified by:
getRules in interface org.kie.api.definition.KiePackage

getFunction

public Function getFunction(String name)

getProcesses

public Collection<org.kie.api.definition.process.Process> getProcesses()
Specified by:
getProcesses in interface org.kie.api.definition.KiePackage

getFactTypes

public Collection<org.kie.api.definition.type.FactType> getFactTypes()
Specified by:
getFactTypes in interface org.kie.api.definition.KiePackage

getFactTypesMap

public Map<String,org.kie.api.definition.type.FactType> getFactTypesMap()

getQueries

public Collection<org.kie.api.definition.rule.Query> getQueries()
Specified by:
getQueries in interface org.kie.api.definition.KiePackage

getFunctionNames

public Collection<String> getFunctionNames()
Specified by:
getFunctionNames in interface org.kie.api.definition.KiePackage

getGlobalVariables

public Collection<org.kie.api.definition.rule.Global> getGlobalVariables()
Specified by:
getGlobalVariables in interface org.kie.api.definition.KiePackage

writeExternal

public void writeExternal(ObjectOutput stream)
                   throws IOException
Handles the write serialization of the Package. Patterns in Rules may reference generated data which cannot be serialized by default methods. The Package uses PackageCompilationData to hold a reference to the generated bytecode. The generated bytecode must be restored before any Rules.

Specified by:
writeExternal in interface Externalizable
Parameters:
stream - out the stream to write the object to; should be an instance of DroolsObjectOutputStream or OutputStream
Throws:
IOException

readExternal

public void readExternal(ObjectInput stream)
                  throws IOException,
                         ClassNotFoundException
Handles the read serialization of the Package. Patterns in Rules may reference generated data which cannot be serialized by default methods. The Package uses PackageCompilationData to hold a reference to the generated bytecode; which must be restored before any Rules. A custom ObjectInputStream, able to resolve classes against the bytecode in the PackageCompilationData, is used to restore the Rules.

Specified by:
readExternal in interface Externalizable
Parameters:
stream, - the stream to read data from in order to restore the object; should be an instance of DroolsObjectInputStream or InputStream
Throws:
IOException
ClassNotFoundException

getName

public String getName()
Retrieve the name of this Package.

Specified by:
getName in interface org.kie.api.definition.KiePackage
Returns:
The name of this Package.

getPackageClassLoader

public ClassLoader getPackageClassLoader()
Specified by:
getPackageClassLoader in interface InternalKnowledgePackage

getDialectRuntimeRegistry

public DialectRuntimeRegistry getDialectRuntimeRegistry()
Specified by:
getDialectRuntimeRegistry in interface InternalKnowledgePackage

setDialectRuntimeRegistry

public void setDialectRuntimeRegistry(DialectRuntimeRegistry dialectRuntimeRegistry)
Specified by:
setDialectRuntimeRegistry in interface InternalKnowledgePackage

addImport

public void addImport(ImportDeclaration importDecl)
Specified by:
addImport in interface InternalKnowledgePackage

removeImport

public void removeImport(String importEntry)

getImports

public Map<String,ImportDeclaration> getImports()
Specified by:
getImports in interface InternalKnowledgePackage

addTypeDeclaration

public void addTypeDeclaration(TypeDeclaration typeDecl)
Specified by:
addTypeDeclaration in interface InternalKnowledgePackage

removeTypeDeclaration

public void removeTypeDeclaration(String type)

getTypeDeclarations

public Map<String,TypeDeclaration> getTypeDeclarations()
Specified by:
getTypeDeclarations in interface InternalKnowledgePackage

getTypeDeclaration

public TypeDeclaration getTypeDeclaration(Class<?> clazz)
Specified by:
getTypeDeclaration in interface InternalKnowledgePackage

getTypeDeclaration

public TypeDeclaration getTypeDeclaration(String type)
Specified by:
getTypeDeclaration in interface InternalKnowledgePackage

addStaticImport

public void addStaticImport(String functionImport)
Specified by:
addStaticImport in interface InternalKnowledgePackage

addFunction

public void addFunction(Function function)
Specified by:
addFunction in interface InternalKnowledgePackage

getFunctions

public Map<String,Function> getFunctions()
Specified by:
getFunctions in interface InternalKnowledgePackage

addAccumulateFunction

public void addAccumulateFunction(String name,
                                  org.kie.api.runtime.rule.AccumulateFunction function)
Specified by:
addAccumulateFunction in interface InternalKnowledgePackage

getAccumulateFunctions

public Map<String,org.kie.api.runtime.rule.AccumulateFunction> getAccumulateFunctions()
Specified by:
getAccumulateFunctions in interface InternalKnowledgePackage

removeFunctionImport

public void removeFunctionImport(String functionImport)

getStaticImports

public Set<String> getStaticImports()
Specified by:
getStaticImports in interface InternalKnowledgePackage

addGlobal

public void addGlobal(String identifier,
                      Class<?> clazz)
Specified by:
addGlobal in interface InternalKnowledgePackage

removeGlobal

public void removeGlobal(String identifier)

getGlobals

public Map<String,String> getGlobals()
Specified by:
getGlobals in interface InternalKnowledgePackage

removeFunction

public void removeFunction(String functionName)
Specified by:
removeFunction in interface InternalKnowledgePackage

getFactTemplate

public FactTemplate getFactTemplate(String name)
Specified by:
getFactTemplate in interface InternalKnowledgePackage

addFactTemplate

public void addFactTemplate(FactTemplate factTemplate)
Specified by:
addFactTemplate in interface InternalKnowledgePackage

addRule

public void addRule(RuleImpl rule)
Add a Rule to this Package.

Specified by:
addRule in interface InternalKnowledgePackage
Parameters:
rule - The rule to add.
Throws:
DuplicateRuleNameException - If the Rule attempting to be added has the same name as another previously added Rule.
InvalidRuleException - If the Rule is not valid.

addProcess

public void addProcess(org.kie.api.definition.process.Process process)
Add a rule flow to this package.

Specified by:
addProcess in interface InternalKnowledgePackage

getRuleFlows

public Map<String,org.kie.api.definition.process.Process> getRuleFlows()
Get the rule flows for this package. The key is the ruleflow id. It will be Collections.EMPTY_MAP if none have been added.

Specified by:
getRuleFlows in interface InternalKnowledgePackage

removeRuleFlow

public void removeRuleFlow(String id)
Rule flows can be removed by ID.

Specified by:
removeRuleFlow in interface InternalKnowledgePackage

removeRule

public void removeRule(RuleImpl rule)
Specified by:
removeRule in interface InternalKnowledgePackage

getRule

public RuleImpl getRule(String name)
Retrieve a Rule by name.

Specified by:
getRule in interface InternalKnowledgePackage
Parameters:
name - The name of the Rule to retrieve.
Returns:
The named Rule, or null if not such Rule has been added to this Package.

toString

public String toString()
Overrides:
toString in class Object

setError

public void setError(String summary)
Once this is called, the package will be marked as invalid

Specified by:
setError in interface InternalKnowledgePackage

resetErrors

public void resetErrors()
Once this is called, the package will be marked as invalid

Specified by:
resetErrors in interface InternalKnowledgePackage

isValid

public boolean isValid()
Specified by:
isValid in interface InternalKnowledgePackage
Returns:
true (default) if there are no build/structural problems.

checkValidity

public void checkValidity()
This will throw an exception if the package is not valid

Specified by:
checkValidity in interface InternalKnowledgePackage

getErrorSummary

public String getErrorSummary()
This will return the error summary (if any) if the package is invalid.


equals

public boolean equals(Object object)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

isEvent

public boolean isEvent(Class clazz)
Returns true if clazz is imported as an Event class in this package

Specified by:
isEvent in interface InternalKnowledgePackage
Parameters:
clazz -
Returns:
true if clazz is imported as an Event class in this package

clear

public void clear()
Specified by:
clear in interface InternalKnowledgePackage

getFactType

public org.kie.api.definition.type.FactType getFactType(String typeName)
Specified by:
getFactType in interface InternalKnowledgePackage

getClassFieldAccessorStore

public ClassFieldAccessorStore getClassFieldAccessorStore()
Specified by:
getClassFieldAccessorStore in interface InternalKnowledgePackage

setClassFieldAccessorCache

public void setClassFieldAccessorCache(ClassFieldAccessorCache classFieldAccessorCache)
Specified by:
setClassFieldAccessorCache in interface InternalKnowledgePackage

getEntryPointIds

public Set<String> getEntryPointIds()
Specified by:
getEntryPointIds in interface InternalKnowledgePackage

addEntryPointId

public void addEntryPointId(String id)
Specified by:
addEntryPointId in interface InternalKnowledgePackage

getTypeResolver

public TypeResolver getTypeResolver()
Specified by:
getTypeResolver in interface InternalKnowledgePackage

setTypeResolver

public void setTypeResolver(TypeResolver typeResolver)
Specified by:
setTypeResolver in interface InternalKnowledgePackage

addWindowDeclaration

public void addWindowDeclaration(WindowDeclaration window)
Specified by:
addWindowDeclaration in interface InternalKnowledgePackage

getWindowDeclarations

public Map<String,WindowDeclaration> getWindowDeclarations()
Specified by:
getWindowDeclarations in interface InternalKnowledgePackage

setWindowDeclarations

public void setWindowDeclarations(Map<String,WindowDeclaration> windowDeclarations)

hasTraitRegistry

public boolean hasTraitRegistry()
Specified by:
hasTraitRegistry in interface InternalKnowledgePackage

getTraitRegistry

public TraitRegistry getTraitRegistry()
Specified by:
getTraitRegistry in interface InternalKnowledgePackage

removeObjectsGeneratedFromResource

public boolean removeObjectsGeneratedFromResource(org.kie.api.io.Resource resource)
Specified by:
removeObjectsGeneratedFromResource in interface InternalKnowledgePackage

removeRulesGeneratedFromResource

public List<RuleImpl> removeRulesGeneratedFromResource(org.kie.api.io.Resource resource)
Specified by:
removeRulesGeneratedFromResource in interface InternalKnowledgePackage

getRulesGeneratedFromResource

public List<RuleImpl> getRulesGeneratedFromResource(org.kie.api.io.Resource resource)

getTypesGeneratedFromResource

public List<TypeDeclaration> getTypesGeneratedFromResource(org.kie.api.io.Resource resource)

removeFunctionsGeneratedFromResource

public List<Function> removeFunctionsGeneratedFromResource(org.kie.api.io.Resource resource)
Specified by:
removeFunctionsGeneratedFromResource in interface InternalKnowledgePackage

getFunctionsGeneratedFromResource

public List<Function> getFunctionsGeneratedFromResource(org.kie.api.io.Resource resource)

removeProcessesGeneratedFromResource

public List<org.kie.api.definition.process.Process> removeProcessesGeneratedFromResource(org.kie.api.io.Resource resource)
Specified by:
removeProcessesGeneratedFromResource in interface InternalKnowledgePackage

getProcessesGeneratedFromResource

public List<org.kie.api.definition.process.Process> getProcessesGeneratedFromResource(org.kie.api.io.Resource resource)

needsStreamMode

public boolean needsStreamMode()

setNeedStreamMode

public void setNeedStreamMode()
Specified by:
setNeedStreamMode in interface InternalKnowledgePackage

deepCloneIfAlreadyInUse

public KnowledgePackageImpl deepCloneIfAlreadyInUse(ClassLoader classLoader)
Specified by:
deepCloneIfAlreadyInUse in interface InternalKnowledgePackage

Drools :: Core 6.2.0.CR4

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