Clover coverage report -
Coverage timestamp: Thu Jul 5 2007 20:02:32 EDT
file stats: LOC: 111   Methods: 9
NCLOC: 68   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ElementSizeConfiguration.java 33.3% 59.1% 77.8% 59.5%
coverage coverage
 1    /*
 2    * JBoss, the OpenSource J2EE webOS
 3    *
 4    * Distributable under LGPL license.
 5    * See terms of license at gnu.org.
 6    */
 7    package org.jboss.cache.eviction;
 8   
 9    import org.jboss.cache.config.ConfigurationException;
 10    import org.jboss.cache.config.Dynamic;
 11   
 12    /**
 13    * Configuration for {@link ElementSizePolicy}.
 14    * <p/>
 15    * If configured via XML, expects the following:
 16    * <p/>
 17    * <pre>
 18    * <region name="/region/">
 19    * <attribute name="maxElementsPerNode">100</attribute>
 20    * <attribute name="maxNodes">10000</attribute>
 21    * </region>
 22    * </pre>
 23    *
 24    * Requires a positive "maxElementsPerNode" value otherwise a ConfigurationException is thrown.
 25    *
 26    * @author Daniel Huang
 27    * @author Brian Stansberry
 28    *
 29    * @version $Revision: 1.6 $
 30    */
 31    public class ElementSizeConfiguration extends EvictionPolicyConfigBase
 32    {
 33    /** The serialVersionUID */
 34    private static final long serialVersionUID = 2510593544656833758L;
 35   
 36    @Dynamic
 37    private int maxElementsPerNode;
 38   
 39  17 public ElementSizeConfiguration()
 40    {
 41  17 super();
 42    // Force configuration of maxElementsPerNode
 43  17 setMaxElementsPerNode(-1);
 44    }
 45   
 46  32 @Override
 47    protected void setEvictionPolicyClassName()
 48    {
 49  32 setEvictionPolicyClass(ElementSizePolicy.class.getName());
 50    }
 51   
 52  18 public int getMaxElementsPerNode()
 53    {
 54  18 return maxElementsPerNode;
 55    }
 56   
 57  50 public void setMaxElementsPerNode(int maxElementsPerNode)
 58    {
 59  50 testImmutability("maxElementsPerNode");
 60  50 this.maxElementsPerNode = maxElementsPerNode;
 61    }
 62   
 63    /**
 64    * Requires a positive maxElementsPerNode value or ConfigurationException
 65    * is thrown.
 66    */
 67  45 @Override
 68    public void validate() throws ConfigurationException
 69    {
 70  45 if (maxElementsPerNode < 0)
 71    {
 72  1 throw new ConfigurationException("maxElementsPerNode must be must be " +
 73    "configured to a value greater than or equal to 0");
 74    }
 75    }
 76   
 77  0 public String toString()
 78    {
 79  0 StringBuffer str = new StringBuffer();
 80  0 str.append("ElementSizeConfiguration: maxElementsPerNode =");
 81  0 str.append(getMaxElementsPerNode()).append(" maxNodes =").append(getMaxNodes());
 82  0 return str.toString();
 83    }
 84   
 85  0 @Override
 86    public boolean equals(Object obj)
 87    {
 88  0 if (this == obj)
 89  0 return true;
 90  0 if (obj instanceof ElementSizeConfiguration && super.equals(obj))
 91    {
 92  0 return this.maxElementsPerNode == ((ElementSizeConfiguration) obj).maxElementsPerNode;
 93    }
 94  0 return false;
 95    }
 96   
 97  30 @Override
 98    public int hashCode()
 99    {
 100  30 int result = super.hashCode();
 101  30 result = 31 * result + maxElementsPerNode;
 102  30 return result;
 103    }
 104   
 105  15 @Override
 106    public void reset()
 107    {
 108  15 super.reset();
 109  15 setMaxElementsPerNode(-1);
 110    }
 111    }