Clover coverage report - Drools - 2.0-rc2
Coverage timestamp: Wed May 11 2005 07:12:26 BST
file stats: LOC: 297   Methods: 27
NCLOC: 141   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
SimpleSemanticModule.java - 88.6% 81.5% 85.9%
coverage coverage
 1    package org.drools.smf;
 2   
 3    /*
 4    * $Id: SimpleSemanticModule.java,v 1.10 2005/02/04 02:13:38 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.util.HashMap;
 44    import java.util.Map;
 45    import java.util.Set;
 46   
 47    /**
 48    * Simple implementation of a Semantic Module.
 49    *
 50    * @see org.drools.spi
 51    *
 52    * @author <a href="mailto:bob@werken.com">bob mcwhirter </a>
 53    */
 54    public class SimpleSemanticModule implements SemanticModule
 55    {
 56    // ------------------------------------------------------------
 57    // Instance members
 58    // ------------------------------------------------------------
 59   
 60    /** URI of this module. */
 61    private String uri;
 62   
 63    /** Rule factories. */
 64    private Map ruleFactories;
 65   
 66    /** Object type factories. */
 67    private Map objectTypeFactories;
 68   
 69    /** Condition factories. */
 70    private Map conditionFactories;
 71   
 72    /** Consequence factories. */
 73    private Map consequenceFactories;
 74   
 75    private Map durationFactories;
 76   
 77    /** Imports factories */
 78    private Map importEntryFactories;
 79   
 80    /** ApplicationData factories */
 81    private Map applicationDataFactories;
 82   
 83    /** functions factories */
 84    private Map functionFactories;
 85   
 86    private Map types;
 87   
 88   
 89    // ------------------------------------------------------------
 90    // Constructors
 91    // ------------------------------------------------------------
 92   
 93    /**
 94    * Construct with a URI.
 95    *
 96    * @param uri The URI the identifies this semantic module.
 97    */
 98  18 public SimpleSemanticModule(String uri)
 99    {
 100  18 this.uri = uri;
 101   
 102  18 this.ruleFactories = new HashMap( );
 103  18 this.objectTypeFactories = new HashMap( );
 104  18 this.conditionFactories = new HashMap( );
 105  18 this.consequenceFactories = new HashMap( );
 106  18 this.durationFactories = new HashMap( );
 107  18 this.importEntryFactories = new HashMap( );
 108  18 this.applicationDataFactories = new HashMap( );
 109  18 this.functionFactories = new HashMap( );
 110  18 this.types = new HashMap( );
 111    }
 112   
 113    // ------------------------------------------------------------
 114    // Instance methods
 115    // ------------------------------------------------------------
 116   
 117    /**
 118    * @see SemanticModule
 119    */
 120  13 public String getUri()
 121    {
 122  13 return this.uri;
 123    }
 124   
 125  1358 public String getType(String name)
 126    {
 127  1358 return (String) this.types.get(name);
 128    }
 129   
 130  8 public void addRuleFactory(String name, RuleFactory factory)
 131    {
 132  8 this.ruleFactories.put( name, factory );
 133  8 this.types.put(name, "Rule");
 134    }
 135   
 136    /**
 137    * @see SemanticModule
 138    */
 139  80 public RuleFactory getRuleFactory(String name)
 140    {
 141  80 return ( RuleFactory ) this.ruleFactories.get( name );
 142    }
 143   
 144  1 public Set getRuleFactoryNames()
 145    {
 146  1 return this.ruleFactories.keySet( );
 147    }
 148   
 149    /**
 150    * Add a semantic <code>ObjectTypeFactory</code>.
 151    *
 152    * @param name The object type name.
 153    * @param factory The object type factory.
 154    *
 155    */
 156  24 public void addObjectTypeFactory(String name, ObjectTypeFactory factory)
 157    {
 158  24 this.objectTypeFactories.put( name, factory );
 159  24 this.types.put(name, "ObjectType");
 160    }
 161   
 162    /**
 163    * @see SemanticModule
 164    */
 165  171 public ObjectTypeFactory getObjectTypeFactory(String name)
 166    {
 167  171 return ( ObjectTypeFactory ) this.objectTypeFactories.get( name );
 168    }
 169   
 170    /**
 171    * @see SemanticModule
 172    */
 173  1 public Set getObjectTypeFactoryNames()
 174    {
 175  1 return this.objectTypeFactories.keySet( );
 176    }
 177   
 178    /**
 179    * Add a semantic <code>ConditionFactory</code>.
 180    *
 181    * @param name The condition name.
 182    * @param factory The condition factory.
 183    */
 184  6 public void addConditionFactory(String name, ConditionFactory factory)
 185    {
 186  6 this.conditionFactories.put( name, factory );
 187  6 this.types.put(name, "Condition");
 188    }
 189   
 190    /**
 191    * @see SemanticModule
 192    */
 193  168 public ConditionFactory getConditionFactory(String name)
 194    {
 195  168 return ( ConditionFactory ) this.conditionFactories.get( name );
 196    }
 197   
 198    /**
 199    * @see SemanticModule
 200    */
 201  1 public Set getConditionFactoryNames()
 202    {
 203  1 return this.conditionFactories.keySet( );
 204    }
 205   
 206    /**
 207    * Add a semantic <code>ConsequenceFactory</code>.
 208    *
 209    * @param name The consequence name.
 210    * @param factory The consequence factory.
 211    */
 212  6 public void addConsequenceFactory(String name, ConsequenceFactory factory)
 213    {
 214  6 this.consequenceFactories.put( name, factory );
 215  6 this.types.put(name, "Consequence");
 216    }
 217   
 218    /**
 219    * @see SemanticModule
 220    */
 221  95 public ConsequenceFactory getConsequenceFactory(String name)
 222    {
 223  95 return ( ConsequenceFactory ) this.consequenceFactories.get( name );
 224    }
 225   
 226    /**
 227    * @see SemanticModule
 228    */
 229  1 public Set getConsequenceFactoryNames()
 230    {
 231  1 return this.consequenceFactories.keySet( );
 232    }
 233   
 234  7 public void addDurationFactory(String name, DurationFactory factory)
 235    {
 236  7 this.durationFactories.put( name, factory );
 237  7 this.types.put(name, "Duration");
 238    }
 239   
 240  1 public DurationFactory getDurationFactory(String name)
 241    {
 242  1 return ( DurationFactory ) this.durationFactories.get( name );
 243    }
 244   
 245  1 public Set getDurationFactoryNames()
 246    {
 247  1 return this.durationFactories.keySet( );
 248    }
 249   
 250  11 public void addImportEntryFactory(String name, ImportEntryFactory factory)
 251    {
 252  11 this.importEntryFactories.put( name, factory );
 253  11 this.types.put(name, "ImportEntry");
 254    }
 255   
 256  30 public ImportEntryFactory getImportEntryFactory(String name)
 257    {
 258  30 return ( ImportEntryFactory ) this.importEntryFactories.get( name );
 259    }
 260   
 261  0 public Set getImportEntryFactoryNames()
 262    {
 263  0 return this.importEntryFactories.keySet( );
 264    }
 265   
 266  6 public void addApplicationDataFactory(String name, ApplicationDataFactory factory)
 267    {
 268  6 this.applicationDataFactories.put( name, factory );
 269  6 this.types.put(name, "ApplicationData");
 270    }
 271   
 272  0 public ApplicationDataFactory getApplicationDataFactory(String name)
 273    {
 274  0 return ( ApplicationDataFactory ) this.applicationDataFactories.get( name );
 275    }
 276   
 277  0 public Set getApplicationDataFactoryNames()
 278    {
 279  0 return this.applicationDataFactories.keySet( );
 280    }
 281   
 282  5 public void addFunctionsFactory(String name, FunctionsFactory factory)
 283    {
 284  5 this.functionFactories.put( name, factory );
 285  5 this.types.put(name, "Functions");
 286    }
 287   
 288  0 public FunctionsFactory getFunctionsFactory(String name)
 289    {
 290  0 return ( FunctionsFactory ) this.functionFactories.get( name );
 291    }
 292   
 293  0 public Set getFunctionsFactoryNames()
 294    {
 295  0 return this.functionFactories.keySet();
 296    }
 297    }