Class DeclarationsHandler
- java.lang.Object
-
- org.drools.ancompiler.NetworkHandlerAdaptor
-
- org.drools.ancompiler.DeclarationsHandler
-
- All Implemented Interfaces:
NetworkHandler
public class DeclarationsHandler extends NetworkHandlerAdaptor
This handler is used to create the member declarations section of a generated subclass of aCompiledNetwork. Currently we only create member variables for the following types of nodes:- Non-hashed
AlphaNodesLeftInputAdapterNodesBetaNodes- A
Mapfor each set of hashedAlphaNodes. The keys are the hashed values, and the values are the IDs of the alphas
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringNEWLINEprotected static StringRANGE_INDEX_VARIABLE_NAME_PREFIX
-
Constructor Summary
Constructors Constructor Description DeclarationsHandler(StringBuilder builder, boolean disableContextEntry)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringgetAlphaNodeVariableName(org.drools.core.reteoo.AlphaNode alphaNode)protected StringgetContextVariableName(org.drools.core.reteoo.AlphaNode alphaNode)Collection<HashedAlphasDeclaration>getHashedAlphaDeclarations()protected intgetMinIdFromRangeIndex(org.drools.core.util.index.AlphaRangeIndex alphaRangeIndex)Map<String,org.drools.core.util.index.AlphaRangeIndex>getRangeIndexDeclarationMap()protected StringgetRangeIndexVariableName(org.drools.core.util.index.AlphaRangeIndex alphaRangeIndex, int minId)protected StringgetVariableName()protected static StringgetVariableName(Class<?> clazz, int nodeId)Returns a variable name based on the simple name of the specified class appended with the specified nodeId.protected static StringgetVariableName(org.drools.core.reteoo.AlphaNode alphaNode)protected static StringgetVariableName(org.drools.core.reteoo.Sink sink)static Class<?>getVariableType(org.drools.core.reteoo.AlphaNode alphaNode)static Class<?>getVariableType(org.drools.core.reteoo.Sink sink)static booleansinkCanBeInlined(org.drools.core.reteoo.Sink sink)voidstartBetaNode(org.drools.core.reteoo.BetaNode betaNode)voidstartHashedAlphaNode(org.drools.core.reteoo.AlphaNode hashedAlpha, Object hashedValue)voidstartHashedAlphaNodes(org.drools.core.rule.IndexableConstraint indexableConstraint)Receive notification of the a group of hashedorg.kie.reteoo.AlphaNodes.voidstartLeftInputAdapterNode(org.drools.core.reteoo.LeftInputAdapterNode leftInputAdapterNode)voidstartNonHashedAlphaNode(org.drools.core.reteoo.AlphaNode alphaNode)Receive notification of the a non-hashedorg.kie.reteoo.AlphaNode.voidstartRangeIndex(org.drools.core.util.index.AlphaRangeIndex alphaRangeIndex)Receive notification of alpha node range indexvoidstartWindowNode(org.drools.core.reteoo.WindowNode windowNode)-
Methods inherited from class org.drools.ancompiler.NetworkHandlerAdaptor
endBetaNode, endHashedAlphaNode, endHashedAlphaNodes, endNonHashedAlphaNode, endObjectTypeNode, endRangeIndex, endRangeIndexedAlphaNode, endWindowNode, endWindowNode, nullCaseAlphaNodeEnd, nullCaseAlphaNodeStart, replaceNameExpr, startObjectTypeNode, startRangeIndexedAlphaNode
-
-
-
-
Field Detail
-
NEWLINE
protected static final String NEWLINE
- See Also:
- Constant Field Values
-
RANGE_INDEX_VARIABLE_NAME_PREFIX
protected static final String RANGE_INDEX_VARIABLE_NAME_PREFIX
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DeclarationsHandler
public DeclarationsHandler(StringBuilder builder, boolean disableContextEntry)
-
-
Method Detail
-
getHashedAlphaDeclarations
public Collection<HashedAlphasDeclaration> getHashedAlphaDeclarations()
-
startNonHashedAlphaNode
public void startNonHashedAlphaNode(org.drools.core.reteoo.AlphaNode alphaNode)
Description copied from interface:NetworkHandlerReceive notification of the a non-hashedorg.kie.reteoo.AlphaNode.The Parser will invoke this method at the beginning of every non-hashed Alpha in the Network; there will be a corresponding endNonHashedAlphaNode() event for every startNonHashedAlphaNode() event. All of the node's decendants will be reported, in order, before the corresponding endNonHashedAlphaNode() event.
- Specified by:
startNonHashedAlphaNodein interfaceNetworkHandler- Overrides:
startNonHashedAlphaNodein classNetworkHandlerAdaptor- Parameters:
alphaNode- non-hashed AlphaNode- See Also:
NetworkHandler.endNonHashedAlphaNode(org.drools.core.reteoo.AlphaNode)
-
startBetaNode
public void startBetaNode(org.drools.core.reteoo.BetaNode betaNode)
- Specified by:
startBetaNodein interfaceNetworkHandler- Overrides:
startBetaNodein classNetworkHandlerAdaptor
-
startWindowNode
public void startWindowNode(org.drools.core.reteoo.WindowNode windowNode)
- Specified by:
startWindowNodein interfaceNetworkHandler- Overrides:
startWindowNodein classNetworkHandlerAdaptor
-
startLeftInputAdapterNode
public void startLeftInputAdapterNode(org.drools.core.reteoo.LeftInputAdapterNode leftInputAdapterNode)
- Specified by:
startLeftInputAdapterNodein interfaceNetworkHandler- Overrides:
startLeftInputAdapterNodein classNetworkHandlerAdaptor
-
startHashedAlphaNodes
public void startHashedAlphaNodes(org.drools.core.rule.IndexableConstraint indexableConstraint)
Description copied from interface:NetworkHandlerReceive notification of the a group of hashedorg.kie.reteoo.AlphaNodes.The Parser will invoke this method at the beginning of every groups of hashed Alphas in the Network; there will be a corresponding
NetworkHandler.endHashedAlphaNodes(org.drools.core.rule.IndexableConstraint)event for every startHashedAlphaNodes() event. The actual alpha nodes will be reported via theNetworkHandler.startHashedAlphaNode(org.drools.core.reteoo.AlphaNode, java.lang.Object)method, along with all of the node's decendants, in order, before the correspondingNetworkHandler.endHashedAlphaNode(org.drools.core.reteoo.AlphaNode, java.lang.Object)event.- Specified by:
startHashedAlphaNodesin interfaceNetworkHandler- Overrides:
startHashedAlphaNodesin classNetworkHandlerAdaptor- Parameters:
indexableConstraint- field reader that is used to access the hashed attribute- See Also:
NetworkHandler.endHashedAlphaNodes(org.drools.core.rule.IndexableConstraint),NetworkHandler.startHashedAlphaNode(org.drools.core.reteoo.AlphaNode, java.lang.Object)
-
startHashedAlphaNode
public void startHashedAlphaNode(org.drools.core.reteoo.AlphaNode hashedAlpha, Object hashedValue)- Specified by:
startHashedAlphaNodein interfaceNetworkHandler- Overrides:
startHashedAlphaNodein classNetworkHandlerAdaptor
-
startRangeIndex
public void startRangeIndex(org.drools.core.util.index.AlphaRangeIndex alphaRangeIndex)
Description copied from interface:NetworkHandlerReceive notification of alpha node range index- Specified by:
startRangeIndexin interfaceNetworkHandler- Overrides:
startRangeIndexin classNetworkHandlerAdaptor
-
getRangeIndexDeclarationMap
public Map<String,org.drools.core.util.index.AlphaRangeIndex> getRangeIndexDeclarationMap()
-
getVariableType
public static Class<?> getVariableType(org.drools.core.reteoo.AlphaNode alphaNode)
-
getVariableType
public static Class<?> getVariableType(org.drools.core.reteoo.Sink sink)
-
sinkCanBeInlined
public static boolean sinkCanBeInlined(org.drools.core.reteoo.Sink sink)
-
getVariableName
protected static String getVariableName(org.drools.core.reteoo.AlphaNode alphaNode)
-
getContextVariableName
protected String getContextVariableName(org.drools.core.reteoo.AlphaNode alphaNode)
-
getVariableName
protected static String getVariableName(org.drools.core.reteoo.Sink sink)
-
getVariableName
protected String getVariableName()
-
getVariableName
protected static String getVariableName(Class<?> clazz, int nodeId)
Returns a variable name based on the simple name of the specified class appended with the specified nodeId.- Parameters:
clazz- class whose simple name is lowercased and user as the prefix of the variable namenodeId- id oforg.kie.common.NetworkNode- Returns:
- variable name
- See Also:
Class.getSimpleName()
-
getAlphaNodeVariableName
protected String getAlphaNodeVariableName(org.drools.core.reteoo.AlphaNode alphaNode)
-
getRangeIndexVariableName
protected String getRangeIndexVariableName(org.drools.core.util.index.AlphaRangeIndex alphaRangeIndex, int minId)
-
getMinIdFromRangeIndex
protected int getMinIdFromRangeIndex(org.drools.core.util.index.AlphaRangeIndex alphaRangeIndex)
-
-