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