Clover Coverage Report
Coverage timestamp: Sa Aug 2 2008 13:56:27 CEST
../../../../../img/srcFileCovDistChart8.png 47% of files have more coverage
39   121   12   9,75
16   69   0,31   4
4     3  
1    
 
  ModuleConstantsExistenceChecker       Line # 32 39 12 72,9% 0.7288136
 
  (21)
 
1    /* $Id: ModuleConstantsExistenceChecker.java,v 1.1 2008/07/26 07:58:29 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.service;
19   
20    import org.qedeq.kernel.bo.ModuleReferenceList;
21    import org.qedeq.kernel.bo.module.DefaultExistenceChecker;
22    import org.qedeq.kernel.bo.module.KernelQedeqBo;
23    import org.qedeq.kernel.common.ModuleDataException;
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 KernelQedeqBo 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  62 toggle public ModuleConstantsExistenceChecker(final KernelQedeqBo prop) throws ModuleDataException {
45  62 super();
46  62 this.prop = prop;
47  62 init();
48    }
49   
50    /**
51    * Check if required QEDEQ modules mix without problems. If for example the identity operator
52    * is defined in two different modules in two different ways we have got a problem.
53    * Also the basic properties (for example
54    * {@link DefaultExistenceChecker#setIdentityOperatorDefined(boolean, String)} and
55    * {@link DefaultExistenceChecker#setClassOperatorExists(boolean)}) are set accordingly.
56    *
57    * @throws ModuleDataException Required modules doesn't mix.
58    */
 
59  62 toggle public final void init() throws ModuleDataException {
60  62 clear();
61  62 boolean identityOperatorExists = false;
62  62 boolean classOperatorExists = false;
63  62 final ModuleReferenceList list = prop.getRequiredModules();
64  62 String identityOperator = null;
65  98 for (int i = 0; i < list.size(); i++) {
66  36 final KernelQedeqBo bo = (KernelQedeqBo) list
67    .getQedeqBo(i);
68  36 if (bo.getExistenceChecker().equalityOperatorExists()) {
69  20 if (identityOperatorExists) {
70    // FIXME mime 20089116: check if both definitions are the same (Module URL ==)
71  0 throw new IdentityOperatorAlreadyExistsException(123476,
72    "identity operator already defined", list.getModuleContext(i));
73    }
74  20 identityOperatorExists = true;
75  20 identityOperator = list.getLabel(i) + "."
76    + bo.getExistenceChecker().getIdentityOperator();
77    }
78  36 if (bo.getExistenceChecker().classOperatorExists()) {
79  0 if (classOperatorExists) {
80    // FIXME mime 20089116: check if both definitions are the same (Module URL ==)
81  0 throw new ClassOperatorAlreadyExistsException(123478,
82    "class operator already defined", list.getModuleContext(i));
83    }
84  0 classOperatorExists = true;
85    }
86    }
87  62 setIdentityOperatorDefined(identityOperatorExists, identityOperator);
88  62 setClassOperatorExists(classOperatorExists);
89    }
90   
 
91  4268 toggle public boolean predicateExists(final String name, final int arguments) {
92  4268 final int external = name.indexOf('.');
93  4268 if (external < 0) {
94  3172 return super.predicateExists(name, arguments);
95    }
96  1096 final String label = name.substring(0, external);
97  1096 final ModuleReferenceList ref = prop.getRequiredModules();
98   
99  1096 final KernelQedeqBo newProp = (KernelQedeqBo) ref
100    .getQedeqBo(label);
101  1096 if (newProp == null) {
102  0 return false;
103    }
104  1096 final String shortName = name.substring(external + 1);
105  1096 return newProp.getExistenceChecker().predicateExists(shortName, arguments);
106    }
107   
 
108  1440 toggle public boolean functionExists(final String name, final int arguments) {
109  1440 final int external = name.indexOf(".");
110  1440 if (external < 0) {
111  1440 return super.functionExists(name, arguments);
112    }
113  0 final String label = name.substring(0, external);
114  0 final ModuleReferenceList ref = prop.getRequiredModules();
115  0 final KernelQedeqBo newProp = (KernelQedeqBo) ref
116    .getQedeqBo(label);
117  0 final String shortName = name.substring(external + 1);
118  0 return newProp.getExistenceChecker().functionExists(shortName, arguments);
119    }
120   
121    }