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 OAVAttributeType
attr
The values extractor.protected IValueExtractor
extractor
The values extractor.protected AttributeSet
indirects
The set of indirect attributes.protected int
min_values
The minimum number of required values.static java.lang.String
MULTI
The constant for a multi variable.static java.lang.String
MULTI_DUMMY
The constant for a dummy multi variable.protected IObjectConsumerNode[]
oconsumers
The object consumers.protected IObjectSourceNode
osource
The object source.protected AttributeSet
relevants
The set of relevant attributes.static java.lang.String
SINGLE
The constant for a single variable.protected java.lang.String[]
splitpattern
The 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 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
contains(IOAVState state, java.util.Collection coll, java.lang.Object o)
Check if an object is contained in a collection.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 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.protected VirtualFact
generateVirtualFact(java.lang.Object object, int[] binding, java.lang.Object[] values)
Generate a virtual fact for a found binding.protected java.util.Collection
generateVirtualFacts(java.lang.Object object, IOAVState state)
Generate virtual facts.OAVAttributeType
getAttribute()
Get the attribute.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.java.lang.String[]
getSplitPattern()
Get the split pattern.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
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
-
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:
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 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.
-
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.
-
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
- 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:
getIndirectAttributes
in 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:
toString
in 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:
doClone
in 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".
-
-