Clover coverage report -
Coverage timestamp: jeu. juin 15 2006 08:24:33 CEST
file stats: LOC: 88   Methods: 2
NCLOC: 33   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ASolverFactory.java 100% 85,7% 100% 90%
coverage coverage
 1    /**
 2    *
 3    */
 4    package org.sat4j.core;
 5   
 6    import java.lang.reflect.Method;
 7    import java.util.ArrayList;
 8    import java.util.List;
 9   
 10    import org.sat4j.specs.ISolver;
 11   
 12    /**
 13    * A solver factory is responsible to provide prebuilt solvers
 14    * to the end user.
 15    *
 16    * @author bourgeois
 17    */
 18    public abstract class ASolverFactory {
 19   
 20    /**
 21    * This methods returns names of solvers to be used with the method
 22    * getSolverByName().
 23    *
 24    * @return an array containing the names of all the solvers available in the
 25    * library.
 26    * @see #createSolverByName(String)
 27    */
 28  1 public String[] solverNames() {
 29  1 List<String> l = new ArrayList<String>();
 30  1 Method[] solvers = this.getClass().getDeclaredMethods();
 31  1 for (int i = 0; i < solvers.length; i++) {
 32  58 if (solvers[i].getParameterTypes().length == 0
 33    && solvers[i].getName().startsWith("new")) { //$NON-NLS-1$
 34  47 l.add(solvers[i].getName().substring(3));
 35    }
 36    }
 37  1 String[] names = new String[l.size()];
 38  1 l.toArray(names);
 39  1 return names;
 40    }
 41   
 42    /**
 43    * create a solver from its String name. the solvername Xxxx must map one of
 44    * the newXxxx methods.
 45    *
 46    * @param solvername
 47    * the name of the solver
 48    * @return an ISolver built using newSolvername. <code>null</code> if the
 49    * solvername doesn't map one of the method of the factory.
 50    */
 51  47 public ISolver createSolverByName(String solvername) {
 52  47 Class[] paramtypes = {};
 53  47 try {
 54  47 Method m = this.getClass()
 55    .getMethod("new" + solvername, paramtypes); //$NON-NLS-1$
 56  47 return (ISolver) m.invoke(null, (Object[]) null);
 57    } catch (Exception e) {
 58  0 e.printStackTrace();
 59    }
 60  0 return null;
 61    }
 62   
 63    /**
 64    * To obtain the default solver of the library.
 65    * The solver is suitable to solve huge SAT benchmarks.
 66    * It should reflect state-of-the-art SAT technologies.
 67    *
 68    * For solving small/easy SAT benchmarks, use lightSolver() instead.
 69    *
 70    * @return a solver from the factory
 71    * @see #lightSolver()
 72    */
 73    public abstract ISolver defaultSolver();
 74   
 75    /**
 76    * To obtain a solver that is suitable for solving
 77    * many small instances of SAT problems.
 78    *
 79    * The solver is not using sophisticated but costly
 80    * reasoning and avoids to allocate too much memory.
 81    *
 82    * For solving bigger SAT benchmarks, use defaultSolver() instead.
 83    *
 84    * @return a solver from the factory
 85    * @see #defaultSolver()
 86    */
 87    public abstract ISolver lightSolver();
 88    }