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