Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Do Mai 10 2007 03:16:40 CEST
file stats: LOC: 174   Methods: 14
NCLOC: 65   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
DefaultXmlFileExceptionList.java 83,3% 61,9% 50% 61%
coverage coverage
 1    /* $Id: DefaultXmlFileExceptionList.java,v 1.1 2007/05/10 00:37:52 m31 Exp $
 2    *
 3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
 4    *
 5    * Copyright 2000-2007, 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.xml.parser;
 19   
 20    import java.io.IOException;
 21    import java.util.ArrayList;
 22    import java.util.List;
 23   
 24    import javax.xml.parsers.ParserConfigurationException;
 25   
 26    import org.qedeq.kernel.common.SyntaxException;
 27    import org.qedeq.kernel.common.SyntaxExceptionList;
 28    import org.qedeq.kernel.common.XmlFileException;
 29    import org.qedeq.kernel.common.XmlFileExceptionList;
 30    import org.xml.sax.SAXException;
 31   
 32   
 33    /**
 34    * Type save {@link org.qedeq.kernel.common.XmlFileException} list.
 35    *
 36    * @version $Revision: 1.1 $
 37    * @author Michael Meyling
 38    */
 39    public class DefaultXmlFileExceptionList extends XmlFileExceptionList {
 40   
 41    /** List with parse exceptions. */
 42    private final List exceptions = new ArrayList();
 43   
 44    /**
 45    * Constructor.
 46    */
 47  6 public DefaultXmlFileExceptionList() {
 48    }
 49   
 50    /**
 51    * Constructor.
 52    *
 53    * @param e Wrap me.
 54    */
 55  0 public DefaultXmlFileExceptionList(final IOException e) {
 56  0 add(new XmlFileException(e));
 57    }
 58   
 59    /**
 60    * Constructor.
 61    *
 62    * @param e Wrap me.
 63    */
 64  0 public DefaultXmlFileExceptionList(final RuntimeException e) {
 65  0 add(new XmlFileException(e));
 66    }
 67   
 68    /**
 69    * Constructor.
 70    *
 71    * @param exceptionList Syntax exceptions that are wrapped into {@link XmlFileException}.
 72    */
 73  4 public DefaultXmlFileExceptionList(final SyntaxExceptionList exceptionList) {
 74  4 for (int i = 0; i < exceptionList.size(); i++) {
 75  10 add(exceptionList.get(i));
 76    }
 77    }
 78   
 79    /**
 80    * Add exception.
 81    *
 82    * @param e Exception to add.
 83    */
 84  6 public void add(final XmlFileException e) {
 85  6 exceptions.add(e);
 86    }
 87   
 88    /**
 89    * Add exception.
 90    *
 91    * @param e Exception to add.
 92    */
 93  10 public final void add(final SyntaxException e) {
 94  10 exceptions.add(new XmlFileException(e));
 95    }
 96   
 97    /**
 98    * Add exception.
 99    *
 100    * @param e Exception to add.
 101    */
 102  0 public final void add(final SAXException e) {
 103  0 exceptions.add(new XmlFileException(e));
 104    }
 105   
 106    /**
 107    * Add exception.
 108    *
 109    * @param e Exception to add.
 110    */
 111  0 public final void add(final IOException e) {
 112  0 exceptions.add(new XmlFileException(e));
 113    }
 114   
 115    /**
 116    * Add exception.
 117    *
 118    * @param e Exception to add.
 119    */
 120  0 public void add(final ParserConfigurationException e) {
 121  0 exceptions.add(new XmlFileException(e));
 122    }
 123   
 124    /**
 125    * Add exception.
 126    *
 127    * @param e Exception to add.
 128    */
 129  0 public void add(final RuntimeException e) {
 130  0 exceptions.add(new XmlFileException(e));
 131    }
 132   
 133    /**
 134    * Get number of collected exceptions.
 135    *
 136    * @return Number of collected exceptions.
 137    */
 138  18 public final int size() {
 139  18 return exceptions.size();
 140    }
 141   
 142    /**
 143    * Get <code>i</code>-th exception.
 144    *
 145    * @param i Starts with 0 and must be smaller than {@link #size()}.
 146    * @return Wanted exception.
 147    */
 148  20 public final XmlFileException get(final int i) {
 149  20 return (XmlFileException) exceptions.get(i);
 150    }
 151   
 152    /**
 153    * Get all exceptions.
 154    *
 155    * @return All exceptions.
 156    */
 157  0 public final XmlFileException[] toArray() {
 158  0 return (XmlFileException[]) exceptions.toArray(new XmlFileException[0]);
 159    }
 160   
 161  4 public String toString() {
 162  4 final StringBuffer buffer = new StringBuffer();
 163  4 for (int i = 0; i < size(); i++) {
 164  4 if (i != 0) {
 165  0 buffer.append("\n");
 166    }
 167  4 final XmlFileException e = get(i);
 168  4 buffer.append(i).append(": ");
 169  4 buffer.append(e.toString());
 170    }
 171  4 return buffer.toString();
 172    }
 173   
 174    }