Class SplitNode
- java.lang.Object
-
- jadex.rules.rulesystem.rete.nodes.AbstractNode
-
- jadex.rules.rulesystem.rete.nodes.SplitNode
-
- All Implemented Interfaces:
INode,IObjectConsumerNode,IObjectSourceNode,java.lang.Cloneable
public class SplitNode extends AbstractNode implements IObjectConsumerNode, IObjectSourceNode
A split node has the purpose of generating virtual facts for multislot bindings that use a non-multi variable or variable patterns.
-
-
Field Summary
Fields Modifier and Type Field Description protected OAVAttributeTypeattrThe values extractor.protected IValueExtractorextractorThe values extractor.protected AttributeSetindirectsThe set of indirect attributes.protected intmin_valuesThe minimum number of required values.static java.lang.StringMULTIThe constant for a multi variable.static java.lang.StringMULTI_DUMMYThe constant for a dummy multi variable.protected IObjectConsumerNode[]oconsumersThe object consumers.protected IObjectSourceNodeosourceThe object source.protected AttributeSetrelevantsThe set of relevant attributes.static java.lang.StringSINGLEThe constant for a single variable.protected java.lang.String[]splitpatternThe splitpattern (multi, single or multi dummy).-
Fields inherited from class jadex.rules.rulesystem.rete.nodes.AbstractNode
clones, nodeid
-
-
Constructor Summary
Constructors Constructor Description SplitNode(int nodeid, IValueExtractor extractor, OAVAttributeType attr, java.lang.String[] splitpattern)Create a new node.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddObject(java.lang.Object object, IOAVState state, ReteMemory mem, AbstractAgenda agenda)Send a new object to this node.voidaddObjectConsumer(IObjectConsumerNode node)Add an object consumer node.protected booleancontains(IOAVState state, java.util.Collection coll, java.lang.Object o)Check if an object is contained in a collection.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 voidgenerateBindings(int weight, int cur, int[] binding, java.lang.Object object, java.lang.Object[] values, java.util.List ret)Generate all possible bindings for a list of values.protected VirtualFactgenerateVirtualFact(java.lang.Object object, int[] binding, java.lang.Object[] values)Generate a virtual fact for a found binding.protected java.util.CollectiongenerateVirtualFacts(java.lang.Object object, IOAVState state)Generate virtual facts.OAVAttributeTypegetAttribute()Get the attribute.AttributeSetgetIndirectAttributes()Get the set of indirect attribute types.java.util.CollectiongetNodeMemory(ReteMemory mem)Get the memory for this node.IObjectConsumerNode[]getObjectConsumers()Get all object consumer nodes.IObjectSourceNodegetObjectSource()Get the object source of this node.AttributeSetgetRelevantAttributes()Get the set of relevant attribute types.java.lang.String[]getSplitPattern()Get the split pattern.booleanisAffected(OAVAttributeType attr)Test if the node is affected from a modification.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 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 voidpropagateAdditionToObjectConsumers(java.lang.Object object, IOAVState state, ReteMemory mem, AbstractAgenda agenda)Propagate a new object to all object consumers.protected voidpropagateModificationToObjectConsumers(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 voidpropagateRemovalToObjectConsumers(java.lang.Object object, IOAVState state, ReteMemory mem, AbstractAgenda agenda)Propagate a removed object to all object consumers.voidremoveObject(java.lang.Object object, IOAVState state, ReteMemory mem, AbstractAgenda agenda)Send a removed object to this node.voidremoveObjectConsumer(IObjectConsumerNode node)Remove an object consumer.voidsetObjectSource(IObjectSourceNode node)Set the object source of this node.java.lang.StringtoString()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
-
MULTI
public static final java.lang.String MULTI
The constant for a multi variable.- See Also:
- Constant Field Values
-
SINGLE
public static final java.lang.String SINGLE
The constant for a single variable.- See Also:
- Constant Field Values
-
MULTI_DUMMY
public static final java.lang.String MULTI_DUMMY
The constant for a dummy multi variable.- See Also:
- Constant Field Values
-
osource
protected IObjectSourceNode osource
The object source.
-
oconsumers
protected IObjectConsumerNode[] oconsumers
The object consumers.
-
relevants
protected volatile AttributeSet relevants
The set of relevant attributes.
-
indirects
protected volatile AttributeSet indirects
The set of indirect attributes.
-
attr
protected OAVAttributeType attr
The values extractor.
-
extractor
protected IValueExtractor extractor
The values extractor.
-
splitpattern
protected java.lang.String[] splitpattern
The splitpattern (multi, single or multi dummy).
-
min_values
protected int min_values
The minimum number of required values.
-
-
Constructor Detail
-
SplitNode
public SplitNode(int nodeid, IValueExtractor extractor, OAVAttributeType attr, java.lang.String[] splitpattern)Create a new node.- Parameters:
state- The state.
-
-
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:
addObjectin 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:
removeObjectin 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:
modifyObjectin interfaceIObjectConsumerNode- Parameters:
object- 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:
object- 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.
-
addObjectConsumer
public void addObjectConsumer(IObjectConsumerNode node)
Add an object consumer node.- Specified by:
addObjectConsumerin interfaceIObjectSourceNode- Parameters:
node- A new consumer node.
-
removeObjectConsumer
public void removeObjectConsumer(IObjectConsumerNode node)
Remove an object consumer.- Specified by:
removeObjectConsumerin interfaceIObjectSourceNode- 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 interfaceIObjectSourceNode- Returns:
- The memory.
-
getObjectConsumers
public IObjectConsumerNode[] getObjectConsumers()
Get all object consumer nodes.- Specified by:
getObjectConsumersin interfaceIObjectSourceNode- Returns:
- All object consumer nodes.
-
createNodeMemory
public java.lang.Object createNodeMemory(IOAVState state)
Create the node memory.- Specified by:
createNodeMemoryin 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.
-
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- Returns:
- The relevant attribute types.
-
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.
-
getAttribute
public OAVAttributeType getAttribute()
Get the attribute.- Returns:
- The attribute.
-
generateVirtualFacts
protected java.util.Collection generateVirtualFacts(java.lang.Object object, IOAVState state)Generate virtual facts.- Parameters:
object- The object.state- The state.
-
generateBindings
protected void generateBindings(int weight, int cur, int[] binding, java.lang.Object object, java.lang.Object[] values, java.util.List ret)Generate all possible bindings for a list of values.- Parameters:
weight- The number of values to distribute on variables.cur- The current variable number.binding- Results are stored in this binding array (contains for each variable how many values it should store).values- The values to distribute.ret- The result list containing all found bindings (in form of virtual facts).
-
generateVirtualFact
protected VirtualFact generateVirtualFact(java.lang.Object object, int[] binding, java.lang.Object[] values)
Generate a virtual fact for a found binding.- Parameters:
binding- The number of values for each variable.values- The multislot values.- Returns:
- A virtual fact with one binding.
-
getSplitPattern
public java.lang.String[] getSplitPattern()
Get the split pattern.
-
toString
public java.lang.String toString()
Get the string representation.- Overrides:
toStringin classAbstractNode- Returns:
- The string representation.
-
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.
-
contains
protected boolean contains(IOAVState state, java.util.Collection coll, java.lang.Object o)
Check if an object is contained in a collection. Avoid the need for an "IdentityArrayList".
-
-