Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Do Mrz 27 2008 21:46:26 CET
file stats: LOC: 109   Methods: 5
NCLOC: 42   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
LoadDirectlyRequiredModules.java - 100% 100% 100%
coverage
 1    /* $Id: LoadDirectlyRequiredModules.java,v 1.1 2008/03/27 05:16:24 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.control;
 19   
 20    import org.qedeq.kernel.base.module.Import;
 21    import org.qedeq.kernel.base.module.ImportList;
 22    import org.qedeq.kernel.common.ModuleDataException;
 23    import org.qedeq.kernel.common.SourceFileExceptionList;
 24    import org.qedeq.kernel.trace.Trace;
 25   
 26   
 27    /**
 28    * Load all required QEDEQ modules.
 29    *
 30    * @version $Revision: 1.1 $
 31    * @author Michael Meyling
 32    */
 33    public final class LoadDirectlyRequiredModules extends ControlVisitor {
 34   
 35    /** This class. */
 36    private static final Class CLASS = LoadDirectlyRequiredModules.class;
 37   
 38    /** Kernel services. */
 39    private final DefaultInternalKernelServices services;
 40   
 41    /** List of required QEDEQ modules. */
 42    private final KernelModuleReferenceList required;
 43   
 44    /**
 45    * Constructor.
 46    *
 47    * @param prop Internal QedeqBo.
 48    * @param services Internal kernel services.
 49    */
 50  151 LoadDirectlyRequiredModules(final KernelQedeqBo prop,
 51    final DefaultInternalKernelServices services) {
 52  151 super(prop);
 53  151 this.services = services;
 54  151 this.required = new KernelModuleReferenceList();
 55    }
 56   
 57    /**
 58    * Load all directly imported QEDEQ modules for a given QEDEQ module.
 59    *
 60    * @return List of all directly imported QEDEQ modules.
 61    * @throws SourceFileExceptionList Failure(s).
 62    */
 63  151 KernelModuleReferenceList load()
 64    throws SourceFileExceptionList {
 65  151 traverse();
 66  150 return required;
 67    }
 68   
 69    /**
 70    * Get list of directly referenced modules.
 71    *
 72    * @return List of directly required modules.
 73    */
 74  161 KernelModuleReferenceList getRequired() {
 75  161 return required;
 76    }
 77   
 78    /**
 79    * Visit import. Loads referenced QEDEQ module and saves reference.
 80    *
 81    * @param imp Begin visit of this element.
 82    * @throws ModuleDataException Major problem occurred.
 83    */
 84  162 public void visitEnter(final Import imp) throws ModuleDataException {
 85  162 try {
 86  162 final KernelQedeqBo propNew = services.loadModule(getQedeqBo().getModuleAddress(),
 87    imp.getSpecification());
 88  161 getRequired().addLabelUnique(getCurrentContext(), imp.getLabel(), propNew);
 89  161 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(), getCurrentContext());
 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  104 public void visitLeave(final ImportList imports) {
 106  104 setBlocked(true); // block further traverse
 107    }
 108   
 109    }