Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
48   181   31   3.69
36   99   0.65   13
13     2.38  
1    
 
  SourceFileExceptionList       Line # 29 48 31 99% 0.9896907
 
No Tests
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2013, 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.se.common;
17   
18    import java.util.ArrayList;
19    import java.util.List;
20   
21    import org.qedeq.base.utility.EqualsUtility;
22   
23   
24    /**
25    * Type save {@link org.qedeq.kernel.se.common.SourceFileException} list.
26    *
27    * @author Michael Meyling
28    */
 
29    public class SourceFileExceptionList extends Exception {
30   
31    /** List with parse exceptions. */
32    private final List exceptions = new ArrayList();
33   
34    /**
35    * Constructor.
36    */
 
37  8637 toggle public SourceFileExceptionList() {
38    }
39   
40    /**
41    * Constructor.
42    *
43    * @param e Wrap me.
44    */
 
45  46 toggle public SourceFileExceptionList(final SourceFileException e) {
46  46 if (e != null) {
47  45 add(e);
48    }
49    }
50   
51    /**
52    * Constructor.
53    *
54    * @param e Wrap me.
55    */
 
56  1216 toggle public SourceFileExceptionList(final SourceFileExceptionList e) {
57  1216 if (e != null) {
58  8523 for (int i = 0; i < e.size(); i++) {
59  8148 add(e.get(i));
60    }
61    }
62    }
63   
64    /**
65    * Clear list.
66    */
 
67  4 toggle public void clear() {
68  4 exceptions.clear();
69    }
70   
71    /**
72    * Add exception. If we get <code>null</code> we do nothing.
73    *
74    * @param e Exception to add.
75    */
 
76  8714 toggle public void add(final SourceFileException e) {
77  8714 if (e == null) {
78  1 return;
79    }
80  8713 if (size() == 0) {
81  557 initCause(e);
82    }
83  8713 if (!exceptions.contains(e)) {
84  8651 exceptions.add(e);
85    }
86    }
87   
88    /**
89    * Add exceptions of given list if they are not already included. If we get <code>null</code> we do nothing.
90    *
91    * @param e Add exceptions of this list.
92    */
 
93  1914 toggle public void add(final SourceFileExceptionList e) {
94  1914 if (e == null) {
95  1 return;
96    }
97  2585 for (int i = 0; i < e.size(); i++) {
98  672 if (size() == 0) {
99  99 initCause(e.get(i));
100    }
101  672 if (!exceptions.contains(e.get(i))) {
102  633 exceptions.add(e.get(i));
103    }
104    }
105    }
106   
107    /**
108    * Get number of collected exceptions.
109    *
110    * @return Number of collected exceptions.
111    */
 
112  25470 toggle public final int size() {
113  25470 return exceptions.size();
114    }
115   
116    /**
117    * Get <code>i</code>-th exception.
118    *
119    * @param i Starts with 0 and must be smaller than {@link #size()}.
120    * @return Wanted exception.
121    */
 
122  10228 toggle public final SourceFileException get(final int i) {
123  10228 return (SourceFileException) exceptions.get(i);
124    }
125   
126    /**
127    * Get all exceptions.
128    *
129    * @return All exceptions.
130    */
 
131  1 toggle public final SourceFileException[] toArray() {
132  1 return (SourceFileException[]) exceptions.toArray(
133    new SourceFileException[exceptions.size()]);
134    }
135   
 
136  6 toggle public int hashCode() {
137  6 int result = 71;
138  15 for (int i = 0; i < size(); i++) {
139  9 result = result ^ (get(i) != null ? get(i).hashCode() : 0);
140    }
141  6 return result;
142    }
143   
 
144  28 toggle public boolean equals(final Object object) {
145  28 if (!(object instanceof SourceFileExceptionList)) {
146  8 return false;
147    }
148  20 SourceFileExceptionList sfl = (SourceFileExceptionList) object;
149  20 if (size() != sfl.size()) {
150  12 return false;
151    }
152  20 for (int i = 0; i < size(); i++) {
153  14 if (!EqualsUtility.equals(get(i), sfl.get(i))) {
154  2 return false;
155    }
156    }
157  6 return true;
158    }
159   
 
160  128 toggle public String getMessage() {
161  128 final StringBuffer buffer = new StringBuffer();
162  407 for (int i = 0; i < size(); i++) {
163  279 if (i != 0) {
164  190 buffer.append("\n");
165    }
166  279 final SourceFileException e = get(i);
167  279 buffer.append(i).append(": ");
168  279 buffer.append(e.toString());
169    }
170  128 return buffer.toString();
171    }
172   
 
173  22 toggle public String toString() {
174  22 final StringBuffer buffer = new StringBuffer();
175  22 buffer.append(getClass().getName());
176  22 buffer.append("\n");
177  22 buffer.append(getMessage());
178  22 return buffer.toString();
179    }
180   
181    }