Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Sa Dez 22 2007 01:35:21 CET
file stats: LOC: 83   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.4 2007/12/21 23:33:46 m31 Exp $
 2    *
 3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
 4    *
 5    * Copyright 2000-2007, 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.module;
 19   
 20    import java.util.HashMap;
 21    import java.util.Map;
 22   
 23    import org.qedeq.kernel.dto.module.NodeVo;
 24   
 25   
 26    /**
 27    * Maps labels of an QEDEQ module to their elements.
 28    *
 29    * @version $Revision: 1.4 $
 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  484 public ModuleLabels() {
 44  484 label2Bo = new HashMap();
 45  484 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  1448 public final void addNode(final ModuleContext context, final NodeVo node)
 57    throws IllegalModuleDataException {
 58  1448 if (null == node.getId()) {
 59  0 throw new IllegalModuleDataException(10001, "An id was not defined.", context, null,
 60    null); // LATER mime 20071026: organize exception codes
 61    }
 62  1448 if (label2Bo.containsKey(node.getId())) {
 63    // LATER mime 20071026: organize exception codes
 64  5 throw new IllegalModuleDataException(10002, "Id \"" + node.getId()
 65    + "\" defined more than once.", context,
 66    (ModuleContext) label2Context.get(node.getId()), null);
 67    }
 68  1443 label2Bo.put(node.getId(), node);
 69    // don't forget to use the copy constructor because the context could change!
 70  1443 label2Context.put(node.getId(), new ModuleContext(context));
 71    }
 72   
 73    /**
 74    * Get node for given id.
 75    *
 76    * @param id Label to search node for.
 77    * @return Node for given label. Maybe <code>null</code>.
 78    */
 79  0 public final NodeVo getNode(final String id) {
 80  0 return (NodeVo) label2Bo.get(id);
 81    }
 82   
 83    }