01: package org.drools.reteoo;
02:
03: import org.drools.common.InternalFactHandle;
04: import org.drools.common.InternalWorkingMemory;
05: import org.drools.spi.PropagationContext;
06:
07: public class SingleTupleSinkAdapter implements TupleSinkPropagator {
08: private TupleSink sink;
09:
10: public SingleTupleSinkAdapter(final TupleSink sink) {
11: this .sink = sink;
12: }
13:
14: public void propagateAssertTuple(final ReteTuple tuple,
15: final InternalFactHandle handle,
16: final PropagationContext context,
17: final InternalWorkingMemory workingMemory) {
18: this .sink.assertTuple(new ReteTuple(tuple, handle), context,
19: workingMemory);
20: }
21:
22: public void propagateAssertTuple(final ReteTuple tuple,
23: final PropagationContext context,
24: final InternalWorkingMemory workingMemory) {
25: this .sink.assertTuple(new ReteTuple(tuple), context,
26: workingMemory);
27: }
28:
29: public void propagateRetractTuple(final ReteTuple tuple,
30: final InternalFactHandle handle,
31: final PropagationContext context,
32: final InternalWorkingMemory workingMemory) {
33: this .sink.retractTuple(new ReteTuple(tuple, handle), context,
34: workingMemory);
35: }
36:
37: public void propagateRetractTuple(final ReteTuple tuple,
38: final PropagationContext context,
39: final InternalWorkingMemory workingMemory) {
40: this .sink.retractTuple(new ReteTuple(tuple), context,
41: workingMemory);
42: }
43:
44: public void createAndPropagateAssertTuple(
45: final InternalFactHandle handle,
46: final PropagationContext context,
47: final InternalWorkingMemory workingMemory) {
48: this .sink.assertTuple(new ReteTuple(handle), context,
49: workingMemory);
50: }
51:
52: public void createAndPropagateRetractTuple(
53: final InternalFactHandle handle,
54: final PropagationContext context,
55: final InternalWorkingMemory workingMemory) {
56: this .sink.retractTuple(new ReteTuple(handle), context,
57: workingMemory);
58: }
59:
60: public TupleSink[] getSinks() {
61: return new TupleSink[] { this .sink };
62: }
63:
64: public int size() {
65: return (this .sink != null) ? 1 : 0;
66: }
67: }
|