Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Sa Jan 26 2008 14:11:34 CET
file stats: LOC: 117   Methods: 4
NCLOC: 66   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ModuleConstantsExistenceChecker.java 62,5% 73,7% 100% 72,4%
coverage coverage
 1    /* $Id: ModuleConstantsExistenceChecker.java,v 1.1 2008/01/26 12:39:09 m31 Exp $
 2    *
 3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
 4    *
 5    * Copyright 2000-2007, 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.bo.module.ModuleDataException;
 22    import org.qedeq.kernel.bo.module.ModuleProperties;
 23    import org.qedeq.kernel.bo.module.ModuleReferenceList;
 24   
 25   
 26    /**
 27    * Checks if all formulas of a QEDEQ module are well formed.
 28    *
 29    * @version $Revision: 1.1 $
 30    * @author Michael Meyling
 31    */
 32    public class ModuleConstantsExistenceChecker extends DefaultExistenceChecker {
 33   
 34    /** QEDEQ module properties. */
 35    private final ModuleProperties prop;
 36   
 37    /**
 38    * Constructor.
 39    *
 40    * @param prop QEDEQ module properties object.
 41    * @throws ModuleDataException Referenced QEDEQ modules are already inconsistent: they doesn't
 42    * mix.
 43    */
 44  59 public ModuleConstantsExistenceChecker(final ModuleProperties prop)
 45    throws ModuleDataException {
 46  59 super();
 47  59 this.prop = prop;
 48  59 init();
 49    }
 50   
 51    /**
 52    * Check if required QEDEQ modules mix without problems. If for example the identity operator
 53    * is defined in two different modules in two different ways we have got a problem.
 54    * Also the basic properties (for example
 55    * {@link DefaultExistenceChecker#setIdentityOperatorDefined(boolean, String)} and
 56    * {@link DefaultExistenceChecker#setClassOperatorExists(boolean)}) are set accordingly.
 57    *
 58    * @throws ModuleDataException Required modules doesn't mix.
 59    */
 60  59 public void init() throws ModuleDataException {
 61  59 clear();
 62  59 boolean identityOperatorExists = false;
 63  59 boolean classOperatorExists = false;
 64  59 final ModuleReferenceList list = prop.getRequiredModules();
 65  59 String identityOperator = null;
 66  59 for (int i = 0; i < list.size(); i++) {
 67  38 if (list.getModuleProperties(i).getExistenceChecker().equalityOperatorExists()) {
 68  22 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  22 identityOperatorExists = true;
 74  22 identityOperator = list.getLabel(i) + "."
 75    + list.getModuleProperties(i).getExistenceChecker().getIdentityOperator();
 76    }
 77  38 if (list.getModuleProperties(i).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  59 setIdentityOperatorDefined(identityOperatorExists, identityOperator);
 87  59 setClassOperatorExists(classOperatorExists);
 88    }
 89   
 90  4223 public boolean predicateExists(final String name, final int arguments) {
 91  4223 final int external = name.indexOf(".");
 92  4223 if (external < 0) {
 93  3139 return super.predicateExists(name, arguments);
 94    }
 95  1084 final String label = name.substring(0, external);
 96  1084 final ModuleReferenceList ref = prop.getRequiredModules();
 97  1084 final ModuleProperties newProp = ref.getModuleProperties(label);
 98  1084 if (newProp == null) {
 99  0 return false;
 100    }
 101  1084 final String shortName = name.substring(external + 1);
 102  1084 return newProp.getExistenceChecker().predicateExists(shortName, arguments);
 103    }
 104   
 105  1440 public boolean functionExists(final String name, final int arguments) {
 106  1440 final int external = name.indexOf(".");
 107  1440 if (external < 0) {
 108  1440 return super.functionExists(name, arguments);
 109    }
 110  0 final String label = name.substring(0, external);
 111  0 final ModuleReferenceList ref = prop.getRequiredModules();
 112  0 final ModuleProperties newProp = ref.getModuleProperties(label);
 113  0 final String shortName = name.substring(external + 1);
 114  0 return newProp.getExistenceChecker().functionExists(shortName, arguments);
 115    }
 116   
 117    }