Clover Coverage Report
Coverage timestamp: Sa Aug 2 2008 13:56:27 CEST
../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
17   133   12   2,12
6   52   0,71   8
8     1,5  
1    
 
  ControlVisitor       Line # 35 17 12 93,5% 0.9354839
 
  (34)
 
1    /* $Id: ControlVisitor.java,v 1.1 2008/07/26 07:58:30 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.module;
19   
20    import org.qedeq.kernel.common.DefaultSourceFileExceptionList;
21    import org.qedeq.kernel.common.ModuleContext;
22    import org.qedeq.kernel.common.ModuleDataException;
23    import org.qedeq.kernel.common.SourceFileException;
24    import org.qedeq.kernel.visitor.AbstractModuleVisitor;
25    import org.qedeq.kernel.visitor.QedeqNotNullTraverser;
26   
27   
28    /**
29    * Basic visitor that gives some error collecting features. Also hides the
30    * traverser that does the work.
31    *
32    * @version $Revision: 1.1 $
33    * @author Michael Meyling
34    */
 
35    public abstract class ControlVisitor extends AbstractModuleVisitor {
36   
37    /** QEDEQ BO object to work on. */
38    private final KernelQedeqBo prop;
39   
40    /** Traverse QEDEQ module with this traverser. */
41    private final QedeqNotNullTraverser traverser;
42   
43    /** List of Exceptions during Module load. */
44    private DefaultSourceFileExceptionList errorList;
45   
46   
47    /**
48    * Constructor.
49    * @param prop Internal QedeqBo.
50    */
 
51  409 toggle protected ControlVisitor(final KernelQedeqBo prop) {
52  409 if (prop.getQedeq() == null) {
53  0 throw new NullPointerException("Programming error, Module not loaded: "
54    + prop.getModuleAddress());
55    }
56  409 this.prop = prop;
57  409 this.traverser = new QedeqNotNullTraverser(prop.getModuleAddress(), this);
58    }
59   
60    /**
61    * Get QedeqBo.
62    *
63    * @return QedeqBo.
64    */
 
65  652 toggle protected KernelQedeqBo getQedeqBo() {
66  652 return this.prop;
67    }
68   
69    /**
70    * Start traverse of QedeqBo. If during the traverse a {@link ModuleDataException}
71    * occurs it is thrown till high level and transformed into a
72    * {@link DefaultSourceFileExceptionList}. Otherwise all collected exceptions
73    * (via {@link #addModuleDataException(ModuleDataException)} and
74    * {@link #addSourceFileException(SourceFileException)}) are thrown.
75    *
76    * @throws DefaultSourceFileExceptionList All collected exceptions.
77    */
 
78  409 toggle protected void traverse() throws DefaultSourceFileExceptionList {
79  409 try {
80  409 this.traverser.accept(this.prop.getQedeq());
81    } catch (ModuleDataException me) {
82  2 addModuleDataException(me);
83    }
84  409 if (errorList != null) {
85  17 throw errorList;
86    }
87    }
88   
 
89  33890 toggle protected ModuleContext getCurrentContext() {
90  33890 return this.traverser.getCurrentContext();
91    }
92   
93    /**
94    * Get list of exceptions that occurred during loading referenced modules.
95    *
96    * @return Exception list.
97    */
 
98  315 toggle public DefaultSourceFileExceptionList getSourceFileExceptionList() {
99  315 return errorList;
100    }
101   
102    /**
103    * Add exception to error collection.
104    *
105    * @param me Exception to be added.
106    */
 
107  19 toggle protected void addModuleDataException(final ModuleDataException me) {
108  19 addSourceFileException(prop.createSourceFileException(me));
109    }
110   
111    /**
112    * Add exception to error collection.
113    *
114    * @param sf Exception to be added.
115    */
 
116  19 toggle protected void addSourceFileException(final SourceFileException sf) {
117  19 if (errorList == null) {
118  17 errorList = new DefaultSourceFileExceptionList(sf);
119    } else {
120  2 errorList.add(sf);
121    }
122    }
123   
124    /**
125    * Set if further traverse is blocked.
126    *
127    * @param blocked Further traverse blocked?
128    */
 
129  14149 toggle protected void setBlocked(final boolean blocked) {
130  14149 traverser.setBlocked(blocked);
131    }
132   
133    }