Class ReteNode
- java.lang.Object
- 
- jadex.rules.rulesystem.rete.nodes.AbstractNode
- 
- jadex.rules.rulesystem.rete.nodes.ReteNode
 
 
- 
- All Implemented Interfaces:
- INode,- IObjectSourceNode,- java.lang.Cloneable
 
 public class ReteNode extends AbstractNode implements IObjectSourceNode ReteNode implementation of the IConditionSystem.
- 
- 
Field SummaryFields Modifier and Type Field Description protected ReteBuilderbuilderThe rete builder.protected intchangecntprotected booleancheckDo a consistency check after each state change (requires asserts).protected java.util.Listcheckedprotected java.util.MapindirectnodesetsIndirectly affected nodes for an attribute type (cached for speed).protected booleaninitedFor debugging: node is inited and network must not be changed anymore.protected InitialFactNodeinitialfactThe initial fact node (if any).protected intnodecounterThe node counter in this network.protected AttributeSetrelevantsThe set of relevant attributes.protected java.util.MapterminalnodesThe terminal nodes (IRule -> Node).protected java.util.MaptypenodesThe type nodes.protected java.util.MaptypenodesetsMatching nodes for each (sub)type (cached for speed).- 
Fields inherited from class jadex.rules.rulesystem.rete.nodes.AbstractNodeclones, nodeid
 
- 
 - 
Constructor SummaryConstructors Constructor Description ReteNode()Create a new rete system.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddObject(java.lang.Object id, OAVObjectType type, IOAVState state, ReteMemory mem, AbstractAgenda agenda)Tell the condition system about a new object in the state.voidaddObjectConsumer(IObjectConsumerNode node)Add an object consumer node.voidaddRule(IRule rule)Add a rule to the network.protected booleancheckConsistency(ReteMemory mem)Check consistency of Rete network/memory.java.lang.ObjectcreateNodeMemory(IOAVState state)Create the node memory.protected voiddoClone(java.lang.Object theclone)Do clone makes a deep clone without regarding cycles.ReteBuildergetBuilder()Get the builder.AttributeSetgetIndirectAttributes()Get the set of indirect attribute types.protected java.util.SetgetIndirectNodes(OAVAttributeType attrtype, OAVTypeModel tmodel)Get the set of indirectly affected nodes for an attribute type.InitialFactNodegetInitialFactNode()Get the initial fact node (if any).intgetNextNodeId()Get the next nodecounter.intgetNodeCount()Get the number of nodes in the network.java.util.CollectiongetNodeMemory(ReteMemory mem)Get the memory for this node.IObjectConsumerNode[]getObjectConsumers()Get all object consumer nodes.AttributeSetgetRelevantAttributes()Get the set of relevant attribute types.TerminalNodegetTerminalNode(IRule rule)Set the terminal node for a rule.TypeNodegetTypeNode(OAVObjectType type)Get the node for a type.protected java.util.SetgetTypeNodes(OAVObjectType type)Get the set of matching type nodes for a (sub)type.voidmodifyIndirectObject(java.lang.Object object, OAVAttributeType type, java.lang.Object oldvalue, java.lang.Object newvalue, IOAVState state, ReteMemory mem, AbstractAgenda agenda)Propagate an indirect object change to this node.voidmodifyObject(java.lang.Object id, OAVObjectType type, OAVAttributeType attr, java.lang.Object oldvalue, java.lang.Object newvalue, IOAVState state, ReteMemory mem, AbstractAgenda agenda)Tell the condition system about a modified object in the state.voidputTerminalNode(TerminalNode node)Set the terminal node for a rule.voidremoveObject(java.lang.Object id, OAVObjectType type, IOAVState state, ReteMemory mem, AbstractAgenda agenda)Tell the condition system about a removed object in the state.voidremoveObjectConsumer(IObjectConsumerNode node)Remove an object consumer.voidremoveRule(IRule rule)Remove a rule from the network.voidsetInited(boolean inited)Set the inited state.- 
Methods inherited from class jadex.rules.rulesystem.rete.nodes.AbstractNodecheckNodeConsistency, clone, equals, getNodeId, hashCode, toString, toString
 - 
Methods inherited from class java.lang.Objectfinalize, getClass, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface jadex.rules.rulesystem.rete.nodes.INodecheckNodeConsistency, clone, getNodeId
 
- 
 
- 
- 
- 
Field Detail- 
typenodesprotected java.util.Map typenodes The type nodes.
 - 
typenodesetsprotected java.util.Map typenodesets Matching nodes for each (sub)type (cached for speed).
 - 
indirectnodesetsprotected volatile java.util.Map indirectnodesets Indirectly affected nodes for an attribute type (cached for speed).
 - 
initialfactprotected InitialFactNode initialfact The initial fact node (if any).
 - 
terminalnodesprotected java.util.Map terminalnodes The terminal nodes (IRule -> Node).
 - 
builderprotected ReteBuilder builder The rete builder.
 - 
relevantsprotected volatile AttributeSet relevants The set of relevant attributes.
 - 
checkprotected boolean check Do a consistency check after each state change (requires asserts).
 - 
nodecounterprotected int nodecounter The node counter in this network.
 - 
initedprotected boolean inited For debugging: node is inited and network must not be changed anymore.
 - 
changecntprotected int changecnt 
 - 
checkedprotected java.util.List checked 
 
