Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Do Mrz 27 2008 21:46:26 CET
file stats: LOC: 133   Methods: 7
NCLOC: 69   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ModuleLabelsCreator.java 50% 53,8% 71,4% 57,1%
coverage coverage
 1    /* $Id: ModuleLabelsCreator.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.FunctionDefinition;
 21    import org.qedeq.kernel.base.module.Import;
 22    import org.qedeq.kernel.base.module.Node;
 23    import org.qedeq.kernel.base.module.PredicateDefinition;
 24    import org.qedeq.kernel.common.DefaultSourceFileExceptionList;
 25    import org.qedeq.kernel.common.ModuleContext;
 26    import org.qedeq.kernel.common.ModuleDataException;
 27    import org.qedeq.kernel.common.ModuleLabels;
 28    import org.qedeq.kernel.dto.module.NodeVo;
 29    import org.qedeq.kernel.trace.Trace;
 30   
 31   
 32    /**
 33    * Create mapping from labels to {@link org.qedeq.kernel.dto.module.NodeVo} for a QEDEQ module.
 34    *
 35    * @version $Revision: 1.1 $
 36    * @author Michael Meyling
 37    */
 38    public final class ModuleLabelsCreator extends ControlVisitor {
 39   
 40    /** This class. */
 41    private static final Class CLASS = ModuleLabelsCreator.class;
 42   
 43    /** QEDEQ module labels. */
 44    private ModuleLabels labels;
 45   
 46    /**
 47    * Constructor.
 48    *
 49    * @param prop Internal QedeqBo.
 50    */
 51  149 public ModuleLabelsCreator(final KernelQedeqBo prop) {
 52  149 super(prop);
 53    }
 54   
 55    /**
 56    * Visit import. Loads referenced QEDEQ module and saves reference.
 57    *
 58    * @param imp Begin visit of this element.
 59    */
 60  141 public void visitEnter(final Import imp) {
 61  141 try {
 62  141 this.labels.addLabel(new ModuleContext(getCurrentContext()),
 63    imp.getLabel());
 64  141 Trace.param(CLASS, "visitEnter(Import)", "adding context", getCurrentContext());
 65    } catch (ModuleDataException me) {
 66  0 addModuleDataException(me);
 67  0 Trace.trace(CLASS, this, "visitEnter(Import)", me);
 68    }
 69    }
 70   
 71    /**
 72    * Visit import. Loads referenced QEDEQ module and saves reference.
 73    *
 74    * @param funcDef Begin visit of this element.
 75    */
 76  0 public void visitEnter(final FunctionDefinition funcDef) {
 77  0 try {
 78  0 this.labels.checkLabel(new ModuleContext(getCurrentContext()),
 79    funcDef.getName());
 80  0 Trace.param(CLASS, "visitEnter(FunctionDefinition)", "adding context",
 81    getCurrentContext());
 82    } catch (ModuleDataException me) {
 83  0 addModuleDataException(me);
 84  0 Trace.trace(CLASS, this, "visitEnter(FunctionDefinition)", me);
 85    }
 86    }
 87   
 88    /**
 89    * Visit import. Loads referenced QEDEQ module and saves reference.
 90    *
 91    * @param predDef Begin visit of this element.
 92    */
 93  0 public void visitEnter(final PredicateDefinition predDef) {
 94  0 try {
 95  0 this.labels.checkLabel(new ModuleContext(getCurrentContext()),
 96    predDef.getName());
 97  0 Trace.param(CLASS, "visitEnter(PredicateDefinition)", "adding context",
 98    getCurrentContext());
 99    } catch (ModuleDataException me) {
 100  0 addModuleDataException(me);
 101  0 Trace.trace(CLASS, this, "visitEnter(PredicateDefinition)", me);
 102    }
 103    }
 104   
 105    /**
 106    * Get QEDEQ module labels.
 107    *
 108    * @return QEDEQ module labels.
 109    * @throws DefaultSourceFileExceptionList Traverse lead to errors.
 110    */
 111  149 public ModuleLabels createLabels() throws DefaultSourceFileExceptionList {
 112  149 if (this.labels == null) {
 113  149 this.labels = new ModuleLabels();
 114  149 traverse();
 115    }
 116  143 return this.labels;
 117    }
 118   
 119  1358 public void visitEnter(final Node node) throws ModuleDataException {
 120  1358 try {
 121  1358 this.labels.addNode(getCurrentContext(), (NodeVo) node);
 122    } catch (ModuleDataException me) {
 123  6 addModuleDataException(me);
 124  6 Trace.trace(CLASS, this, "visitEnter(Node)", me);
 125    }
 126  1358 setBlocked(true); // block further traverse of sub nodes
 127    }
 128   
 129  1358 public void visitLeave(final Node node) {
 130  1358 setBlocked(false); // allow further traverse
 131    }
 132   
 133    }