Class CollectNode
- java.lang.Object
-
- jadex.rules.rulesystem.rete.nodes.AbstractNode
-
- jadex.rules.rulesystem.rete.nodes.CollectNode
-
- All Implemented Interfaces:
INode
,ITupleConsumerNode
,ITupleSourceNode
,java.lang.Cloneable
public class CollectNode extends AbstractNode implements ITupleConsumerNode, ITupleSourceNode
The purpose of a collect node is to compress a number of tuples to a new tuple, which contains a multi slot. Example: Incoming tuples are: [a, b, d1] [a, b, d2] [a, c, d3] [a, c, d1] -> [a, b, {d1, d2}] [a, c, {d3, d1}]
-
-
Field Summary
Fields Modifier and Type Field Description protected IConstraintEvaluator[]
evaluators
The constraint evaluator.protected AttributeSet
indirects
The set of indirect attributes.protected AttributeSet
relevants
The set of relevant attributes.protected ITupleConsumerNode[]
tconsumers
The tuple consumers.protected ITupleSourceNode
tsource
The tuple source.protected int
tupleindex
The tuple index to collect.-
Fields inherited from class jadex.rules.rulesystem.rete.nodes.AbstractNode
clones, nodeid
-
-
Constructor Summary
Constructors Constructor Description CollectNode(int nodeid, int tupleindex, IConstraintEvaluator[] evaluators)
Create a new beta node.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
checkConstraints(Tuple left, IOAVState state)
Check the constraints with respect to the object.protected Tuple
createIndexTuple(IOAVState state, Tuple tuple, ReteMemory mem)
Create an index tuple from a tuple.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.IConstraintEvaluator[]
getConstraintEvaluators()
Get the evaluators.AttributeSet
getIndirectAttributes()
Get the set of indirect attribute types.java.util.Collection
getNodeMemory(ReteMemory mem)
Get the memory for this node.AttributeSet
getRelevantAttributes()
Get the set of relevant attribute types.ITupleConsumerNode[]
getTupleConsumers()
Get all tuple consumer nodes.int
getTupleIndex()
Get the tuple index.ITupleSourceNode
getTupleSource()
Get the tuple source of this node.boolean
isAffected(OAVAttributeType attr)
Test if the node is affected from a modification.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
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 void
propagateAdditionToTupleConsumers(Tuple tuple, IOAVState state, ReteMemory mem, AbstractAgenda agenda)
Propagate a new tuple to all tuple consumers.protected void
propagateModificationToTupleConsumers(Tuple tuple, OAVAttributeType type, java.lang.Object oldvalue, java.lang.Object newvalue, IOAVState state, ReteMemory mem, AbstractAgenda agenda)
Propagate a modified object to all object consumers.protected void
propagateRemovalToTupleConsumers(Tuple tuple, IOAVState state, ReteMemory mem, AbstractAgenda agenda)
Propagate a removed tuple to all tuple consumers.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
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.
-
tsource
protected ITupleSourceNode tsource
The tuple source.
-
evaluators
protected IConstraintEvaluator[] evaluators
The constraint evaluator.
-
relevants
protected volatile AttributeSet relevants
The set of relevant attributes.
-
indirects
protected volatile AttributeSet indirects
The set of indirect attributes.
-
tupleindex
protected int tupleindex
The tuple index to collect.
-
-
Constructor Detail
-
CollectNode
public CollectNode(int nodeid, int tupleindex, IConstraintEvaluator[] evaluators)
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.
-
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:
object
- The changed object.
-
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.
-
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.
-
getConstraintEvaluators
public IConstraintEvaluator[] getConstraintEvaluators()
Get the evaluators.- Returns:
- The evaluators.
-
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.
-
getTupleIndex
public int getTupleIndex()
Get the tuple index.- Returns:
- The tuple index.
-
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.
-
checkConstraints
protected boolean checkConstraints(Tuple left, IOAVState state)
Check the constraints with respect to the object.- Returns:
- True, if object fits constraints.
-
createIndexTuple
protected Tuple createIndexTuple(IOAVState state, Tuple tuple, ReteMemory mem)
Create an index tuple from a tuple. The index tuple excludes the index position at which the compression happens (and all elements thereafter -> why, could be the last node?).- Parameters:
tuple
- The tuple.- Returns:
- The index tuple.
-
propagateAdditionToTupleConsumers
protected void propagateAdditionToTupleConsumers(Tuple tuple, IOAVState state, ReteMemory mem, AbstractAgenda agenda)
Propagate a new tuple to all tuple consumers.- Parameters:
object
- The new object.
-
propagateRemovalToTupleConsumers
protected void propagateRemovalToTupleConsumers(Tuple tuple, IOAVState state, ReteMemory mem, AbstractAgenda agenda)
Propagate a removed tuple to all tuple consumers.- Parameters:
object
- The new object.
-
propagateModificationToTupleConsumers
protected void propagateModificationToTupleConsumers(Tuple tuple, OAVAttributeType type, java.lang.Object oldvalue, java.lang.Object newvalue, IOAVState state, ReteMemory mem, AbstractAgenda agenda)
Propagate a modified object to all object consumers.- Parameters:
object
- The new object.
-
-