Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Do Mai 10 2007 03:16:40 CEST
file stats: LOC: 102   Methods: 7
NCLOC: 56   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
LinkListVo.java 100% 100% 100% 100%
coverage
 1    /* $Id: LinkListVo.java,v 1.4 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.LinkList;
 24    import org.qedeq.kernel.utility.EqualsUtility;
 25   
 26   
 27    /**
 28    * List of links. A link is just a string that identifies something.
 29    *
 30    * @version $Revision: 1.4 $
 31    * @author Michael Meyling
 32    */
 33    public class LinkListVo implements LinkList {
 34   
 35    /** Contains all list elements. */
 36    private final List list;
 37   
 38    /**
 39    * Constructs an empty list of links.
 40    */
 41  55 public LinkListVo() {
 42  55 this.list = new ArrayList();
 43   
 44    }
 45   
 46    /**
 47    * Add link to list.
 48    *
 49    * @param id Identifier to add.
 50    */
 51  47 public final void add(final String id) {
 52  47 list.add(id);
 53    }
 54   
 55  336 public final int size() {
 56  336 return list.size();
 57    }
 58   
 59  236 public final String get(final int index) {
 60  236 return (String) list.get(index);
 61    }
 62   
 63  50 public boolean equals(final Object obj) {
 64  50 if (!(obj instanceof LinkListVo)) {
 65  7 return false;
 66    }
 67  43 final LinkListVo otherList = (LinkListVo) obj;
 68  43 if (size() != otherList.size()) {
 69  11 return false;
 70    }
 71  32 for (int i = 0; i < size(); i++) {
 72  38 if (!EqualsUtility.equals(get(i), otherList.get(i))) {
 73  4 return false;
 74    }
 75    }
 76  28 return true;
 77    }
 78   
 79  32 public int hashCode() {
 80  32 int hash = 0;
 81  32 for (int i = 0; i < size(); i++) {
 82  34 hash = hash ^ (i + 1);
 83  34 if (get(i) != null) {
 84  32 hash = hash ^ get(i).hashCode();
 85    }
 86    }
 87  32 return hash;
 88    }
 89   
 90  30 public String toString() {
 91  30 final StringBuffer buffer = new StringBuffer("List of links:\n");
 92  30 for (int i = 0; i < size(); i++) {
 93  31 if (i != 0) {
 94  10 buffer.append("\n");
 95    }
 96  31 buffer.append((i + 1) + ":\n");
 97  31 buffer.append(get(i) != null ? get(i) : null);
 98    }
 99  30 return buffer.toString();
 100    }
 101   
 102    }