Clover Coverage Report
Coverage timestamp: Fri Feb 14 2014 07:28:57 UTC
../../../../../../img/srcFileCovDistChart9.png 45% of files have more coverage
18   89   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-2014, 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.InternalModuleServiceCall;
22    import org.qedeq.kernel.bo.module.KernelQedeqBo;
23    import org.qedeq.kernel.bo.service.basis.ControlVisitor;
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  107 toggle public static void check(final InternalModuleServiceCall call) throws SourceFileExceptionList {
46    // TODO 20140125 m31: don't cast to KernelQedeqBo
47  107 final QedeqBoDuplicateLanguageChecker checker
48    = new QedeqBoDuplicateLanguageChecker(call.getService(), (KernelQedeqBo) call.getQedeq());
49  107 checker.traverse(call.getInternalServiceProcess());
50    }
51   
52    /**
53    * Constructor.
54    *
55    * @param service Service we work for.
56    * @param bo BO QEDEQ module object.
57    */
 
58  107 toggle private QedeqBoDuplicateLanguageChecker(final Service service, final KernelQedeqBo bo) {
59  107 super(service, bo);
60    }
61   
 
62  7816 toggle public final void visitEnter(final LatexList list) throws ModuleDataException {
63  7816 if (list == null) {
64  0 return;
65    }
66  7816 final String context = getCurrentContext().getLocationWithinModule();
67  7816 final Map languages = new HashMap();
68  21146 for (int i = 0; i < list.size(); i++) {
69  13332 final Latex latex = list.get(i);
70  13332 setLocationWithinModule(context + ".get(" + i + ")");
71  13332 if (latex == null) {
72  0 throw new LatexListDataException(1000, "Null pointer not permitted.",
73    getCurrentContext());
74    }
75  13332 if (languages.containsKey(latex.getLanguage())) {
76  2 throw new LatexListDataException(1001, "Language entry exists already",
77    getCurrentContext(), (ModuleContext) languages.get(latex.getLanguage()));
78    }
79  13330 languages.put(list.get(i).getLanguage(), getCurrentContext());
80    }
81  7814 setLocationWithinModule(context);
82  7814 setBlocked(true);
83    }
84   
 
85  7814 toggle public final void visitLeave(final LatexList list) {
86  7814 setBlocked(false);
87    }
88   
89    }