Clover coverage report - Drools - 2.0-rc2
Coverage timestamp: Wed May 11 2005 07:12:26 BST
file stats: LOC: 149   Methods: 6
NCLOC: 37   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
RuleImpl.java - 87.5% 83.3% 85.7%
coverage coverage
 1    package org.drools.jsr94.rules.admin;
 2   
 3    /*
 4    * $Id: RuleImpl.java,v 1.11 2004/11/27 00:59:54 dbarnett Exp $
 5    *
 6    * Copyright 2002-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 registered trademark of The Werken Company.
 26    *
 27    * 5. Due credit should be given to The Werken Company.
 28    * (http://drools.werken.com/).
 29    *
 30    * THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS''
 31    * AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 32    * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 33    * ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE
 34    * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 35    * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 36    * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 37    * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 38    * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 39    * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 40    * POSSIBILITY OF SUCH DAMAGE.
 41    *
 42    */
 43   
 44    import java.util.HashMap;
 45    import java.util.Map;
 46   
 47    import javax.rules.admin.Rule;
 48   
 49    /**
 50    * The Drools implementation of the <code>Rule</code> interface which provides
 51    * access to simple metadata for a rule. Related <code>Rule</code>
 52    * instances are assembled into <code>RuleExecutionSet</code>s, which in
 53    * turn, can be executed by a rules engine via the <code>RuleSession</code>
 54    * interface.
 55    *
 56    * @see Rule
 57    *
 58    * @author N. Alex Rupp (n_alex <at>codehaus.org)
 59    * @author <a href="mailto:thomas.diesler@softcon-itec.de">thomas diesler </a>
 60    */
 61    public class RuleImpl implements Rule
 62    {
 63    /** The name of this rule. */
 64    private String name;
 65   
 66    /** A description of the rule or null if no description is specified. */
 67    private String description;
 68   
 69    /** A <code>Map</code> of user-defined and Drools-defined properties. */
 70    private Map properties = new HashMap( );
 71   
 72    /**
 73    * The <code>org.drools.rule.Rule</code> that lies at the core of
 74    * this <code>javax.rules.admin.Rule</code> object.
 75    */
 76    private org.drools.rule.Rule rule;
 77   
 78    /**
 79    * Creates a <code>RuleImpl</code> object by wrapping an
 80    * <code>org.drools.rule.Rule</code> object.
 81    *
 82    * @param rule the <code>org.drools.rule.Rule</code> object to be wrapped.
 83    */
 84  11 RuleImpl( org.drools.rule.Rule rule )
 85    {
 86  11 this.rule = rule;
 87  11 this.name = rule.getName( );
 88  11 this.description = rule.getDocumentation( );
 89    }
 90   
 91    /**
 92    * Returns the <code>org.drools.rule.Rule</code> that lies at the core of
 93    * this <code>javax.rules.admin.Rule</code> object. This method is package
 94    * private.
 95    *
 96    * @return <code>org.drools.rule.Rule</code> at the core of this object.
 97    */
 98  0 org.drools.rule.Rule getRule( )
 99    {
 100  0 return this.rule;
 101    }
 102   
 103    /* Rule interface methods */
 104   
 105    /**
 106    * Get the name of this rule.
 107    *
 108    * @return The name of this rule.
 109    */
 110  2 public String getName( )
 111    {
 112  2 return this.name;
 113    }
 114   
 115    /**
 116    * Get a description of the rule.
 117    *
 118    * @return A description of the rule or null of no description is specified.
 119    */
 120  2 public String getDescription( )
 121    {
 122  2 return this.description;
 123    }
 124   
 125    /**
 126    * Get a user-defined or Drools-defined property.
 127    *
 128    * @param key the key to use to retrieve the property
 129    *
 130    * @return the value bound to the key or <code>null</code>
 131    */
 132  1 public Object getProperty( Object key )
 133    {
 134    // TODO certain keys should reference internal rule accessor methods
 135  1 return this.properties.get( key );
 136    }
 137   
 138    /**
 139    * Set a user-defined or Drools-defined property.
 140    *
 141    * @param key the key for the property value
 142    * @param value the value to associate with the key
 143    */
 144  1 public void setProperty( Object key, Object value )
 145    {
 146    // TODO certain keys should alter internal rule accessor methods
 147  1 this.properties.put( key, value );
 148    }
 149    }