Clover coverage report - Drools - 2.0-rc2
Coverage timestamp: Wed May 11 2005 07:12:26 BST
file stats: LOC: 125   Methods: 4
NCLOC: 69   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ObjectTypeHandler.java 50% 95.2% 100% 92.6%
coverage coverage
 1    package org.drools.io;
 2   
 3    /*
 4    * $Id: ObjectTypeHandler.java,v 1.4.2.3 2005/05/01 03:20:28 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    import java.util.HashSet;
 43   
 44    import org.drools.rule.Declaration;
 45    import org.drools.rule.Rule;
 46    import org.drools.smf.Configuration;
 47    import org.drools.smf.DefaultConfiguration;
 48    import org.drools.smf.FactoryException;
 49    import org.drools.smf.ObjectTypeFactory;
 50    import org.drools.smf.SemanticModule;
 51    import org.drools.spi.ImportEntry;
 52    import org.drools.spi.ObjectType;
 53    import org.xml.sax.Attributes;
 54    import org.xml.sax.SAXException;
 55    import org.xml.sax.SAXParseException;
 56   
 57    /**
 58    * @author mproctor
 59    */
 60    class ObjectTypeHandler extends BaseAbstractHandler
 61    implements
 62    Handler
 63    {
 64  66 ObjectTypeHandler(RuleSetReader ruleSetReader)
 65    {
 66  66 this.ruleSetReader = ruleSetReader;
 67   
 68  66 if ( this.validParents == null && this.validPeers == null )
 69    {
 70  66 this.validParents = new HashSet( );
 71  66 this.validParents.add( Declaration.class );
 72   
 73  66 this.validPeers = new HashSet( );
 74  66 this.validPeers.add( null );
 75   
 76  66 this.allowNesting = false;
 77    }
 78    }
 79   
 80  164 public Object start(String uri,
 81    String localName,
 82    Attributes attrs) throws SAXException
 83    {
 84  164 this.ruleSetReader.startConfiguration( localName,
 85    attrs );
 86  164 return null;
 87    }
 88   
 89  164 public Object end(String uri,
 90    String localName) throws SAXException
 91    {
 92  164 Configuration config = this.ruleSetReader.endConfiguration( );
 93   
 94  164 SemanticModule module = this.ruleSetReader.lookupSemanticModule( uri,
 95    localName );
 96   
 97  164 ObjectTypeFactory factory = module.getObjectTypeFactory( localName );
 98   
 99  164 try
 100    {
 101  164 Rule rule = (Rule) this.ruleSetReader.getParent( Rule.class );
 102  164 Declaration declaration = (Declaration) this.ruleSetReader.getParent( Declaration.class );
 103  164 ((DefaultConfiguration) config).setAttribute( "identifier",
 104    declaration.getIdentifier( ) );
 105   
 106  164 ObjectType objectType = factory.newObjectType( rule,
 107    this.ruleSetReader.getFactoryContext( ),
 108    config );
 109   
 110  164 declaration.setObjectType( objectType );
 111    }
 112    catch ( FactoryException e )
 113    {
 114  0 throw new SAXParseException( "error constructing object type",
 115    this.ruleSetReader.getLocator( ),
 116    e );
 117    }
 118  164 return null;
 119    }
 120   
 121  328 public Class generateNodeFor()
 122    {
 123  328 return ImportEntry.class;
 124    }
 125    }