Class AbstractBetaNode
- java.lang.Object
-
- jadex.rules.rulesystem.rete.nodes.AbstractNode
-
- jadex.rules.rulesystem.rete.nodes.AbstractBetaNode
-
- All Implemented Interfaces:
INode,IObjectConsumerNode,ITupleConsumerNode,ITupleSourceNode,java.lang.Cloneable
public abstract class AbstractBetaNode extends AbstractNode implements IObjectConsumerNode, ITupleConsumerNode, ITupleSourceNode
A beta node has the purpose to perform a constraints check between (at least) two objects. The beta node has to incoming coming connections which both can activate the node.
-
-
Field Summary
Fields Modifier and Type Field Description protected IConstraintEvaluator[]evaluatorsThe constraint evaluator.protected ConstraintIndexer[]indexersThe indexed constraint indexers.protected AttributeSetindirectsThe set of indirect attributes.protected IObjectSourceNodeosourceThe object source.protected AttributeSetrelevantsThe set of relevant attributes.protected ITupleConsumerNode[]tconsumersThe tuple consumers.protected ITupleSourceNodetsourceThe tuple source.-
Fields inherited from class jadex.rules.rulesystem.rete.nodes.AbstractNode
clones, nodeid
-
-
Constructor Summary
Constructors Constructor Description AbstractBetaNode(int nodeid, IConstraintEvaluator[] evaluators, ConstraintIndexer[] xevaluators)Create a new beta node.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidaddMatch(Tuple left, java.lang.Object right, IOAVState state, ReteMemory mem, AbstractAgenda agenda)Add a match to the node memory and propagate if necessary.voidaddObject(java.lang.Object right, IOAVState state, ReteMemory mem, AbstractAgenda agenda)Send an object to this node.voidaddTuple(Tuple left, IOAVState state, ReteMemory mem, AbstractAgenda agenda)Send a tuple to this node.voidaddTupleConsumer(ITupleConsumerNode node)Add an tuple consumer node.protected booleancheckNonindexedConstraints(Tuple left, java.lang.Object right, IOAVState state)Check the non-indexed constraints for the given left/right values.java.lang.ObjectcreateNodeMemory(IOAVState state)Create the node memory.protected voiddoClone(java.lang.Object theclone)Do clone makes a deep clone without regarding cycles.protected java.util.CollectionfetchObjectMemory(IOAVState state, Tuple left, ReteMemory mem)Fetch the object memory for a given object.protected java.util.CollectionfetchTupleMemory(IOAVState state, java.lang.Object right, ReteMemory mem)Fetch the tuple memory for a given object.IConstraintEvaluator[]getConstraintEvaluators()Get the evaluators.ConstraintIndexer[]getConstraintIndexers()Get the indexers.AttributeSetgetIndirectAttributes()Get the set of indirect attribute types.java.util.CollectiongetNodeMemory(ReteMemory mem)Get the memory for this node.IObjectSourceNodegetObjectSource()Get the object source of this node.AttributeSetgetRelevantAttributes()Get the set of relevant attribute types.ITupleConsumerNode[]getTupleConsumers()Get all tuple consumer nodes.ITupleSourceNodegetTupleSource()Get the tuple source of this node.protected java.util.CollectionidentityIntersection(IOAVState state, java.util.Collection c1, java.util.Collection c2)Compute the intersection of two collections.protected java.util.Collectionintersection(IOAVState state, java.util.Collection c1, java.util.Collection c2)Compute the intersection of two collections.booleanisAffected(OAVAttributeType attr)Test if the node is affected from a modification.protected abstract booleanisMatchContained(IOAVState state, Tuple left, java.lang.Object right, ReteMemory mem)Check if a match is contained.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 right, OAVAttributeType type, java.lang.Object oldvalue, java.lang.Object newvalue, IOAVState state, ReteMemory mem, AbstractAgenda agenda)Propagate an object change to this node.voidmodifyTuple(Tuple left, int tupleindex, OAVAttributeType type, java.lang.Object oldvalue, java.lang.Object newvalue, IOAVState state, ReteMemory mem, AbstractAgenda agenda)Modify a tuple in this node.protected abstract voidpropagateModification(Tuple left, java.lang.Object right, int tupleindex, OAVAttributeType type, java.lang.Object oldvalue, java.lang.Object newvalue, IOAVState state, ReteMemory mem, AbstractAgenda agenda)Propagate a change of a tuple in the result memory.protected abstract voidremoveMatch(Tuple left, java.lang.Object right, IOAVState state, ReteMemory mem, AbstractAgenda agenda)Remove a match from the node memory and propagate if necessary.voidremoveObject(java.lang.Object right, IOAVState state, ReteMemory mem, AbstractAgenda agenda)Remove an object from this node.voidremoveTuple(Tuple left, IOAVState state, ReteMemory mem, AbstractAgenda agenda)Remove a tuple from this node.voidremoveTupleConsumer(ITupleConsumerNode node)Remove an tuple consumer.voidsetObjectSource(IObjectSourceNode node)Set the object source of this node.voidsetTupleSource(ITupleSourceNode node)Set the tuple source of this node.-
Methods inherited from class jadex.rules.rulesystem.rete.nodes.AbstractNode
checkNodeConsistency, clone, equals, getNodeId, hashCode, toString, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jadex.rules.rulesystem.rete.nodes.INode
checkNodeConsistency, clone, getNodeId
-
-
-
-
Field Detail
-
tconsumers
protected ITupleConsumerNode[] tconsumers
The tuple consumers.
-
osource
protected IObjectSourceNode osource
The object source.
-
tsource
protected ITupleSourceNode tsource
The tuple source.
-
evaluators
protected IConstraintEvaluator[] evaluators
The constraint evaluator.
-
indexers
protected ConstraintIndexer[] indexers
The indexed constraint indexers.
-
relevants
protected volatile AttributeSet relevants
The set of relevant attributes.
-
indirects
protected volatile AttributeSet indirects
The set of indirect attributes.
-
-
Constructor Detail
-
AbstractBetaNode
public AbstractBetaNode(int nodeid, IConstraintEvaluator[] evaluators, ConstraintIndexer[] xevaluators)Create a new beta node.
-
-
Method Detail
-
addTupleConsumer
public void addTupleConsumer(ITupleConsumerNode node)
Add an tuple consumer node.- Specified by:
addTupleConsumerin interfaceITupleSourceNode- Parameters:
node- A new consumer node.
-
removeTupleConsumer
public void removeTupleConsumer(ITupleConsumerNode node)
Remove an tuple consumer.- Specified by:
removeTupleConsumerin interfaceITupleSourceNode- Parameters:
node- The consumer node.
-
getNodeMemory
public java.util.Collection getNodeMemory(ReteMemory mem)
Get the memory for this node.- Specified by:
getNodeMemoryin interfaceINode- Specified by:
getNodeMemoryin interfaceITupleSourceNode- Returns:
- The memory.
-
getTupleConsumers
public ITupleConsumerNode[] getTupleConsumers()
Get all tuple consumer nodes.- Specified by:
getTupleConsumersin interfaceITupleSourceNode- Returns:
- All tuple consumer nodes.
-
addTuple
public void addTuple(Tuple left, IOAVState state, ReteMemory mem, AbstractAgenda agenda)
Send a tuple to this node.- Specified by:
addTuplein interfaceITupleConsumerNode- Parameters:
tuple- The tuple.
-
removeTuple
public void removeTuple(Tuple left, IOAVState state, ReteMemory mem, AbstractAgenda agenda)
Remove a tuple from this node.- Specified by:
removeTuplein interfaceITupleConsumerNode- Parameters:
tuple- The tuple.
-
modifyTuple
public void modifyTuple(Tuple left, int tupleindex, OAVAttributeType type, java.lang.Object oldvalue, java.lang.Object newvalue, IOAVState state, ReteMemory mem, AbstractAgenda agenda)
Modify a tuple in this node.- Specified by:
modifyTuplein interfaceITupleConsumerNode- Parameters:
left- The tuple.
-
setTupleSource
public void setTupleSource(ITupleSourceNode node)
Set the tuple source of this node.- Specified by:
setTupleSourcein interfaceITupleConsumerNode- Parameters:
node- The tuple source node.
-
getTupleSource
public ITupleSourceNode getTupleSource()
Get the tuple source of this node.- Specified by:
getTupleSourcein interfaceITupleConsumerNode- Returns:
- The object source node.
-
addObject
public void addObject(java.lang.Object right, IOAVState state, ReteMemory mem, AbstractAgenda agenda)Send an object to this node.- Specified by:
addObjectin interfaceIObjectConsumerNode- Parameters:
object- The object.
-
removeObject
public void removeObject(java.lang.Object right, IOAVState state, ReteMemory mem, AbstractAgenda agenda)Remove an object from this node.- Specified by:
removeObjectin interfaceIObjectConsumerNode- Parameters:
object- The object.
-
modifyObject
public void modifyObject(java.lang.Object right, OAVAttributeType type, java.lang.Object oldvalue, java.lang.Object newvalue, IOAVState state, ReteMemory mem, AbstractAgenda agenda)Propagate an object change to this node.- Specified by:
modifyObjectin interfaceIObjectConsumerNode- Parameters:
right- The new object.
-
modifyIndirectObject
public 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 interfaceINode- Parameters:
id- The changed object.
-
setObjectSource
public void setObjectSource(IObjectSourceNode node)
Set the object source of this node.- Specified by:
setObjectSourcein interfaceIObjectConsumerNode- Parameters:
node- The object source node.
-
getObjectSource
public IObjectSourceNode getObjectSource()
Get the object source of this node.- Specified by:
getObjectSourcein interfaceIObjectConsumerNode- Returns:
- The object source node.
-
createNodeMemory
public java.lang.Object createNodeMemory(IOAVState state)
Create the node memory.- Specified by:
createNodeMemoryin interfaceINode- Parameters:
state- The state.- Returns:
- The node memory.
-
getConstraintIndexers
public ConstraintIndexer[] getConstraintIndexers()
Get the indexers.- Returns:
- The indexers.
-
getConstraintEvaluators
public IConstraintEvaluator[] getConstraintEvaluators()
Get the evaluators.- Returns:
- The evaluators.
-
intersection
protected java.util.Collection intersection(IOAVState state, java.util.Collection c1, java.util.Collection c2)
Compute the intersection of two collections.- Parameters:
c1- The first collection.c2- The second collection.- Returns:
- The intersection.
-
identityIntersection
protected java.util.Collection identityIntersection(IOAVState state, java.util.Collection c1, java.util.Collection c2)
Compute the intersection of two collections.- Parameters:
c1- The first collection.c2- The second collection.- Returns:
- The intersection.
-
fetchTupleMemory
protected java.util.Collection fetchTupleMemory(IOAVState state, java.lang.Object right, ReteMemory mem)
Fetch the tuple memory for a given object.- Parameters:
right- The right object.mem- The rete memory.state- The state.- Returns:
- The tuple memory matching that object (or complete).
-
fetchObjectMemory
protected java.util.Collection fetchObjectMemory(IOAVState state, Tuple left, ReteMemory mem)
Fetch the object memory for a given object.- Parameters:
left- The left tuple.value- The hash value (if any).type- The attribute type (if any).tupleindex- The tuple index of the changed object (if any).mem- The rete memory.state- The state.- Returns:
- The tuple memory matching that object (or complete).
-
checkNonindexedConstraints
protected boolean checkNonindexedConstraints(Tuple left, java.lang.Object right, IOAVState state)
Check the non-indexed constraints for the given left/right values.
-
isAffected
public boolean isAffected(OAVAttributeType attr)
Test if the node is affected from a modification.- Parameters:
type- The attribute type.- Returns:
- True, if possibly affected.
-
getRelevantAttributes
public AttributeSet getRelevantAttributes()
Get the set of relevant attribute types.- Specified by:
getRelevantAttributesin interfaceINode
-
getIndirectAttributes
public 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 interfaceINode- Returns:
- The relevant attribute types.
-
doClone
protected void doClone(java.lang.Object theclone)
Do clone makes a deep clone without regarding cycles. Method is overridden by subclasses to actually incorporate their attributes.- Specified by:
doClonein classAbstractNode- Parameters:
theclone- The clone.
-
addMatch
protected abstract void addMatch(Tuple left, java.lang.Object right, IOAVState state, ReteMemory mem, AbstractAgenda agenda)
Add a match to the node memory and propagate if necessary.
-
removeMatch
protected abstract void removeMatch(Tuple left, java.lang.Object right, IOAVState state, ReteMemory mem, AbstractAgenda agenda)
Remove a match from the node memory and propagate if necessary.
-
propagateModification
protected abstract void propagateModification(Tuple left, java.lang.Object right, int tupleindex, OAVAttributeType type, java.lang.Object oldvalue, java.lang.Object newvalue, IOAVState state, ReteMemory mem, AbstractAgenda agenda)
Propagate a change of a tuple in the result memory.
-
isMatchContained
protected abstract boolean isMatchContained(IOAVState state, Tuple left, java.lang.Object right, ReteMemory mem)
Check if a match is contained.
-
-