001: package org.drools.reteoo;
002:
003: /*
004: * Copyright 2005 JBoss Inc
005: *
006: * Licensed under the Apache License, Version 2.0 (the "License");
007: * you may not use this file except in compliance with the License.
008: * You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing, software
013: * distributed under the License is distributed on an "AS IS" BASIS,
014: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: import java.util.ArrayList;
020: import java.util.Collections;
021: import java.util.HashMap;
022: import java.util.List;
023:
024: import org.drools.FactException;
025: import org.drools.RuleBaseConfiguration;
026: import org.drools.common.BaseNode;
027: import org.drools.common.InternalWorkingMemory;
028: import org.drools.common.NodeMemory;
029: import org.drools.spi.PropagationContext;
030:
031: public class MockTupleSink extends TupleSource implements
032: TupleSinkNode, NodeMemory {
033: /**
034: *
035: */
036: private static final long serialVersionUID = 400L;
037: private final List asserted = new ArrayList();
038: private final List retracted = new ArrayList();
039:
040: private TupleSinkNode previousTupleSinkNode;
041: private TupleSinkNode nextTupleSinkNode;
042:
043: public MockTupleSink() {
044: super (0);
045: }
046:
047: public MockTupleSink(final int id) {
048: super (id);
049: }
050:
051: public void assertTuple(final ReteTuple tuple,
052: final PropagationContext context,
053: final InternalWorkingMemory workingMemory) {
054: this .asserted
055: .add(new Object[] { tuple, context, workingMemory });
056:
057: }
058:
059: public void retractTuple(final ReteTuple tuple,
060: final PropagationContext context,
061: final InternalWorkingMemory workingMemory) {
062: this .retracted
063: .add(new Object[] { tuple, context, workingMemory });
064:
065: }
066:
067: public List getAsserted() {
068: return this .asserted;
069: }
070:
071: public List getRetracted() {
072: return this .retracted;
073: }
074:
075: public void ruleAttached() {
076: // TODO Auto-generated method stub
077: }
078:
079: public void setHasMemory(final boolean hasMemory) {
080: this .hasMemory = hasMemory;
081: }
082:
083: public int getId() {
084: return this .id;
085: }
086:
087: public Object createMemory(final RuleBaseConfiguration config) {
088: return new HashMap();
089: }
090:
091: public void attach() {
092: // TODO Auto-generated method stub
093:
094: }
095:
096: public void updateSink(final TupleSink sink,
097: final PropagationContext context,
098: final InternalWorkingMemory workingMemory)
099: throws FactException {
100: // TODO Auto-generated method stub
101:
102: }
103:
104: public void remove(final BaseNode node,
105: final InternalWorkingMemory[] workingMemories) {
106: // TODO Auto-generated method stub
107:
108: }
109:
110: public void attach(final InternalWorkingMemory[] workingMemories) {
111: // TODO Auto-generated method stub
112:
113: }
114:
115: public List getPropagatedTuples(
116: final ReteooWorkingMemory workingMemory,
117: final TupleSink sink) {
118: // TODO Auto-generated method stub
119: return Collections.EMPTY_LIST;
120: }
121:
122: /**
123: * Returns the next node
124: * @return
125: * The next TupleSinkNode
126: */
127: public TupleSinkNode getNextTupleSinkNode() {
128: return this .nextTupleSinkNode;
129: }
130:
131: /**
132: * Sets the next node
133: * @param next
134: * The next TupleSinkNode
135: */
136: public void setNextTupleSinkNode(final TupleSinkNode next) {
137: this .nextTupleSinkNode = next;
138: }
139:
140: /**
141: * Returns the previous node
142: * @return
143: * The previous TupleSinkNode
144: */
145: public TupleSinkNode getPreviousTupleSinkNode() {
146: return this .previousTupleSinkNode;
147: }
148:
149: /**
150: * Sets the previous node
151: * @param previous
152: * The previous TupleSinkNode
153: */
154: public void setPreviousTupleSinkNode(final TupleSinkNode previous) {
155: this.previousTupleSinkNode = previous;
156: }
157:
158: }
|