Clover Coverage Report
Coverage timestamp: Sat Sep 18 2010 04:09:52 UTC
../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
26   101   15   3.71
18   57   0.58   7
7     2.14  
1    
 
  LiteratureItemListVo       Line # 32 26 15 100% 1.0
 
  (10)
 
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.module.LiteratureItem;
23    import org.qedeq.kernel.base.module.LiteratureItemList;
24   
25   
26    /**
27    * List of literature references.
28    *
29    * @version $Revision: 1.6 $
30    * @author Michael Meyling
31    */
 
32    public class LiteratureItemListVo implements LiteratureItemList {
33   
34    /** Contains all list elements. */
35    private final List list;
36   
37    /**
38    * Constructs an empty list of authors.
39    */
 
40  73 toggle public LiteratureItemListVo() {
41  73 this.list = new ArrayList();
42   
43    }
44   
45    /**
46    * Add literature reference to list.
47    *
48    * @param item Add this reference.
49    */
 
50  198 toggle public final void add(final LiteratureItemVo item) {
51  198 list.add(item);
52    }
53   
 
54  1332 toggle public final int size() {
55  1332 return list.size();
56    }
57   
 
58  1364 toggle public final LiteratureItem get(final int index) {
59  1364 return (LiteratureItem) list.get(index);
60    }
61   
 
62  38 toggle public boolean equals(final Object obj) {
63  38 if (!(obj instanceof LiteratureItemListVo)) {
64  6 return false;
65    }
66  32 final LiteratureItemListVo otherList = (LiteratureItemListVo) obj;
67  32 if (size() != otherList.size()) {
68  7 return false;
69    }
70  47 for (int i = 0; i < size(); i++) {
71  24 if (!EqualsUtility.equals(get(i), otherList.get(i))) {
72  2 return false;
73    }
74    }
75  23 return true;
76    }
77   
 
78  34 toggle public int hashCode() {
79  34 int hash = 0;
80  78 for (int i = 0; i < size(); i++) {
81  44 hash = hash ^ (i + 1);
82  44 if (get(i) != null) {
83  43 hash = hash ^ get(i).hashCode();
84    }
85    }
86  34 return hash;
87    }
88   
 
89  32 toggle public String toString() {
90  32 final StringBuffer buffer = new StringBuffer("Bibliography:\n");
91  73 for (int i = 0; i < size(); i++) {
92  41 if (i != 0) {
93  12 buffer.append("\n");
94    }
95  41 buffer.append((i + 1) + ":\t");
96  41 buffer.append(get(i) != null ? get(i).toString() : null);
97    }
98  32 return buffer.toString();
99    }
100   
101    }