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[]
evaluators
The constraint evaluator.protected ConstraintIndexer[]
indexers
The indexed constraint indexers.protected AttributeSet
indirects
The set of indirect attributes.protected IObjectSourceNode
osource
The object source.protected AttributeSet
relevants
The set of relevant attributes.protected ITupleConsumerNode[]
tconsumers
The tuple consumers.protected ITupleSourceNode
tsource
The 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 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.void
addObject(java.lang.Object right, IOAVState state, ReteMemory mem, AbstractAgenda agenda)
Send an object to this node.void
addTuple(Tuple left, IOAVState state, ReteMemory mem, AbstractAgenda agenda)
Send a tuple to this node.void
addTupleConsumer(ITupleConsumerNode node)
Add an tuple consumer node.protected boolean
checkNonindexedConstraints(Tuple left, java.lang.Object right, IOAVState state)
Check the non-indexed constraints for the given left/right values.java.lang.Object
createNodeMemory(IOAVState state)
Create the node memory.protected void
doClone(java.lang.Object theclone)
Do clone makes a deep clone without regarding cycles.protected java.util.Collection
fetchObjectMemory(IOAVState state, Tuple left, ReteMemory mem)
Fetch the object memory for a given object.protected java.util.Collection
fetchTupleMemory(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.AttributeSet
getIndirectAttributes()
Get the set of indirect attribute types.java.util.Collection
getNodeMemory(ReteMemory mem)
Get the memory for this node.IObjectSourceNode
getObjectSource()
Get the object source of this node.AttributeSet
getRelevantAttributes()
Get the set of relevant attribute types.ITupleConsumerNode[]
getTupleConsumers()
Get all tuple consumer nodes.ITupleSourceNode
getTupleSource()
Get the tuple source of this node.protected java.util.Collection
identityIntersection(IOAVState state, java.util.Collection c1, java.util.Collection c2)
Compute the intersection of two collections.protected java.util.Collection
intersection(IOAVState state, java.util.Collection c1, java.util.Collection c2)
Compute the intersection of two collections.boolean
isAffected(OAVAttributeType attr)
Test if the node is affected from a modification.protected abstract boolean
isMatchContained(IOAVState state, Tuple left, java.lang.Object right, ReteMemory mem)
Check if a match is contained.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.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.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.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.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.void
removeObject(java.lang.Object right, IOAVState state, ReteMemory mem, AbstractAgenda agenda)
Remove an object from this node.void
removeTuple(Tuple left, IOAVState state, ReteMemory mem, AbstractAgenda agenda)
Remove a tuple from this node.void
removeTupleConsumer(ITupleConsumerNode node)
Remove an tuple consumer.void
setObjectSource(IObjectSourceNode node)
Set the object source of this node.void
setTupleSource(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:
addTupleConsumer
in interfaceITupleSourceNode
- Parameters:
node
- A new consumer node.
-
removeTupleConsumer
public void removeTupleConsumer(ITupleConsumerNode node)
Remove an tuple consumer.- Specified by:
removeTupleConsumer
in interfaceITupleSourceNode
- Parameters:
node
- The consumer node.
-
getNodeMemory
public java.util.Collection getNodeMemory(ReteMemory mem)
Get the memory for this node.- Specified by:
getNodeMemory
in interfaceINode
- Specified by:
getNodeMemory
in interfaceITupleSourceNode
- Returns:
- The memory.
-
getTupleConsumers
public ITupleConsumerNode[] getTupleConsumers()
Get all tuple consumer nodes.- Specified by:
getTupleConsumers
in 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:
addTuple
in 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:
removeTuple
in 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:
modifyTuple
in interfaceITupleConsumerNode
- Parameters:
left
- The tuple.
-
setTupleSource
public void setTupleSource(ITupleSourceNode node)
Set the tuple source of this node.- Specified by:
setTupleSource
in interfaceITupleConsumerNode
- Parameters:
node
- The tuple source node.
-
getTupleSource
public ITupleSourceNode getTupleSource()
Get the tuple source of this node.- Specified by:
getTupleSource
in 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:
addObject
in 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:
removeObject
in 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:
modifyObject
in 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:
modifyIndirectObject
in interfaceINode
- Parameters:
id
- The changed object.
-
setObjectSource
public void setObjectSource(IObjectSourceNode node)
Set the object source of this node.- Specified by:
setObjectSource
in interfaceIObjectConsumerNode
- Parameters:
node
- The object source node.
-
getObjectSource
public IObjectSourceNode getObjectSource()
Get the object source of this node.- Specified by:
getObjectSource
in interfaceIObjectConsumerNode
- Returns:
- The object source node.
-
createNodeMemory
public java.lang.Object createNodeMemory(IOAVState state)
Create the node memory.- Specified by:
createNodeMemory
in 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:
getRelevantAttributes
in 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:
getIndirectAttributes
in 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:
doClone
in 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.
-
-