Clover coverage report - JGAP 3.1
Coverage timestamp: Mo Dez 11 2006 21:16:18 CET
file stats: LOC: 84   Methods: 2
NCLOC: 63   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
DefaultCompareToHandler.java 0% 0% 0% 0%
coverage
 1    /*
 2    * This file is part of JGAP.
 3    *
 4    * JGAP offers a dual license model containing the LGPL as well as the MPL.
 5    *
 6    * For licencing information please see the file license.txt included with JGAP
 7    * or have a look at the top of class org.jgap.Chromosome which representatively
 8    * includes the JGAP license policy applicable for any file delivered with JGAP.
 9    */
 10    package org.jgap.impl;
 11   
 12    import org.jgap.*;
 13   
 14    /**
 15    * Default implementation for comparing Comparables. Boolean values are also
 16    * covered with this handler as the Boolean class has no compareTo method.
 17    *
 18    * @author Klaus Meffert
 19    * @since 2.6
 20    */
 21    public class DefaultCompareToHandler
 22    implements ICompareToHandler {
 23    /** String containing the CVS revision. Read out via reflection!*/
 24    private static final String CVS_REVISION = "$Revision: 1.3 $";
 25   
 26  0 public boolean isHandlerFor(final Object a_obj, final Class a_clazz) {
 27  0 Class clazz;
 28  0 if (a_clazz == null) {
 29  0 if (a_obj == null) {
 30  0 return false;
 31    }
 32  0 clazz = a_obj.getClass();
 33    }
 34    else {
 35  0 clazz = a_clazz;
 36    }
 37  0 if (Comparable.class.isAssignableFrom(clazz)) {
 38  0 return true;
 39    }
 40    else {
 41  0 if (clazz != null && Boolean.class == clazz) {
 42  0 return true;
 43    }
 44    else {
 45  0 return false;
 46    }
 47    }
 48    }
 49   
 50  0 public Object perform(final Object a_obj, final Class a_class,
 51    final Object a_params)
 52    throws Exception {
 53  0 int i;
 54  0 if (a_obj == null) {
 55  0 if (a_params != null) {
 56  0 i = -1;
 57    }
 58    else {
 59  0 i = 0;
 60    }
 61    }
 62  0 else if (a_params == null) {
 63  0 i = 1;
 64    }
 65    else {
 66  0 if (a_obj.getClass() == Boolean.class) {
 67  0 boolean b1 = ((Boolean)a_obj).booleanValue();
 68  0 boolean b2 = ((Boolean)a_params).booleanValue();
 69  0 if (b1 == b2) {
 70  0 i = 0;
 71    }
 72  0 else if (b1) {
 73  0 i = 1;
 74    }
 75    else
 76  0 i = -1;
 77    }
 78    else {
 79  0 i = ( (Comparable) a_obj).compareTo(a_params);
 80    }
 81    }
 82  0 return new Integer(i);
 83    }
 84    }