Clover Coverage Report
Coverage timestamp: Sat Sep 18 2010 04:09:52 UTC
../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
26   100   15   3.71
18   57   0.58   7
7     2.14  
1    
 
  VariableListVo       Line # 32 26 15 100% 1.0
 
  (43)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2010, Michael Meyling <mime@qedeq.org>.
4    *
5    * "Hilbert II" is free software; you can redistribute
6    * it and/or modify it under the terms of the GNU General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10    * This program is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13    * GNU General Public License for more details.
14    */
15   
16    package org.qedeq.kernel.dto.module;
17   
18    import java.util.ArrayList;
19    import java.util.List;
20   
21    import org.qedeq.base.utility.EqualsUtility;
22    import org.qedeq.kernel.base.list.Element;
23    import org.qedeq.kernel.base.module.VariableList;
24   
25   
26    /**
27    * List of variables.
28    *
29    * @version $Revision: 1.10 $
30    * @author Michael Meyling
31    */
 
32    public class VariableListVo implements VariableList {
33   
34    /** Contains all list elements. */
35    private final List list;
36   
37    /**
38    * Constructs an empty list of variables.
39    */
 
40  815 toggle public VariableListVo() {
41  815 this.list = new ArrayList();
42    }
43   
44    /**
45    * Add variable to list.
46    *
47    * @param element Variable.
48    */
 
49  1282 toggle public final void add(final Element element) {
50  1282 list.add(element);
51    }
52   
 
53  12227 toggle public final int size() {
54  12227 return list.size();
55    }
56   
 
57  20486 toggle public final Element get(final int index) {
58  20486 return (Element) list.get(index);
59    }
60   
 
61  251 toggle public boolean equals(final Object obj) {
62  251 if (!(obj instanceof VariableListVo)) {
63  8 return false;
64    }
65  243 final VariableListVo otherList = (VariableListVo) obj;
66  243 if (size() != otherList.size()) {
67  7 return false;
68    }
69  469 for (int i = 0; i < size(); i++) {
70  235 if (!EqualsUtility.equals(get(i), otherList.get(i))) {
71  2 return false;
72    }
73    }
74  234 return true;
75    }
76   
 
77  371 toggle public int hashCode() {
78  371 int hash = 0;
79  752 for (int i = 0; i < size(); i++) {
80  381 hash = hash ^ (i + 1);
81  381 if (get(i) != null) {
82  380 hash = hash ^ get(i).hashCode();
83    }
84    }
85  371 return hash;
86    }
87   
 
88  280 toggle public String toString() {
89  280 final StringBuffer buffer = new StringBuffer("List of elements:\n");
90  569 for (int i = 0; i < size(); i++) {
91  289 if (i != 0) {
92  12 buffer.append("\n");
93    }
94  289 buffer.append((i + 1) + ":\t");
95  289 buffer.append(get(i) != null ? get(i).toString() : null);
96    }
97  280 return buffer.toString();
98    }
99   
100    }