Class AlphaNode
- java.lang.Object
-
- jadex.rules.rulesystem.rete.nodes.AbstractNode
-
- jadex.rules.rulesystem.rete.nodes.AlphaNode
-
- All Implemented Interfaces:
INode
,IObjectConsumerNode
,IObjectSourceNode
,java.lang.Cloneable
- Direct Known Subclasses:
TypeNode
public class AlphaNode extends AbstractNode implements IObjectConsumerNode, IObjectSourceNode
An alpha node is a 1-input -> 1-output node which propagates objects matching its constraints.
-
-
Field Summary
Fields Modifier and Type Field Description protected IConstraintEvaluator[]
evaluators
The constraint evaluator.protected AttributeSet
indirects
The set of indirect attributes.protected IObjectConsumerNode[]
oconsumers
The object consumers.protected IObjectSourceNode
osource
The object source.protected AttributeSet
relevants
The set of relevant attributes.-
Fields inherited from class jadex.rules.rulesystem.rete.nodes.AbstractNode
clones, nodeid
-
-
Constructor Summary
Constructors Constructor Description AlphaNode(int nodeid, IConstraintEvaluator[] evaluators)
Create a new node.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addObject(java.lang.Object object, IOAVState state, ReteMemory mem, AbstractAgenda agenda)
Send a new object to this node.void
addObjectConsumer(IObjectConsumerNode node)
Add an object consumer node.protected boolean
checkConstraints(java.lang.Object right, IOAVState state)
Check the constraints with respect to the object.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 constraint evaluators.AttributeSet
getIndirectAttributes()
Get the set of indirect attribute types.java.util.Collection
getNodeMemory(ReteMemory mem)
Get the memory for this node.IObjectConsumerNode[]
getObjectConsumers()
Get all object consumer nodes.IObjectSourceNode
getObjectSource()
Get the object source of this node.AttributeSet
getRelevantAttributes()
Get the set of relevant attribute types.boolean
isAffected(OAVAttributeType attr)
Test if the node is affected from a modification.void
modifyIndirectObject(java.lang.Object id, 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 object, OAVAttributeType type, java.lang.Object oldvalue, java.lang.Object newvalue, IOAVState state, ReteMemory mem, AbstractAgenda agenda)
Propagate an object change to this node.protected void
propagateAdditionToObjectConsumers(java.lang.Object object, IOAVState state, ReteMemory mem, AbstractAgenda agenda)
Propagate a new object to all object consumers.protected void
propagateModificationToObjectConsumers(java.lang.Object object, 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
propagateRemovalToObjectConsumers(java.lang.Object object, IOAVState state, ReteMemory mem, AbstractAgenda agenda)
Propagate a removed object to all object consumers.void
removeObject(java.lang.Object object, IOAVState state, ReteMemory mem, AbstractAgenda agenda)
Send a removed object to this node.void
removeObjectConsumer(IObjectConsumerNode node)
Remove an object consumer.void
setObjectSource(IObjectSourceNode node)
Set the object source of this node.java.lang.String
toString()
Get the string representation.-
Methods inherited from class jadex.rules.rulesystem.rete.nodes.AbstractNode
checkNodeConsistency, clone, equals, getNodeId, hashCode, 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
-
osource
protected IObjectSourceNode osource
The object source.
-
oconsumers
protected IObjectConsumerNode[] oconsumers
The object consumers.
-
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.
-
-
Constructor Detail
-
AlphaNode
public AlphaNode(int nodeid, IConstraintEvaluator[] evaluators)
Create a new node.- Parameters:
evaluators
- The evaluators.
-
-
Method Detail
-
addObject
public void addObject(java.lang.Object object, IOAVState state, ReteMemory mem, AbstractAgenda agenda)
Send a new object to this node.- Specified by:
addObject
in interfaceIObjectConsumerNode
- Parameters:
object
- The object.
-
removeObject
public void removeObject(java.lang.Object object, IOAVState state, ReteMemory mem, AbstractAgenda agenda)
Send a removed object to this node.- Specified by:
removeObject
in interfaceIObjectConsumerNode
- Parameters:
object
- The object.
-
modifyObject
public void modifyObject(java.lang.Object object, 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:
object
- The new object.
-
modifyIndirectObject
public void modifyIndirectObject(java.lang.Object id, 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.
-
addObjectConsumer
public void addObjectConsumer(IObjectConsumerNode node)
Add an object consumer node.- Specified by:
addObjectConsumer
in interfaceIObjectSourceNode
- Parameters:
node
- A new consumer node.
-
removeObjectConsumer
public void removeObjectConsumer(IObjectConsumerNode node)
Remove an object consumer.- Specified by:
removeObjectConsumer
in interfaceIObjectSourceNode
- 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 interfaceIObjectSourceNode
- Returns:
- The memory.
-
getObjectConsumers
public IObjectConsumerNode[] getObjectConsumers()
Get all object consumer nodes.- Specified by:
getObjectConsumers
in interfaceIObjectSourceNode
- Returns:
- All object consumer nodes.
-
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.
-
propagateAdditionToObjectConsumers
protected void propagateAdditionToObjectConsumers(java.lang.Object object, IOAVState state, ReteMemory mem, AbstractAgenda agenda)
Propagate a new object to all object consumers.- Parameters:
object
- The new object.
-
propagateRemovalToObjectConsumers
protected void propagateRemovalToObjectConsumers(java.lang.Object object, IOAVState state, ReteMemory mem, AbstractAgenda agenda)
Propagate a removed object to all object consumers.- Parameters:
object
- The new object.
-
propagateModificationToObjectConsumers
protected void propagateModificationToObjectConsumers(java.lang.Object object, 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.
-
checkConstraints
protected boolean checkConstraints(java.lang.Object right, IOAVState state)
Check the constraints with respect to the object.- Returns:
- True, if object fits constraints.
-
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.
-
toString
public java.lang.String toString()
Get the string representation.- Overrides:
toString
in classAbstractNode
- Returns:
- The string representation.
-
getConstraintEvaluators
public IConstraintEvaluator[] getConstraintEvaluators()
Get the constraint evaluators.
-
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.
-
-