Clover coverage report - Drools - 2.0-rc2
Coverage timestamp: Wed May 11 2005 07:12:26 BST
file stats: LOC: 170   Methods: 5
NCLOC: 47   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
TupleSource.java 83.3% 85.7% 80% 83.3%
coverage coverage
 1    package org.drools.reteoo;
 2   
 3    /*
 4    * $Id: TupleSource.java,v 1.30 2005/02/02 00:23:22 mproctor Exp $
 5    *
 6    * Copyright 2001-2003 (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 that the
 10    * following conditions are met:
 11    *
 12    * 1. Redistributions of source code must retain copyright statements and
 13    * notices. Redistributions must also contain a copy of this document.
 14    *
 15    * 2. Redistributions in binary form must reproduce the above copyright notice,
 16    * this list of conditions and the following disclaimer in the documentation
 17    * and/or other materials provided with the distribution.
 18    *
 19    * 3. The name "drools" must not be used to endorse or promote products derived
 20    * from this Software without prior written permission of The Werken Company.
 21    * For written permission, please contact bob@werken.com.
 22    *
 23    * 4. Products derived from this Software may not be called "drools" nor may
 24    * "drools" appear in their names without prior written permission of The Werken
 25    * Company. "drools" is a trademark of The Werken Company.
 26    *
 27    * 5. Due credit should be given to The Werken Company. (http://werken.com/)
 28    *
 29    * THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS''
 30    * AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 31    * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 32    * ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE
 33    * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 34    * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 35    * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 36    * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 37    * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 38    * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 39    * POSSIBILITY OF SUCH DAMAGE.
 40    *
 41    */
 42   
 43    import java.io.Serializable;
 44    import java.util.ArrayList;
 45    import java.util.List;
 46    import java.util.Set;
 47   
 48    import org.drools.AssertionException;
 49    import org.drools.RetractionException;
 50   
 51    /**
 52    * A source of <code>ReteTuple</code> s for a <code>TupleSink</code>.
 53    *
 54    * <p>
 55    * Nodes that propagate <code>Tuples</code> extend this class.
 56    * </p>
 57    *
 58    * @see TupleSource
 59    * @see ReteTuple
 60    *
 61    * @author <a href="mailto:bob@eng.werken.com">bob mcwhirter </a>
 62    */
 63    abstract class TupleSource
 64    implements
 65    Serializable
 66    {
 67    // ------------------------------------------------------------
 68    // Instance members
 69    // ------------------------------------------------------------
 70   
 71    /** The destination for <code>Tuples</code>. */
 72    private List tupleSinks = new ArrayList( 1 );
 73   
 74    // ------------------------------------------------------------
 75    // Constructors
 76    // ------------------------------------------------------------
 77   
 78    /**
 79    * Construct.
 80    */
 81  435 TupleSource()
 82    {
 83    // intentionally left blank.
 84    }
 85   
 86    // ------------------------------------------------------------
 87    // Instance methods
 88    // ------------------------------------------------------------
 89   
 90    /**
 91    * Adds the <code>TupleSink</code> so that it may receive <code>Tuples</code>
 92    * propagated from this <code>TupleSource</code>.
 93    *
 94    * @param tupleSink The <code>TupleSink</code> to receive propagated <code>Tuples</code>.
 95    */
 96  411 protected void addTupleSink(TupleSink tupleSink)
 97    {
 98  411 if ( !this.tupleSinks.contains( tupleSink ) )
 99    {
 100  411 this.tupleSinks.add( tupleSink );
 101    }
 102    }
 103   
 104    /**
 105    * Propagate the assertion of a <code>Tuple</code> to this node's
 106    * <code>TupleSink</code>.
 107    *
 108    * @param tuple The <code>Tuple</code> to propagate.
 109    * @param workingMemory the working memory session.
 110    *
 111    * @throws AssertionException If an errors occurs while attempting assertion.
 112    */
 113  48803 protected void propagateAssertTuple(ReteTuple tuple,
 114    WorkingMemoryImpl workingMemory) throws AssertionException
 115    {
 116  48803 for ( int i = 0, size = this.tupleSinks.size( ); i < size; i++ )
 117    {
 118  50073 ( ( TupleSink ) this.tupleSinks.get( i ) ).assertTuple( tuple,
 119    workingMemory );
 120    }
 121    }
 122   
 123    /**
 124    * Propagate the retration of a <code>Tuple</code> to this node's
 125    * <code>TupleSink</code>.
 126    *
 127    * @param key The tuple key.
 128    * @param workingMemory The working memory session.
 129    *
 130    * @throws RetractionException If an error occurs while attempting retraction
 131    *
 132    */
 133  4221 protected void propagateRetractTuples(TupleKey key,
 134    WorkingMemoryImpl workingMemory) throws RetractionException
 135    {
 136  4221 for ( int i = 0, size = this.tupleSinks.size( ); i < size; i++ )
 137    {
 138  4951 ( ( TupleSink ) this.tupleSinks.get( i ) ).retractTuples( key,
 139    workingMemory );
 140    }
 141    }
 142   
 143    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 144    // org.drools.reteoo.TupleSource
 145    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 146   
 147    /**
 148    * Retrieve the <code>TupleSinks</code> that receive propagated
 149    * <code>Tuples</code>.
 150    *
 151    * @return The <code>TupleSinks</code> that receive propagated
 152    * <code>Tuples</code>.
 153    */
 154  0 public List getTupleSinks()
 155    {
 156  0 return this.tupleSinks;
 157    }
 158   
 159    /**
 160    * Retrieve the available tuple <code>Declaration</code>s.
 161    *
 162    * @return The available tuple declarations.
 163    */
 164    public abstract Set getTupleDeclarations();
 165   
 166    /**
 167    * Attaches this node into the network.
 168    */
 169    public abstract void attach( );
 170    }