Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Do Mai 10 2007 03:16:40 CEST
file stats: LOC: 103   Methods: 7
NCLOC: 57   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
UsedByListVo.java 100% 100% 100% 100%
coverage
 1    /* $Id: UsedByListVo.java,v 1.7 2007/05/10 00:37:50 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.dto.module;
 19   
 20    import java.util.ArrayList;
 21    import java.util.List;
 22   
 23    import org.qedeq.kernel.base.module.Specification;
 24    import org.qedeq.kernel.base.module.UsedByList;
 25    import org.qedeq.kernel.utility.EqualsUtility;
 26   
 27   
 28    /**
 29    * List of modules which use the current one.
 30    *
 31    * @version $Revision: 1.7 $
 32    * @author Michael Meyling
 33    */
 34    public class UsedByListVo implements UsedByList {
 35   
 36    /** Contains all list elements. */
 37    private final List list;
 38   
 39    /**
 40    * Constructs an empty list of used by modules.
 41    */
 42  98 public UsedByListVo() {
 43  98 this.list = new ArrayList();
 44   
 45    }
 46   
 47    /**
 48    * Add specification of module.
 49    *
 50    * @param specification Module specification
 51    */
 52  85 public final void add(final SpecificationVo specification) {
 53  85 list.add(specification);
 54    }
 55   
 56  815 public final int size() {
 57  815 return list.size();
 58    }
 59   
 60  598 public final Specification get(final int index) {
 61  598 return (Specification) list.get(index);
 62    }
 63   
 64  115 public boolean equals(final Object obj) {
 65  115 if (!(obj instanceof UsedByListVo)) {
 66  6 return false;
 67    }
 68  109 final UsedByListVo otherList = (UsedByListVo) obj;
 69  109 if (size() != otherList.size()) {
 70  7 return false;
 71    }
 72  102 for (int i = 0; i < size(); i++) {
 73  101 if (!EqualsUtility.equals(get(i), otherList.get(i))) {
 74  2 return false;
 75    }
 76    }
 77  100 return true;
 78    }
 79   
 80  79 public int hashCode() {
 81  79 int hash = 0;
 82  79 for (int i = 0; i < size(); i++) {
 83  77 hash = hash ^ (i + 1);
 84  77 if (get(i) != null) {
 85  76 hash = hash ^ get(i).hashCode();
 86    }
 87    }
 88  79 return hash;
 89    }
 90   
 91  61 public String toString() {
 92  61 final StringBuffer buffer = new StringBuffer("List of modules that use the current one:\n");
 93  61 for (int i = 0; i < size(); i++) {
 94  58 if (i != 0) {
 95  6 buffer.append("\n");
 96    }
 97  58 buffer.append((i + 1) + ":\t");
 98  58 buffer.append(get(i) != null ? get(i).toString() : null);
 99    }
 100  61 return buffer.toString();
 101    }
 102   
 103    }