- 
 - 
Method Detail- 
addObjectpublic void addObject(java.lang.Object id, OAVObjectType type, IOAVState state, ReteMemory mem, AbstractAgenda agenda)Tell the condition system about a new object in the state.- Parameters:
- object- The new object.
 
 - 
removeObjectpublic void removeObject(java.lang.Object id, OAVObjectType type, IOAVState state, ReteMemory mem, AbstractAgenda agenda)Tell the condition system about a removed object in the state.- Parameters:
- object- The removed object.
 
 - 
modifyObjectpublic void modifyObject(java.lang.Object id, OAVObjectType type, OAVAttributeType attr, java.lang.Object oldvalue, java.lang.Object newvalue, IOAVState state, ReteMemory mem, AbstractAgenda agenda)Tell the condition system about a modified object in the state.- Parameters:
- object- The new object.
 
 - 
modifyIndirectObjectpublic void modifyIndirectObject(java.lang.Object object, OAVAttributeType type, java.lang.Object oldvalue, java.lang.Object newvalue, IOAVState state, ReteMemory mem, AbstractAgenda agenda)Propagate an indirect object change to this node.- Specified by:
- modifyIndirectObjectin interface- INode
- Parameters:
- object- The changed object.
 
 - 
addRulepublic void addRule(IRule rule) Add a rule to the network.- Parameters:
- rule- The rule to add.
 
 - 
removeRulepublic void removeRule(IRule rule) Remove a rule from the network.- Parameters:
- rule- The rule to remove.
 
 - 
putTerminalNodepublic void putTerminalNode(TerminalNode node) Set the terminal node for a rule.- Parameters:
- rule- The rule.
- node- The node.
 
 - 
getTerminalNodepublic TerminalNode getTerminalNode(IRule rule) Set the terminal node for a rule.- Parameters:
- rule- The rule.
- node- The node.
 
 - 
getNodeCountpublic int getNodeCount() Get the number of nodes in the network.- Returns:
- The number of nodes.
 
 - 
addObjectConsumerpublic void addObjectConsumer(IObjectConsumerNode node) Add an object consumer node.- Specified by:
- addObjectConsumerin interface- IObjectSourceNode
- Parameters:
- node- A new consumer node.
 
 - 
removeObjectConsumerpublic void removeObjectConsumer(IObjectConsumerNode node) Remove an object consumer.- Specified by:
- removeObjectConsumerin interface- IObjectSourceNode
- Parameters:
- node- The consumer node.
 
 - 
getNodeMemorypublic java.util.Collection getNodeMemory(ReteMemory mem) Get the memory for this node.- Specified by:
- getNodeMemoryin interface- INode
- Specified by:
- getNodeMemoryin interface- IObjectSourceNode
- Returns:
- The memory.
 
 - 
getObjectConsumerspublic IObjectConsumerNode[] getObjectConsumers() Get all object consumer nodes.- Specified by:
- getObjectConsumersin interface- IObjectSourceNode
- Returns:
- All object consumer nodes.
 
 - 
getTypeNodepublic TypeNode getTypeNode(OAVObjectType type) Get the node for a type.- Parameters:
- type- The type.
- Returns:
- The type node (if any).
 
 - 
getInitialFactNodepublic InitialFactNode getInitialFactNode() Get the initial fact node (if any).
 - 
createNodeMemorypublic java.lang.Object createNodeMemory(IOAVState state) Create the node memory.- Specified by:
- createNodeMemoryin interface- INode
- Parameters:
- state- The state.
- Returns:
- The node memory.
 
 - 
getRelevantAttributespublic AttributeSet getRelevantAttributes() Get the set of relevant attribute types.- Specified by:
- getRelevantAttributesin interface- INode
 
 - 
getIndirectAttributespublic AttributeSet getIndirectAttributes() Get the set of indirect attribute types. I.e. attributes of objects, which are not part of an object conditions (e.g. for chained extractors)- Specified by:
- getIndirectAttributesin interface- INode
- Returns:
- The relevant attribute types.
 
 - 
getBuilderpublic ReteBuilder getBuilder() Get the builder.- Returns:
- The rete builder.
 
 - 
getTypeNodesprotected java.util.Set getTypeNodes(OAVObjectType type) Get the set of matching type nodes for a (sub)type.- Parameters:
- type- The object type.
- Returns:
- The set of type nodes for that object type.
 
 - 
getIndirectNodesprotected java.util.Set getIndirectNodes(OAVAttributeType attrtype, OAVTypeModel tmodel) Get the set of indirectly affected nodes for an attribute type.- Parameters:
- attrtype- The attribute type.
- tmodel- The OAV type model.
- Returns:
- The set of indirectly affected nodes for that attribute type.
 
 - 
doCloneprotected void doClone(java.lang.Object theclone) Do clone makes a deep clone without regarding cycles.- Specified by:
- doClonein class- AbstractNode
- Parameters:
- clone- The clone.
 
 - 
checkConsistencyprotected boolean checkConsistency(ReteMemory mem) Check consistency of Rete network/memory. For debugging. Only performs some simple checks and does not assure complete consistency.
 - 
getNextNodeIdpublic int getNextNodeId() Get the next nodecounter.- Returns:
- The id for the next node.
 
 - 
setInitedpublic void setInited(boolean inited) Set the inited state.
 
- 
 
-