Clover coverage report - Drools - 2.0-rc2
Coverage timestamp: Wed May 11 2005 07:12:26 BST
file stats: LOC: 215   Methods: 11
NCLOC: 79   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
DefaultConfiguration.java 0% 31.8% 45.5% 29.3%
coverage coverage
 1    package org.drools.smf;
 2   
 3    /*
 4    * $Id: DefaultConfiguration.java,v 1.1.2.1 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   
 43    import java.util.ArrayList;
 44    import java.util.HashMap;
 45    import java.util.Iterator;
 46    import java.util.List;
 47    import java.util.Map;
 48   
 49   
 50    /**
 51    * Default implementation of <code>Configuration</code>.
 52    *
 53    * @author <a href="mailto:bob@werken.com">bob mcwhirter </a>
 54    *
 55    * @version $Id: DefaultConfiguration.java,v 1.2 2004/09/17 00:25:09 mproctor
 56    * Exp $
 57    */
 58    public class DefaultConfiguration implements Configuration
 59    {
 60    // ----------------------------------------------------------------------
 61    // Class members
 62    // ----------------------------------------------------------------------
 63   
 64    /** Empty <code>String</code> array. */
 65    private static final String[] EMPTY_STRING_ARRAY = new String[0];
 66   
 67    // ----------------------------------------------------------------------
 68    // Instance members
 69    // ----------------------------------------------------------------------
 70   
 71    /** Node name. */
 72    private String name;
 73   
 74    /** Node text. */
 75    private String text = "";
 76   
 77    /** Node attributes. */
 78    private Map attrs;
 79   
 80    /** Children nodes. */
 81    private List children;
 82   
 83    // ----------------------------------------------------------------------
 84    // Constructors
 85    // ----------------------------------------------------------------------
 86   
 87    /**
 88    * Construct.
 89    *
 90    * @param name
 91    * The name of the node.
 92    */
 93  562 public DefaultConfiguration( String name )
 94    {
 95  562 this.name = name;
 96  562 this.attrs = new HashMap( );
 97  562 this.children = new ArrayList( );
 98    }
 99   
 100    /**
 101    * @see Configuration
 102    */
 103  0 public String getName()
 104    {
 105  0 return this.name;
 106    }
 107   
 108    /**
 109    * Set the node text.
 110    *
 111    * @param text
 112    * The text.
 113    */
 114  553 public void setText( String text )
 115    {
 116  553 this.text = text;
 117    }
 118   
 119    /**
 120    * @see Configuration
 121    */
 122  477 public String getText()
 123    {
 124  477 return this.text;
 125    }
 126   
 127    /**
 128    * Set an attribute value.
 129    *
 130    * @param name
 131    * The attribute name.
 132    * @param value
 133    * The attribute value.
 134    */
 135  336 public void setAttribute( String name, String value )
 136    {
 137  336 this.attrs.put( name, value );
 138    }
 139   
 140    /**
 141    * @see Configuration
 142    */
 143  150 public String getAttribute( String name )
 144    {
 145  150 return (String) this.attrs.get( name );
 146    }
 147   
 148    /**
 149    * @see Configuration
 150    */
 151  0 public String[] getAttributeNames()
 152    {
 153  0 return (String[]) this.attrs.keySet( ).toArray( EMPTY_STRING_ARRAY );
 154    }
 155   
 156    /**
 157    * Add a child <code>Configuration</code>.
 158    *
 159    * @param config
 160    * The child.
 161    */
 162  0 public void addChild( Configuration config )
 163    {
 164  0 this.children.add( config );
 165    }
 166   
 167    /**
 168    * @see Configuration
 169    */
 170  0 public Configuration getChild( String name )
 171    {
 172  0 for ( Iterator childIter = this.children.iterator( ); childIter
 173    .hasNext( ); )
 174    {
 175  0 Configuration eachConfig = (Configuration) childIter.next( );
 176   
 177  0 if ( eachConfig.getName( ).equals( name ) )
 178    {
 179  0 return eachConfig;
 180    }
 181    }
 182   
 183  0 return null;
 184    }
 185   
 186    /**
 187    * @see Configuration
 188    */
 189  0 public Configuration[] getChildren( String name )
 190    {
 191  0 List result = new ArrayList( );
 192   
 193  0 for ( Iterator childIter = this.children.iterator( ); childIter
 194    .hasNext( ); )
 195    {
 196  0 Configuration eachConfig = (Configuration) childIter.next( );
 197   
 198  0 if ( eachConfig.getName( ).equals( name ) )
 199    {
 200  0 result.add( eachConfig );
 201    }
 202    }
 203   
 204  0 return (Configuration[]) result.toArray( Configuration.EMPTY_ARRAY );
 205    }
 206   
 207    /**
 208    * @see Configuration
 209    */
 210  0 public Configuration[] getChildren()
 211    {
 212  0 return (Configuration[]) this.children
 213    .toArray( Configuration.EMPTY_ARRAY );
 214    }
 215    }