/** * Propagate a new object to all object consumers. * @param object The new object. */ protected void propagateAdditionToObjectConsumers(Object object, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { IObjectConsumerNode[] ocon = oconsumers; for(int i=0; ocon!=null && i<ocon.length; i++) ocon[i].addObject(object, state, mem, agenda); }
/** * Propagate a modified object to all object consumers. * @param object The new object. */ protected void propagateModificationToObjectConsumers(Object object, OAVAttributeType type, Object oldvalue, Object newvalue, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { IObjectConsumerNode[] ocon = oconsumers; for(int i=0; ocon!=null && i<ocon.length; i++) ocon[i].modifyObject(object, type, oldvalue, newvalue, state, mem, agenda); }
/** * Propagate a removed object to all object consumers. * @param object The new object. */ protected void propagateRemovalToObjectConsumers(Object object, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { IObjectConsumerNode[] ocon = oconsumers; for(int i=0; ocon!=null && i<ocon.length; i++) ocon[i].removeObject(object, state, mem, agenda); }
test.add(((ITupleConsumerNode)test.get(i)).getTupleSource()); if(test.get(i) instanceof IObjectConsumerNode) test.add(((IObjectConsumerNode)test.get(i)).getObjectSource()); c.setObjectSource(s); oconsumer.setObjectSource(ria);
/** * Check the consistency of the node. */ public boolean checkNodeConsistency(ReteMemory mem) { // Mark node as checked (for debugging). Object node = this; while(!(node instanceof ReteNode)) { if(node instanceof IObjectConsumerNode) { node = ((IObjectConsumerNode)node).getObjectSource(); } else if(node instanceof ITupleConsumerNode) { node = ((ITupleConsumerNode)node).getTupleSource(); } else { throw new RuntimeException("Unhandled node type: "+node); } } ((ReteNode)node).checked.add(this); // Empty default implementation. return true; } }
/** * Do clone makes a deep clone without regarding cycles. * Method is overridden by subclasses to actually incorporate their attributes. * @param theclone The clone. */ protected void doClone(Object theclone) { RightInputAdapterNode clone = (RightInputAdapterNode)theclone; // Deep clone tuple consumers clone.oconsumers = new IObjectConsumerNode[oconsumers.length]; for(int i=0; i<oconsumers.length; i++) clone.oconsumers[i] = (IObjectConsumerNode)oconsumers[i].clone(); // Set the source clone.tsource = (ITupleSourceNode)tsource.clone(); // Shallow copy the relevant attributes if(relevants!=null) clone.relevants = (AttributeSet)((AttributeSet)relevants).clone(); } }
/** * Get the set of relevant attribute types. */ public AttributeSet getRelevantAttributes() { if(relevants==null) { synchronized(this) { if(relevants==null) { AttributeSet relevants = new AttributeSet(); for(int i=0; oconsumers!=null && i<oconsumers.length; i++) { relevants.addAll(oconsumers[i].getRelevantAttributes()); } this.relevants = relevants; } } } return relevants; }
test.add(((ITupleConsumerNode)test.get(i)).getTupleSource()); if(test.get(i) instanceof IObjectConsumerNode) test.add(((IObjectConsumerNode)test.get(i)).getObjectSource()); c.setObjectSource(s); oconsumer.setObjectSource(ria);
/** * Check the consistency of the node. */ public boolean checkNodeConsistency(ReteMemory mem) { // Mark node as checked (for debugging). Object node = this; while(!(node instanceof ReteNode)) { if(node instanceof IObjectConsumerNode) { node = ((IObjectConsumerNode)node).getObjectSource(); } else if(node instanceof ITupleConsumerNode) { node = ((ITupleConsumerNode)node).getTupleSource(); } else { throw new RuntimeException("Unhandled node type: "+node); } } ((ReteNode)node).checked.add(this); // Empty default implementation. return true; } }
/** * Do clone makes a deep clone without regarding cycles. * Method is overridden by subclasses to actually incorporate their attributes. * @param theclone The clone. */ protected void doClone(Object theclone) { RightInputAdapterNode clone = (RightInputAdapterNode)theclone; // Deep clone tuple consumers clone.oconsumers = new IObjectConsumerNode[oconsumers.length]; for(int i=0; i<oconsumers.length; i++) clone.oconsumers[i] = (IObjectConsumerNode)oconsumers[i].clone(); // Set the source clone.tsource = (ITupleSourceNode)tsource.clone(); // Shallow copy the relevant attributes if(relevants!=null) clone.relevants = (AttributeSet)((AttributeSet)relevants).clone(); } }
/** * Get the set of relevant attribute types. */ public AttributeSet getRelevantAttributes() { if(relevants==null) { synchronized(this) { if(relevants==null) { AttributeSet relevants = new AttributeSet(); for(int i=0; oconsumers!=null && i<oconsumers.length; i++) { relevants.addAll(oconsumers[i].getRelevantAttributes()); } this.relevants = relevants; } } } return relevants; }
IObjectSourceNode source = consumer.getObjectSource(); consumer.setObjectSource(null); source.removeObjectConsumer(consumer); removeNodeUsage(source);
/** * Check the consistency of the node. */ public boolean checkNodeConsistency(ReteMemory mem) { boolean consistent = true; Collection tuples = getNodeMemory(mem); Collection objects = getObjectSource().getNodeMemory(mem); if(tuples!=null) { for(Iterator it=tuples.iterator(); consistent && it.hasNext(); ) { Tuple tuple = (Tuple)it.next(); consistent = objects.contains(tuple.getObject()); } } Object node = this; while(node instanceof IObjectConsumerNode) node = ((IObjectConsumerNode)node).getObjectSource(); ((ReteNode)node).checked.add(this); return consistent; } }
/** * Add a new tuple to this node. * @param tuple The tuple. */ public void addTuple(Tuple tuple, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { // Propagate tuple as object. IObjectConsumerNode[] ocs = oconsumers; for(int j=0; ocs!=null && j<ocs.length; j++) ocs[j].addObject(tuple, state, mem, agenda); }
/** * Remove a tuple from this node. * @param tuple The tuple. */ public void removeTuple(Tuple tuple, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { // Propagate tuple as object. IObjectConsumerNode[] ocs = oconsumers; for(int j=0; ocs!=null && j<ocs.length; j++) ocs[j].removeObject(tuple, state, mem, agenda); }
/** * Propagate a modified object to all object consumers. * @param object The new object. */ protected void propagateModificationToObjectConsumers(Object object, OAVAttributeType type, Object oldvalue, Object newvalue, IOAVState state, ReteMemory mem, AbstractAgenda agenda) { IObjectConsumerNode[] ocon = oconsumers; for(int i=0; ocon!=null && i<ocon.length; i++) ocon[i].modifyObject(object, type, oldvalue, newvalue, state, mem, agenda); }
/** * Do clone makes a deep clone without regarding cycles. * Method is overridden by subclasses to actually incorporate their attributes. * @param theclone The clone. */ protected void doClone(Object theclone) { SplitNode ret = (SplitNode)theclone; // Deep clone tuple consumers ret.oconsumers = new IObjectConsumerNode[oconsumers.length]; for(int i=0; i<oconsumers.length; i++) ret.oconsumers[i] = (IObjectConsumerNode)oconsumers[i].clone(); // Don't change the source, will be done by the source ret.osource = (IObjectSourceNode)osource.clone(); // Shallow copy the relevant attributes if(relevants!=null) ret.relevants = (AttributeSet)((AttributeSet)relevants).clone(); // Keep extractor // Keep the attribute // Keep the split pattern // Keep the min_values }
/** * Get the set of relevant attribute types. * @return The relevant attribute types. */ public AttributeSet getRelevantAttributes() { if(relevants==null) { synchronized(this) { if(relevants==null) { AttributeSet relevants = new AttributeSet(); relevants.addAll(extractor.getRelevantAttributes()); for(int i=0; oconsumers!=null && i<oconsumers.length; i++) { relevants.addAll(oconsumers[i].getRelevantAttributes()); } this.relevants = relevants; } } } return relevants; }
IObjectSourceNode source = consumer.getObjectSource(); consumer.setObjectSource(null); source.removeObjectConsumer(consumer); removeNodeUsage(source);
/** * Check the consistency of the node. */ public boolean checkNodeConsistency(ReteMemory mem) { boolean consistent = true; Collection tuples = getNodeMemory(mem); Collection objects = getObjectSource().getNodeMemory(mem); if(tuples!=null) { for(Iterator it=tuples.iterator(); consistent && it.hasNext(); ) { Tuple tuple = (Tuple)it.next(); consistent = objects.contains(tuple.getObject()); } } Object node = this; while(node instanceof IObjectConsumerNode) node = ((IObjectConsumerNode)node).getObjectSource(); ((ReteNode)node).checked.add(this); return consistent; } }