Clover Coverage Report
Coverage timestamp: Sa Aug 2 2008 13:56:27 CEST
../../../../../../img/srcFileCovDistChart9.png 30% of files have more coverage
19   98   9   3,8
8   49   0,47   5
5     1,8  
1    
 
  QedeqBoDuplicateLanguageChecker       Line # 38 19 9 87,5% 0.875
 
  (10)
 
1    /* $Id: QedeqBoDuplicateLanguageChecker.java,v 1.1 2008/07/26 07:58:28 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.latex;
19   
20    import java.util.HashMap;
21    import java.util.Map;
22   
23    import org.qedeq.kernel.base.module.Latex;
24    import org.qedeq.kernel.base.module.LatexList;
25    import org.qedeq.kernel.bo.module.ControlVisitor;
26    import org.qedeq.kernel.bo.module.KernelQedeqBo;
27    import org.qedeq.kernel.common.DefaultSourceFileExceptionList;
28    import org.qedeq.kernel.common.ModuleContext;
29    import org.qedeq.kernel.common.ModuleDataException;
30   
31   
32    /**
33    * Checks if all formulas of a QEDEQ module are well formed.
34    *
35    * @version $Revision: 1.1 $
36    * @author Michael Meyling
37    */
 
38    public final class QedeqBoDuplicateLanguageChecker extends ControlVisitor {
39   
40    /**
41    * Constructor.
42    *
43    * @param bo BO QEDEQ module object.
44    */
 
45  48 toggle private QedeqBoDuplicateLanguageChecker(final KernelQedeqBo bo) {
46  48 super(bo);
47    }
48   
49    /**
50    * Checks if all formulas of a QEDEQ module are well formed.
51    *
52    * @param prop QEDEQ BO.
53    * @throws DefaultSourceFileExceptionList An error occured.
54    */
 
55  48 toggle public static void check(final KernelQedeqBo prop)
56    throws DefaultSourceFileExceptionList {
57  48 final QedeqBoDuplicateLanguageChecker checker
58    = new QedeqBoDuplicateLanguageChecker(prop);
59  48 checker.traverse();
60    }
61   
 
62  5026 toggle public final void visitEnter(final LatexList list) throws ModuleDataException {
63  5026 if (list == null) {
64  0 return;
65    }
66  5026 final String context = getCurrentContext().getLocationWithinModule();
67  5026 final Map languages = new HashMap();
68  14180 for (int i = 0; i < list.size(); i++) {
69  9156 final Latex latex = list.get(i);
70  9156 setLocationWithinModule(context + ".get(" + i + ")");
71  9156 if (latex == null) {
72  0 throw new LatexListDataException(1000, "Null pointer not permitted.",
73    getCurrentContext());
74    }
75  9156 if (languages.containsKey(latex.getLanguage())) {
76  2 throw new LatexListDataException(1001, "Language entry exists already",
77    getCurrentContext(), (ModuleContext) languages.get(latex.getLanguage()));
78    }
79  9154 languages.put(list.get(i).getLanguage(), getCurrentContext());
80    }
81  5024 setLocationWithinModule(context);
82  5024 setBlocked(true);
83    }
84   
 
85  5024 toggle public final void visitLeave(final LatexList list) {
86  5024 setBlocked(false);
87    }
88   
89    /**
90    * Set location information where are we within the original module.
91    *
92    * @param locationWithinModule Location within module.
93    */
 
94  14180 toggle public void setLocationWithinModule(final String locationWithinModule) {
95  14180 getCurrentContext().setLocationWithinModule(locationWithinModule);
96    }
97   
98    }