Clover Coverage Report
Coverage timestamp: Sa Aug 2 2008 13:56:27 CEST
../../../../img/srcFileCovDistChart9.png 30% of files have more coverage
23   146   16   2,09
10   57   0,7   11
11     1,45  
1    
 
  DefaultSourceFileExceptionList       Line # 31 23 16 90,9% 0.90909094
 
  (138)
 
1    /* $Id: DefaultSourceFileExceptionList.java,v 1.2 2008/05/15 21:27:48 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.common;
19   
20    import java.io.IOException;
21    import java.util.ArrayList;
22    import java.util.List;
23   
24    /**
25    * Type save {@link org.qedeq.kernel.common.SourceFileException} list.
26    * TODO mime 20080109: shouldn't this list have some informations about the source being parsed?
27    *
28    * @version $Revision: 1.2 $
29    * @author Michael Meyling
30    */
 
31    public class DefaultSourceFileExceptionList extends SourceFileExceptionList {
32   
33    /** List with parse exceptions. */
34    private final List exceptions = new ArrayList();
35   
36    /**
37    * Constructor.
38    */
 
39  595 toggle public DefaultSourceFileExceptionList() {
40    }
41   
42    /**
43    * Constructor.
44    *
45    * @param e Wrap me.
46    */
 
47  1 toggle public DefaultSourceFileExceptionList(final IOException e) {
48  1 add(e);
49    }
50   
51    /**
52    * Constructor.
53    *
54    * @param e Wrap me.
55    */
 
56  4 toggle public DefaultSourceFileExceptionList(final RuntimeException e) {
57  4 add(e);
58    }
59   
60    /**
61    * Constructor.
62    *
63    * @param e Wrap me.
64    */
 
65  88 toggle public DefaultSourceFileExceptionList(final SourceFileException e) {
66  88 add(e);
67    }
68   
69    /**
70    * Add exception.
71    *
72    * @param e Exception to add.
73    */
 
74  149 toggle public void add(final SourceFileException e) {
75  149 if (size() == 0) {
76  94 initCause(e);
77    }
78  149 exceptions.add(e);
79    }
80   
81    /**
82    * Add exception.
83    *
84    * @param e Exception to add.
85    */
 
86  1 toggle public final void add(final IOException e) {
87  1 if (size() == 0) {
88  1 initCause(e);
89    }
90  1 exceptions.add(new SourceFileException(e));
91    }
92   
93    /**
94    * Add exception.
95    *
96    * @param e Exception to add.
97    */
 
98  4 toggle public void add(final RuntimeException e) {
99  4 if (size() == 0) {
100  4 initCause(e);
101    }
102  4 exceptions.add(new SourceFileException(e));
103    }
104   
105    /**
106    * Get number of collected exceptions.
107    *
108    * @return Number of collected exceptions.
109    */
 
110  916 toggle public final int size() {
111  916 return exceptions.size();
112    }
113   
114    /**
115    * Get <code>i</code>-th exception.
116    *
117    * @param i Starts with 0 and must be smaller than {@link #size()}.
118    * @return Wanted exception.
119    */
 
120  298 toggle public final SourceFileException get(final int i) {
121  298 return (SourceFileException) exceptions.get(i);
122    }
123   
124    /**
125    * Get all exceptions.
126    *
127    * @return All exceptions.
128    */
 
129  0 toggle public final SourceFileException[] toArray() {
130  0 return (SourceFileException[]) exceptions.toArray(new SourceFileException[0]);
131    }
132   
 
133  104 toggle public String getMessage() {
134  104 final StringBuffer buffer = new StringBuffer();
135  277 for (int i = 0; i < size(); i++) {
136  173 if (i != 0) {
137  69 buffer.append("\n");
138    }
139  173 final SourceFileException e = get(i);
140  173 buffer.append(i).append(": ");
141  173 buffer.append(e.toString());
142    }
143  104 return buffer.toString();
144    }
145   
146    }