Clover coverage report - Drools - 2.0-rc2
Coverage timestamp: Wed May 11 2005 07:12:26 BST
file stats: LOC: 186   Methods: 9
NCLOC: 59   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
AgendaItem.java - 83.3% 77.8% 81%
coverage coverage
 1    package org.drools.reteoo;
 2   
 3    /*
 4    * $Id: AgendaItem.java,v 1.22 2005/02/04 02:13:36 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   
 45    import org.drools.FactHandle;
 46    import org.drools.rule.Rule;
 47    import org.drools.spi.Activation;
 48    import org.drools.spi.ConsequenceException;
 49    import org.drools.spi.Tuple;
 50   
 51    /**
 52    * Item entry in the <code>Agenda</code>.
 53    *
 54    * @author <a href="mailto:bob@eng.werken.com">bob mcwhirter </a>
 55    */
 56    class AgendaItem
 57    implements
 58    Activation,
 59    Serializable
 60    {
 61    // ------------------------------------------------------------
 62    // Instance members
 63    // ------------------------------------------------------------
 64   
 65    /** The tuple. */
 66    private ReteTuple tuple;
 67   
 68    /** The rule. */
 69    private Rule rule;
 70   
 71    // ** The Counter */
 72    private static long counter;
 73   
 74    private long activationNumber;
 75   
 76    private boolean retract;
 77   
 78    // ------------------------------------------------------------
 79    // Constructors
 80    // ------------------------------------------------------------
 81   
 82    /**
 83    * Construct.
 84    *
 85    * @param tuple
 86    * The tuple.
 87    * @param rule
 88    * The rule.
 89    */
 90  6157 AgendaItem(ReteTuple tuple,
 91    Rule rule)
 92    {
 93  6157 this.tuple = tuple;
 94  6157 this.rule = rule;
 95  6157 this.activationNumber = counter++;
 96    }
 97   
 98    // ------------------------------------------------------------
 99    // Instance methods
 100    // ------------------------------------------------------------
 101   
 102    /**
 103    * Retrieve the rule.
 104    *
 105    * @return The rule.
 106    */
 107  198681 public Rule getRule()
 108    {
 109  198681 return this.rule;
 110    }
 111   
 112    /**
 113    * Determine if this tuple depends on the values derrived from a particular
 114    * root object.
 115    *
 116    * @param handle
 117    * The root object handle.
 118    *
 119    * @return <code>true<code> if this agenda item depends
 120    * upon the item, otherwise <code>false</code>.
 121    */
 122  6 boolean dependsOn(FactHandle handle)
 123    {
 124  6 return this.tuple.dependsOn( handle );
 125    }
 126   
 127    /**
 128    * Set the tuple.
 129    *
 130    * @param tuple
 131    * The tuple.
 132    */
 133  1 void setTuple(ReteTuple tuple)
 134    {
 135  1 this.tuple = tuple;
 136    }
 137   
 138    /**
 139    * Retrieve the tuple.
 140    *
 141    * @return The tuple.
 142    */
 143  99384 public Tuple getTuple()
 144    {
 145  99384 return this.tuple;
 146    }
 147   
 148    /**
 149    * Retrieve the <code>TupleKey</code>.
 150    *
 151    * @return The key to the tuple in this item.
 152    */
 153  11623 TupleKey getKey()
 154    {
 155  11623 return this.tuple.getKey( );
 156    }
 157   
 158    /**
 159    * Fire this item.
 160    *
 161    * @param workingMemory
 162    * The working memory context.
 163    *
 164    * @throws ConsequenceException
 165    * If an error occurs while attempting to fire the consequence.
 166    */
 167  386 void fire(WorkingMemoryImpl workingMemory) throws ConsequenceException
 168    {
 169   
 170  386 this.rule.getConsequence( ).invoke( this.tuple );
 171   
 172  385 workingMemory.getEventSupport( ).fireActivationFired( this.rule,
 173    this.tuple );
 174    }
 175   
 176  0 public long getActivationNumber()
 177    {
 178  0 return this.activationNumber;
 179    }
 180   
 181  0 public String toString()
 182    {
 183  0 return "[" + this.rule.getName( ) + " " + this.tuple + "]";
 184    }
 185   
 186    }