View Javadoc
1 package org.drools.reteoo.impl; 2 3 /* 4 $Id: JoinNodeInput.java,v 1.5 2002/08/27 23:57:45 bob Exp $ 5 6 Copyright 2002 (C) The Werken Company. All Rights Reserved. 7 8 Redistribution and use of this software and associated documentation 9 ("Software"), with or without modification, are permitted provided 10 that the following conditions are met: 11 12 1. Redistributions of source code must retain copyright 13 statements and notices. Redistributions must also contain a 14 copy of this document. 15 16 2. Redistributions in binary form must reproduce the 17 above copyright notice, this list of conditions and the 18 following disclaimer in the documentation and/or other 19 materials provided with the distribution. 20 21 3. The name "drools" must not be used to endorse or promote 22 products derived from this Software without prior written 23 permission of The Werken Company. For written permission, 24 please contact bob@werken.com. 25 26 4. Products derived from this Software may not be called "drools" 27 nor may "drools" appear in their names without prior written 28 permission of The Werken Company. "drools" is a registered 29 trademark of The Werken Company. 30 31 5. Due credit should be given to The Werken Company. 32 (http://drools.werken.com/). 33 34 THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS 35 ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT 36 NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 37 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 38 THE WERKEN COMPANY OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 39 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 40 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 41 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 42 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 43 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 44 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 45 OF THE POSSIBILITY OF SUCH DAMAGE. 46 47 */ 48 49 import org.drools.WorkingMemory; 50 import org.drools.AssertionException; 51 import org.drools.RetractionException; 52 import org.drools.FactException; 53 54 /*** Input <code>TupleSinkImpl</code> for a <code>JoinNodeImpl</code>. 55 * 56 * @see JoinNodeImpl 57 * 58 * @author <a href="mailto:bob@eng.werken.com">bob mcwhirter</a> 59 */ 60 class JoinNodeInput implements TupleSinkImpl 61 { 62 // ------------------------------------------------------------ 63 // Constants 64 // ------------------------------------------------------------ 65 66 /*** Left-side input. */ 67 static final int LEFT = 41; 68 69 /*** Right-side input. */ 70 static final int RIGHT = 42; 71 72 // ------------------------------------------------------------ 73 // Instance members 74 // ------------------------------------------------------------ 75 76 /*** Join node. */ 77 private JoinNodeImpl joinNode; 78 79 /*** Side. */ 80 private int side; 81 82 // ------------------------------------------------------------ 83 // Constructors 84 // ------------------------------------------------------------ 85 86 /*** Construct. 87 * 88 * @param joinNode Join node. 89 * @param side Side marker. 90 */ 91 JoinNodeInput(JoinNodeImpl joinNode, 92 int side) 93 { 94 this.joinNode = joinNode; 95 this.side = side; 96 } 97 98 // ------------------------------------------------------------ 99 // Instance methods 100 // ------------------------------------------------------------ 101 102 /*** Retrieve the side marker. 103 * 104 * @return The side marker. 105 */ 106 int getSide() 107 { 108 return this.side; 109 } 110 111 /*** Retrieve the destination join node. 112 * 113 * @return The join node. 114 */ 115 JoinNodeImpl getJoinNode() 116 { 117 return this.joinNode; 118 } 119 120 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 121 // org.drools.reteoo.impl.TupleSinkImpl 122 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 123 124 /*** Assert a new <code>Tuple</code>. 125 * 126 * @param tuple The <code>Tuple</code> being asserted. 127 * @param workingMemory The working memory seesion. 128 * 129 * @throws AssertionException If an error occurs while asserting. 130 */ 131 public void assertTuple(ReteTuple tuple, 132 WorkingMemory workingMemory) throws AssertionException 133 { 134 if ( this.side == LEFT ) 135 { 136 getJoinNode().assertLeftTuple( tuple, 137 workingMemory ); 138 } 139 else 140 { 141 getJoinNode().assertRightTuple( tuple, 142 workingMemory ); 143 } 144 } 145 146 /*** Retract tuples. 147 * 148 * @param key The tuple key. 149 * @param workingMemory The working memory seesion. 150 * 151 * @throws RetractionException If an error occurs while retracting. 152 */ 153 public void retractTuples(TupleKey key, 154 WorkingMemory workingMemory) throws RetractionException 155 { 156 getJoinNode().retractTuples( key, 157 workingMemory ); 158 } 159 160 /*** Modify tuples. 161 * 162 * @param trigger The root fact object. 163 * @param newTuples Modification replacement tuples. 164 * @param workingMemory The working memory session. 165 * 166 * @throws FactException If an error occurs while modifying. 167 */ 168 public void modifyTuples(Object trigger, 169 TupleSet newTuples, 170 WorkingMemory workingMemory) throws FactException 171 { 172 if ( this.side == LEFT ) 173 { 174 getJoinNode().modifyLeftTuples( trigger, 175 newTuples, 176 workingMemory ); 177 } 178 else 179 { 180 getJoinNode().modifyRightTuples( trigger, 181 newTuples, 182 workingMemory ); 183 } 184 } 185 }

This page was automatically generated by Maven