Clover Coverage Report
Coverage timestamp: Sat Sep 18 2010 04:09:52 UTC
../../../../img/srcFileCovDistChart8.png 50% of files have more coverage
43   173   27   3.31
30   91   0.63   13
13     2.08  
1    
 
  DefaultSourceFileExceptionList       Line # 29 43 27 75.6% 0.75581396
 
  (154)
 
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.common;
17   
18    import java.util.ArrayList;
19    import java.util.List;
20   
21    import org.qedeq.base.utility.EqualsUtility;
22   
23    /**
24    * Type save {@link org.qedeq.kernel.common.SourceFileException} list.
25    * TODO m31 20080109: shouldn't this list have some informations about the source being parsed?
26    *
27    * @author Michael Meyling
28    */
 
29    public class DefaultSourceFileExceptionList extends SourceFileExceptionList {
30   
31    /** List with parse exceptions. */
32    private final List exceptions = new ArrayList();
33   
34    /**
35    * Constructor.
36    */
 
37  1997 toggle public DefaultSourceFileExceptionList() {
38    }
39   
40    /**
41    * Constructor.
42    *
43    * @param e Wrap me.
44    */
 
45  75 toggle public DefaultSourceFileExceptionList(final SourceFileException e) {
46  75 add(e);
47    }
48   
49    /**
50    * Constructor.
51    *
52    * @param e Wrap me.
53    */
 
54  1240 toggle public DefaultSourceFileExceptionList(final SourceFileExceptionList e) {
55  1240 if (e != null) {
56  218 for (int i = 0; i < e.size(); i++) {
57  123 add(e.get(i));
58    }
59    }
60    }
61   
62    /**
63    * Clear list.
64    */
 
65  0 toggle public void clear() {
66  0 exceptions.clear();
67    }
68   
69    /**
70    * Add exception.
71    *
72    * @param e Exception to add.
73    */
 
74  232 toggle public void add(final SourceFileException e) {
75  232 if (size() == 0) {
76  176 initCause(e);
77    }
78  232 if (!exceptions.contains(e)) {
79  232 exceptions.add(e);
80    }
81    }
82   
83    /**
84    * Add exceptions of given list if they are not already included.
85    *
86    * @param e Add exceptions of this list.
87    */
 
88  1357 toggle public void add(final SourceFileExceptionList e) {
89  1357 if (e == null) {
90  46 return;
91    }
92  1351 for (int i = 0; i < e.size(); i++) {
93  40 if (!exceptions.contains(e.get(i))) {
94  40 exceptions.add(e.get(i));
95    }
96    }
97    }
98   
99    /**
100    * Get number of collected exceptions.
101    *
102    * @return Number of collected exceptions.
103    */
 
104  3970 toggle public final int size() {
105  3970 return exceptions.size();
106    }
107   
108    /**
109    * Get <code>i</code>-th exception.
110    *
111    * @param i Starts with 0 and must be smaller than {@link #size()}.
112    * @return Wanted exception.
113    */
 
114  465 toggle public final SourceFileException get(final int i) {
115  465 return (SourceFileException) exceptions.get(i);
116    }
117   
118    /**
119    * Get all exceptions.
120    *
121    * @return All exceptions.
122    */
 
123  0 toggle public final SourceFileException[] toArray() {
124  0 return (SourceFileException[]) exceptions.toArray(
125    new SourceFileException[exceptions.size()]);
126    }
127   
 
128  0 toggle public int hashCode() {
129  0 int result = 71;
130  0 for (int i = 0; i < size(); i++) {
131  0 result = result ^ (get(i) != null ? get(i).hashCode() : 0);
132    }
133  0 return result;
134    }
135   
 
136  2 toggle public boolean equals(final Object object) {
137  2 if (!(object instanceof SourceFileExceptionList)) {
138  0 return false;
139    }
140  2 SourceFileExceptionList sfl = (SourceFileExceptionList) object;
141  2 if (size() != sfl.size()) {
142  0 return false;
143    }
144  4 for (int i = 0; i < size(); i++) {
145  2 if (!EqualsUtility.equals(get(i), sfl.get(i))) {
146  0 return false;
147    }
148    }
149  2 return true;
150    }
151   
 
152  95 toggle public String getMessage() {
153  95 final StringBuffer buffer = new StringBuffer();
154  232 for (int i = 0; i < size(); i++) {
155  137 if (i != 0) {
156  42 buffer.append("\n");
157    }
158  137 final SourceFileException e = get(i);
159  137 buffer.append(i).append(": ");
160  137 buffer.append(e.toString());
161    }
162  95 return buffer.toString();
163    }
164   
 
165  8 toggle public String toString() {
166  8 final StringBuffer buffer = new StringBuffer();
167  8 buffer.append(getClass().getName());
168  8 buffer.append("\n");
169  8 buffer.append(getMessage());
170  8 return buffer.toString();
171    }
172   
173    }