Clover coverage report - Drools - 2.0-rc2
Coverage timestamp: Wed May 11 2005 07:12:26 BST
file stats: LOC: 228   Methods: 13
NCLOC: 155   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
WorkingMemoryEventSupport.java 96.7% 95.2% 84.6% 94.1%
coverage coverage
 1    package org.drools.event;
 2   
 3    /*
 4    * $Id: WorkingMemoryEventSupport.java,v 1.9 2005/02/02 00:23:21 mproctor Exp $
 5    *
 6    * Copyright 2004 (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.Collections;
 46    import java.util.List;
 47   
 48    import org.drools.FactHandle;
 49    import org.drools.WorkingMemory;
 50    import org.drools.rule.Rule;
 51    import org.drools.spi.Condition;
 52    import org.drools.spi.Tuple;
 53   
 54    /**
 55    * @author <a href="mailto:simon@redhillconsulting.com.au">Simon Harris </a>
 56    */
 57    public class WorkingMemoryEventSupport
 58    implements
 59    Serializable
 60    {
 61    private final List listeners = new ArrayList( );
 62    private final WorkingMemory workingMemory;
 63   
 64  71 public WorkingMemoryEventSupport(WorkingMemory workingMemory)
 65    {
 66  71 this.workingMemory = workingMemory;
 67    }
 68   
 69  3 public void addEventListener(WorkingMemoryEventListener listener)
 70    {
 71  3 if ( !this.listeners.contains( listener ) )
 72    {
 73  3 this.listeners.add( listener );
 74    }
 75    }
 76   
 77  0 public void removeEventListener(WorkingMemoryEventListener listener)
 78    {
 79  0 this.listeners.remove( listener );
 80    }
 81   
 82  2 public List getEventListeners()
 83    {
 84  2 return Collections.unmodifiableList( this.listeners );
 85    }
 86   
 87  0 public int size()
 88    {
 89  0 return this.listeners.size( );
 90    }
 91   
 92  5760 public boolean isEmpty()
 93    {
 94  5760 return this.listeners.isEmpty( );
 95    }
 96   
 97  872 public void fireObjectAsserted(FactHandle handle,
 98    Object object)
 99    {
 100  872 if ( this.listeners.isEmpty( ) )
 101    {
 102  769 return;
 103    }
 104   
 105  103 ObjectAssertedEvent event = new ObjectAssertedEvent( this.workingMemory,
 106    handle,
 107    object );
 108   
 109  103 for ( int i = 0, size = this.listeners.size( ); i < size; i++ )
 110    {
 111  103 ((WorkingMemoryEventListener) this.listeners.get( i )).objectAsserted( event );
 112    }
 113    }
 114   
 115  316 public void fireObjectModified(FactHandle handle,
 116    Object oldObject,
 117    Object object)
 118    {
 119  316 if ( this.listeners.isEmpty( ) )
 120    {
 121  247 return;
 122    }
 123   
 124  69 ObjectModifiedEvent event = new ObjectModifiedEvent( this.workingMemory,
 125    handle,
 126    oldObject,
 127    object );
 128   
 129  69 for ( int i = 0, size = this.listeners.size( ); i < size; i++ )
 130    {
 131  69 ((WorkingMemoryEventListener) this.listeners.get( i )).objectModified( event );
 132    }
 133    }
 134   
 135  54 public void fireObjectRetracted(FactHandle handle,
 136    Object oldObject)
 137    {
 138  54 if ( this.listeners.isEmpty( ) )
 139    {
 140  5 return;
 141    }
 142   
 143  49 ObjectRetractedEvent event = new ObjectRetractedEvent( this.workingMemory,
 144    handle,
 145    oldObject );
 146   
 147  49 for ( int i = 0, size = this.listeners.size( ); i < size; i++ )
 148    {
 149  49 ((WorkingMemoryEventListener) this.listeners.get( i )).objectRetracted( event );
 150    }
 151    }
 152   
 153  41832 public void fireConditionTested(Rule rule,
 154    Condition condition,
 155    Tuple tuple,
 156    boolean result)
 157    {
 158  41832 if ( this.listeners.isEmpty( ) )
 159    {
 160  39238 return;
 161    }
 162   
 163  2594 ConditionTestedEvent event = new ConditionTestedEvent( this.workingMemory,
 164    rule,
 165    condition,
 166    tuple,
 167    result );
 168   
 169  2594 for ( int i = 0, size = this.listeners.size( ); i < size; i++ )
 170    {
 171  2594 ((WorkingMemoryEventListener) this.listeners.get( i )).conditionTested( event );
 172    }
 173    }
 174   
 175  6152 public void fireActivationCreated(Rule rule,
 176    Tuple tuple)
 177    {
 178  6152 if ( this.listeners.isEmpty( ) )
 179    {
 180  5949 return;
 181    }
 182   
 183  203 ActivationCreatedEvent event = new ActivationCreatedEvent( this.workingMemory,
 184    rule,
 185    tuple );
 186   
 187  203 for ( int i = 0, size = this.listeners.size( ); i < size; i++ )
 188    {
 189  203 ((WorkingMemoryEventListener) this.listeners.get( i )).activationCreated( event );
 190    }
 191    }
 192   
 193  5765 public void fireActivationCancelled(Rule rule,
 194    Tuple tuple)
 195    {
 196  5765 if ( this.listeners.isEmpty( ) )
 197    {
 198  5682 return;
 199    }
 200   
 201  83 ActivationCancelledEvent event = new ActivationCancelledEvent( this.workingMemory,
 202    rule,
 203    tuple );
 204   
 205  83 for ( int i = 0, size = this.listeners.size( ); i < size; i++ )
 206    {
 207  83 ((WorkingMemoryEventListener) this.listeners.get( i )).activationCancelled( event );
 208    }
 209    }
 210   
 211  385 public void fireActivationFired(Rule rule,
 212    Tuple tuple)
 213    {
 214  385 if ( this.listeners.isEmpty( ) )
 215    {
 216  265 return;
 217    }
 218   
 219  120 ActivationFiredEvent event = new ActivationFiredEvent( this.workingMemory,
 220    rule,
 221    tuple );
 222   
 223  120 for ( int i = 0, size = this.listeners.size( ); i < size; i++ )
 224    {
 225  120 ((WorkingMemoryEventListener) this.listeners.get( i )).activationFired( event );
 226    }
 227    }
 228    }