Clover coverage report - Drools - 2.0-rc2
Coverage timestamp: Wed May 11 2005 07:12:26 BST
file stats: LOC: 114   Methods: 4
NCLOC: 53   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
RuleSetHandler.java 66.7% 95% 100% 90%
coverage coverage
 1    package org.drools.io;
 2   
 3    /*
 4    * $Id: RuleSetHandler.java,v 1.1.2.2 2005/04/30 13:49:43 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.HashSet;
 44   
 45    import org.drools.rule.RuleSet;
 46    import org.drools.smf.DefaultImporter;
 47    import org.xml.sax.Attributes;
 48    import org.xml.sax.SAXException;
 49    import org.xml.sax.SAXParseException;
 50   
 51    /**
 52    * @author mproctor
 53    *
 54    * TODO To change the template for this generated type comment go to Window -
 55    * Preferences - Java - Code Style - Code Templates
 56    */
 57    class RuleSetHandler extends BaseAbstractHandler implements Handler
 58    {
 59  66 RuleSetHandler( RuleSetReader ruleSetReader )
 60    {
 61  66 this.ruleSetReader = ruleSetReader;
 62   
 63  66 if ( (this.validParents == null) && (validPeers == null) )
 64    {
 65  66 this.validParents = new HashSet( );
 66  66 this.validParents.add( null );
 67   
 68  66 this.validPeers = new HashSet( );
 69  66 this.validPeers.add( null );
 70   
 71  66 this.allowNesting = false;
 72    }
 73    }
 74   
 75  66 public Object start( String uri, String localName, Attributes attrs ) throws SAXException
 76    {
 77   
 78  66 String ruleSetName = attrs.getValue( "name" );
 79  66 String ruleSetDesc = attrs.getValue( "description" );
 80   
 81  66 if ( ruleSetName == null || ruleSetName.trim( ).equals( "" ) )
 82    {
 83  0 throw new SAXParseException(
 84    "<rule-set> requires a 'name' attribute", ruleSetReader
 85    .getLocator( ) );
 86    }
 87   
 88  66 RuleSet ruleSet = new RuleSet( ruleSetName.trim( ), this.ruleSetReader.getFactoryContext( ) );
 89   
 90  66 if ( ruleSetDesc == null || ruleSetDesc.trim( ).equals( "" ) )
 91    {
 92  51 ruleSet.setDocumentation( "" );
 93    }
 94    else
 95    {
 96  15 ruleSet.setDocumentation( ruleSetDesc );
 97    }
 98   
 99  66 ruleSet.setImporter( new DefaultImporter( ) );
 100   
 101  66 ruleSetReader.setRuleSet( ruleSet );
 102  66 return ruleSet;
 103    }
 104   
 105  65 public Object end( String uri, String localName ) throws SAXException
 106    {
 107  65 return null;
 108    }
 109   
 110  131 public Class generateNodeFor()
 111    {
 112  131 return RuleSet.class;
 113    }
 114    }