Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Do Mrz 27 2008 21:46:26 CET
file stats: LOC: 120   Methods: 4
NCLOC: 68   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ModuleConstantsExistenceChecker.java 62,5% 74,4% 100% 72,9%
coverage coverage
 1    /* $Id: ModuleConstantsExistenceChecker.java,v 1.2 2008/03/27 05:16:24 m31 Exp $
 2    *
 3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
 4    *
 5    * Copyright 2000-2008, Michael Meyling <mime@qedeq.org>.
 6    *
 7    * "Hilbert II" is free software; you can redistribute
 8    * it and/or modify it under the terms of the GNU General Public
 9    * License as published by the Free Software Foundation; either
 10    * version 2 of the License, or (at your option) any later version.
 11    *
 12    * This program is distributed in the hope that it will be useful,
 13    * but WITHOUT ANY WARRANTY; without even the implied warranty of
 14    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 15    * GNU General Public License for more details.
 16    */
 17   
 18    package org.qedeq.kernel.bo.control;
 19   
 20    import org.qedeq.kernel.bo.logic.DefaultExistenceChecker;
 21    import org.qedeq.kernel.common.ModuleDataException;
 22    import org.qedeq.kernel.common.ModuleReferenceList;
 23   
 24   
 25    /**
 26    * Checks if all formulas of a QEDEQ module are well formed.
 27    *
 28    * @version $Revision: 1.2 $
 29    * @author Michael Meyling
 30    */
 31    public class ModuleConstantsExistenceChecker extends DefaultExistenceChecker {
 32   
 33    /** QEDEQ module properties. */
 34    private final KernelQedeqBo prop;
 35   
 36    /**
 37    * Constructor.
 38    *
 39    * @param prop QEDEQ module properties object.
 40    * @throws ModuleDataException Referenced QEDEQ modules are already inconsistent: they doesn't
 41    * mix.
 42    */
 43  90 public ModuleConstantsExistenceChecker(final KernelQedeqBo prop) throws ModuleDataException {
 44  90 super();
 45  90 this.prop = prop;
 46  90 init();
 47    }
 48   
 49    /**
 50    * Check if required QEDEQ modules mix without problems. If for example the identity operator
 51    * is defined in two different modules in two different ways we have got a problem.
 52    * Also the basic properties (for example
 53    * {@link DefaultExistenceChecker#setIdentityOperatorDefined(boolean, String)} and
 54    * {@link DefaultExistenceChecker#setClassOperatorExists(boolean)}) are set accordingly.
 55    *
 56    * @throws ModuleDataException Required modules doesn't mix.
 57    */
 58  90 public void init() throws ModuleDataException {
 59  90 clear();
 60  90 boolean identityOperatorExists = false;
 61  90 boolean classOperatorExists = false;
 62  90 final ModuleReferenceList list = prop.getRequiredModules();
 63  90 String identityOperator = null;
 64  90 for (int i = 0; i < list.size(); i++) {
 65  78 final KernelQedeqBo bo = (KernelQedeqBo) list
 66    .getQedeqBo(i);
 67  78 if (bo.getExistenceChecker().equalityOperatorExists()) {
 68  26 if (identityOperatorExists) {
 69    // FIXME mime 20089116: check if both definitions are the same (Module URL ==)
 70  0 throw new IdentityOperatorAlreadyExistsException(123476,
 71    "identity operator already defined", list.getModuleContext(i));
 72    }
 73  26 identityOperatorExists = true;
 74  26 identityOperator = list.getLabel(i) + "."
 75    + bo.getExistenceChecker().getIdentityOperator();
 76    }
 77  78 if (bo.getExistenceChecker().classOperatorExists()) {
 78  0 if (classOperatorExists) {
 79    // FIXME mime 20089116: check if both definitions are the same (Module URL ==)
 80  0 throw new ClassOperatorAlreadyExistsException(123478,
 81    "class operator already defined", list.getModuleContext(i));
 82    }
 83  0 classOperatorExists = true;
 84    }
 85    }
 86  90 setIdentityOperatorDefined(identityOperatorExists, identityOperator);
 87  90 setClassOperatorExists(classOperatorExists);
 88    }
 89   
 90  4479 public boolean predicateExists(final String name, final int arguments) {
 91  4479 final int external = name.indexOf(".");
 92  4479 if (external < 0) {
 93  3370 return super.predicateExists(name, arguments);
 94    }
 95  1109 final String label = name.substring(0, external);
 96  1109 final ModuleReferenceList ref = prop.getRequiredModules();
 97   
 98  1109 final KernelQedeqBo newProp = (KernelQedeqBo) ref
 99    .getQedeqBo(label);
 100  1109 if (newProp == null) {
 101  0 return false;
 102    }
 103  1109 final String shortName = name.substring(external + 1);
 104  1109 return newProp.getExistenceChecker().predicateExists(shortName, arguments);
 105    }
 106   
 107  1440 public boolean functionExists(final String name, final int arguments) {
 108  1440 final int external = name.indexOf(".");
 109  1440 if (external < 0) {
 110  1440 return super.functionExists(name, arguments);
 111    }
 112  0 final String label = name.substring(0, external);
 113  0 final ModuleReferenceList ref = prop.getRequiredModules();
 114  0 final KernelQedeqBo newProp = (KernelQedeqBo) ref
 115    .getQedeqBo(label);
 116  0 final String shortName = name.substring(external + 1);
 117  0 return newProp.getExistenceChecker().functionExists(shortName, arguments);
 118    }
 119   
 120    }