Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../../img/srcFileCovDistChart9.png 45% of files have more coverage
18   88   8   4.5
8   47   0.44   4
4     2  
1    
 
  QedeqBoDuplicateLanguageChecker       Line # 37 18 8 86.7% 0.8666667
 
  (17)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>.
4    *
5    * "Hilbert II" is free software; you can redistribute
6    * it and/or modify it under the terms of the GNU General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10    * This program is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13    * GNU General Public License for more details.
14    */
15   
16    package org.qedeq.kernel.bo.service.latex;
17   
18    import java.util.HashMap;
19    import java.util.Map;
20   
21    import org.qedeq.kernel.bo.module.ControlVisitor;
22    import org.qedeq.kernel.bo.module.InternalServiceCall;
23    import org.qedeq.kernel.bo.module.KernelQedeqBo;
24    import org.qedeq.kernel.se.base.module.Latex;
25    import org.qedeq.kernel.se.base.module.LatexList;
26    import org.qedeq.kernel.se.common.ModuleContext;
27    import org.qedeq.kernel.se.common.ModuleDataException;
28    import org.qedeq.kernel.se.common.Service;
29    import org.qedeq.kernel.se.common.SourceFileExceptionList;
30   
31   
32    /**
33    * Checks if no duplicate language entries exist.
34    *
35    * @author Michael Meyling
36    */
 
37    public final class QedeqBoDuplicateLanguageChecker extends ControlVisitor {
38   
39    /**
40    * Checks if all formulas of a QEDEQ module are well formed.
41    *
42    * @param call Service process we work in.
43    * @throws SourceFileExceptionList An error occurred.
44    */
 
45  102 toggle public static void check(final InternalServiceCall call) throws SourceFileExceptionList {
46  102 final QedeqBoDuplicateLanguageChecker checker
47    = new QedeqBoDuplicateLanguageChecker(call.getService(), call.getKernelQedeq());
48  102 checker.traverse(call.getInternalServiceProcess());
49    }
50   
51    /**
52    * Constructor.
53    *
54    * @param service Service we work for.
55    * @param bo BO QEDEQ module object.
56    */
 
57  102 toggle private QedeqBoDuplicateLanguageChecker(final Service service, final KernelQedeqBo bo) {
58  102 super(service, bo);
59    }
60   
 
61  7746 toggle public final void visitEnter(final LatexList list) throws ModuleDataException {
62  7746 if (list == null) {
63  0 return;
64    }
65  7746 final String context = getCurrentContext().getLocationWithinModule();
66  7746 final Map languages = new HashMap();
67  21006 for (int i = 0; i < list.size(); i++) {
68  13262 final Latex latex = list.get(i);
69  13262 setLocationWithinModule(context + ".get(" + i + ")");
70  13262 if (latex == null) {
71  0 throw new LatexListDataException(1000, "Null pointer not permitted.",
72    getCurrentContext());
73    }
74  13262 if (languages.containsKey(latex.getLanguage())) {
75  2 throw new LatexListDataException(1001, "Language entry exists already",
76    getCurrentContext(), (ModuleContext) languages.get(latex.getLanguage()));
77    }
78  13260 languages.put(list.get(i).getLanguage(), getCurrentContext());
79    }
80  7744 setLocationWithinModule(context);
81  7744 setBlocked(true);
82    }
83   
 
84  7744 toggle public final void visitLeave(final LatexList list) {
85  7744 setBlocked(false);
86    }
87   
88    }