Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Do Dez 29 2005 18:38:29 CET
file stats: LOC: 82   Methods: 3
NCLOC: 29   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ModuleLabels.java 75% 77,8% 66,7% 75%
coverage coverage
 1    /* $Id: ModuleLabels.java,v 1.9 2005/12/09 18:23:05 m31 Exp $
 2    *
 3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
 4    *
 5    * Copyright 2000-2005, 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 java.util.HashMap;
 21    import java.util.Map;
 22   
 23    import org.qedeq.kernel.bo.module.NodeBo;
 24   
 25   
 26    /**
 27    * Maps labels of an module to their elements.
 28    *
 29    * @version $Revision: 1.9 $
 30    * @author Michael Meyling
 31    */
 32    public final class ModuleLabels {
 33   
 34    /** Maps labels to business objects. */
 35    private final Map label2Bo;
 36   
 37    /** Maps labels to context of business objects. */
 38    private final Map label2Context;
 39   
 40    /**
 41    * Constructs a new empty module label list.
 42    */
 43  46 public ModuleLabels() {
 44  46 label2Bo = new HashMap();
 45  46 label2Context = new HashMap();
 46    }
 47   
 48    /**
 49    * Add node with certain id.
 50    *
 51    * @param node For this node.
 52    * @param context With this context.
 53    * @throws IllegalModuleDataException The <code>id</code> already exists or is
 54    * <code>null</code>.
 55    */
 56  38 public final void addNode(final Context context, final NodeBo node)
 57    throws IllegalModuleDataException {
 58  38 if (null == node.getId()) {
 59  0 throw new IllegalModuleDataException(10001, "An id was not defined.", context, null,
 60    null);
 61    }
 62  38 if (label2Bo.containsKey(node.getId())) {
 63  2 throw new IllegalModuleDataException(10001, "Id \"" + node.getId()
 64    + "\" defined more than once.", context,
 65    (Context) label2Context.get(node.getId()), null);
 66    }
 67  36 label2Bo.put(node.getId(), node);
 68    // don't forget to use the copy constructor because the context could change!
 69  36 label2Context.put(node.getId(), new Context(context));
 70    }
 71   
 72    /**
 73    * Get node for given label.
 74    *
 75    * @param label Label to search node for.
 76    * @return Node for given label. Maybe <code>null</code>.
 77    */
 78  0 public final NodeBo getNode(final String label) {
 79  0 return (NodeBo) label2Bo.get(label);
 80    }
 81   
 82    }