Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Do Jan 11 2007 09:03:50 CET
file stats: LOC: 103   Methods: 7
NCLOC: 57   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
SectionListVo.java 100% 100% 100% 100%
coverage
 1    /* $Id: SectionListVo.java,v 1.4 2006/10/20 20:23:01 m31 Exp $
 2    *
 3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
 4    *
 5    * Copyright 2000-2006, 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.Section;
 24    import org.qedeq.kernel.base.module.SectionList;
 25    import org.qedeq.kernel.utility.EqualsUtility;
 26   
 27   
 28    /**
 29    * List of sections.
 30    *
 31    * @version $Revision: 1.4 $
 32    * @author Michael Meyling
 33    */
 34    public final class SectionListVo implements SectionList {
 35   
 36    /** Contains all sections. */
 37    private final List list;
 38   
 39    /**
 40    * Constructs an empty section list.
 41    */
 42  179 public SectionListVo() {
 43  179 this.list = new ArrayList();
 44   
 45    }
 46   
 47    /**
 48    * Add section to this list.
 49    *
 50    * @param section Section to add.
 51    */
 52  333 public final void add(final SectionVo section) {
 53  333 list.add(section);
 54    }
 55   
 56  1239 public final int size() {
 57  1239 return list.size();
 58    }
 59   
 60  3526 public final Section get(final int index) {
 61  3526 return (Section) list.get(index);
 62    }
 63   
 64  127 public boolean equals(final Object obj) {
 65  127 if (!(obj instanceof SectionListVo)) {
 66  7 return false;
 67    }
 68  120 final SectionListVo otherList = (SectionListVo) obj;
 69  120 if (size() != otherList.size()) {
 70  11 return false;
 71    }
 72  109 for (int i = 0; i < size(); i++) {
 73  115 if (!EqualsUtility.equals(get(i), otherList.get(i))) {
 74  4 return false;
 75    }
 76    }
 77  105 return true;
 78    }
 79   
 80  98 public int hashCode() {
 81  98 int hash = 0;
 82  98 for (int i = 0; i < size(); i++) {
 83  100 hash = hash ^ (i + 1);
 84  100 if (get(i) != null) {
 85  98 hash = hash ^ get(i).hashCode();
 86    }
 87    }
 88  98 return hash;
 89    }
 90   
 91  93 public String toString() {
 92  93 final StringBuffer buffer = new StringBuffer("List of sections:\n");
 93  93 for (int i = 0; i < size(); i++) {
 94  94 if (i != 0) {
 95  10 buffer.append("\n");
 96    }
 97  94 buffer.append((i + 1) + ":\t");
 98  94 buffer.append(get(i) != null ? get(i).toString() : null);
 99    }
 100  93 return buffer.toString();
 101    }
 102   
 103    }