Clover Coverage Report
Coverage timestamp: Sa Aug 2 2008 13:56:27 CEST
../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
26   104   15   3,71
18   57   0,58   7
7     2,14  
1    
 
  SubsectionListVo       Line # 34 26 15 100% 1.0
 
  (33)
 
1    /* $Id: SubsectionListVo.java,v 1.8 2008/07/26 07:59:35 m31 Exp $
2    *
3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
4    *
5    * Copyright 2000-2008, 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.base.utility.EqualsUtility;
24    import org.qedeq.kernel.base.module.SubsectionList;
25    import org.qedeq.kernel.base.module.SubsectionType;
26   
27   
28    /**
29    * List of nodes. In LaTeX terms a node is something like an "subsection".
30    *
31    * @version $Revision: 1.8 $
32    * @author Michael Meyling
33    */
 
34    public class SubsectionListVo implements SubsectionList {
35   
36    /** Contains all nodes. */
37    private final List list;
38   
39    /**
40    * Constructs an empty node list.
41    */
 
42  564 toggle public SubsectionListVo() {
43  564 this.list = new ArrayList();
44   
45    }
46   
47    /**
48    * Add subsection to this list.
49    *
50    * @param subsection Subsection to add.
51    */
 
52  2676 toggle public final void add(final SubsectionType subsection) {
53  2676 list.add(subsection);
54    }
55   
 
56  160328 toggle public final int size() {
57  160328 return list.size();
58    }
59   
 
60  499011 toggle public final SubsectionType get(final int index) {
61  499011 return (SubsectionType) list.get(index);
62    }
63   
 
64  129 toggle public boolean equals(final Object obj) {
65  129 if (!(obj instanceof SubsectionListVo)) {
66  6 return false;
67    }
68  123 final SubsectionListVo otherList = (SubsectionListVo) obj;
69  123 if (size() != otherList.size()) {
70  7 return false;
71    }
72  229 for (int i = 0; i < size(); i++) {
73  115 if (!EqualsUtility.equals(get(i), otherList.get(i))) {
74  2 return false;
75    }
76    }
77  114 return true;
78    }
79   
 
80  104 toggle public int hashCode() {
81  104 int hash = 0;
82  206 for (int i = 0; i < size(); i++) {
83  102 hash = hash ^ (i + 1);
84  102 if (get(i) != null) {
85  101 hash = hash ^ get(i).hashCode();
86    }
87    }
88  104 return hash;
89    }
90   
 
91  90 toggle public String toString() {
92  90 final StringBuffer buffer = new StringBuffer("List of nodes:\n");
93  177 for (int i = 0; i < size(); i++) {
94  87 if (i != 0) {
95  6 buffer.append("\n");
96    }
97  87 buffer.append((i + 1) + ":\t");
98  87 buffer.append(get(i) != null ? get(i).toString() : null);
99    }
100  90 return buffer.toString();
101    }
102   
103    }
104