Clover Coverage Report
Coverage timestamp: Sa Aug 2 2008 13:56:27 CEST
../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
15   109   6   3
0   45   0,4   5
5     1,2  
1    
 
  LoadDirectlyRequiredModules       Line # 37 15 6 100% 1.0
 
  (27)
 
1    /* $Id: LoadDirectlyRequiredModules.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.base.trace.Trace;
21    import org.qedeq.kernel.base.module.Import;
22    import org.qedeq.kernel.base.module.ImportList;
23    import org.qedeq.kernel.bo.module.ControlVisitor;
24    import org.qedeq.kernel.bo.module.KernelModuleReferenceList;
25    import org.qedeq.kernel.bo.module.KernelQedeqBo;
26    import org.qedeq.kernel.common.ModuleContext;
27    import org.qedeq.kernel.common.ModuleDataException;
28    import org.qedeq.kernel.common.SourceFileExceptionList;
29   
30   
31    /**
32    * Load all required QEDEQ modules.
33    *
34    * @version $Revision: 1.1 $
35    * @author Michael Meyling
36    */
 
37    public final class LoadDirectlyRequiredModules extends ControlVisitor {
38   
39    /** This class. */
40    private static final Class CLASS = LoadDirectlyRequiredModules.class;
41   
42    /** List of required QEDEQ modules. */
43    private final KernelModuleReferenceList required;
44   
45    /**
46    * Constructor.
47    *
48    * @param prop Internal QedeqBo.
49    */
 
50  158 toggle LoadDirectlyRequiredModules(final KernelQedeqBo prop) {
51  158 super(prop);
52  158 this.required = new KernelModuleReferenceList();
53    }
54   
55    /**
56    * Load all directly imported QEDEQ modules for a given QEDEQ module.
57    *
58    * @return List of all directly imported QEDEQ modules.
59    * @throws SourceFileExceptionList Failure(s).
60    */
 
61  158 toggle KernelModuleReferenceList load()
62    throws SourceFileExceptionList {
63  158 traverse();
64  157 return required;
65    }
66   
67    /**
68    * Get list of directly referenced modules.
69    *
70    * @return List of directly required modules.
71    */
 
72  187 toggle KernelModuleReferenceList getRequired() {
73  187 return required;
74    }
75   
76    /**
77    * Visit import. Loads referenced QEDEQ module and saves reference.
78    *
79    * @param imp Begin visit of this element.
80    * @throws ModuleDataException Major problem occurred.
81    */
 
82  188 toggle public void visitEnter(final Import imp) throws ModuleDataException {
83  188 final ModuleContext context = getCurrentContext();
84  188 context.setLocationWithinModule(context.getLocationWithinModule() + ".getLabel()");
85  188 try {
86  188 final KernelQedeqBo propNew = getQedeqBo().getKernelServices().loadModule(
87    getQedeqBo().getModuleAddress(), imp.getSpecification());
88  187 getRequired().addLabelUnique(context, imp.getLabel(), propNew);
89  187 Trace.param(CLASS, "visitEnter(Import)", "adding context", getCurrentContext());
90    } catch (SourceFileExceptionList e) {
91  1 final ModuleDataException me = new LoadRequiredModuleException(e.get(0).getErrorCode(),
92    "import of module with label \"" + imp.getLabel() + "\" failed: "
93    + e.get(0).getMessage(), context);
94    // TODO mime 20080227: also include reference area in sf creation?
95  1 addModuleDataException(me);
96  1 Trace.trace(CLASS, this, "visitEnter(Import)", e);
97    }
98    }
99   
100    /**
101    * End of visit of import list. Blocks further visits.
102    *
103    * @param imports This visit has just ended.
104    */
 
105  121 toggle public void visitLeave(final ImportList imports) {
106  121 setBlocked(true); // block further traverse
107    }
108   
109    }