Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: So Sep 2 2007 02:40:58 CEST
file stats: LOC: 179   Methods: 14
NCLOC: 70   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
DefaultXmlFileExceptionList.java 100% 64% 50% 66%
coverage coverage
 1    /* $Id: DefaultXmlFileExceptionList.java,v 1.3 2007/08/21 21:03:30 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.3 $
 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  16 public DefaultXmlFileExceptionList() {
 48    }
 49   
 50    /**
 51    * Constructor.
 52    *
 53    * @param e Wrap me.
 54    */
 55  0 public DefaultXmlFileExceptionList(final IOException e) {
 56  0 initCause(e);
 57  0 add(new XmlFileException(e));
 58    }
 59   
 60    /**
 61    * Constructor.
 62    *
 63    * @param e Wrap me.
 64    */
 65  0 public DefaultXmlFileExceptionList(final RuntimeException e) {
 66  0 initCause(e);
 67  0 add(new XmlFileException(e));
 68    }
 69   
 70    /**
 71    * Constructor.
 72    *
 73    * @param exceptionList Syntax exceptions that are wrapped into {@link XmlFileException}.
 74    */
 75  8 public DefaultXmlFileExceptionList(final SyntaxExceptionList exceptionList) {
 76  8 for (int i = 0; i < exceptionList.size(); i++) {
 77  20 if (i == 0) {
 78  8 initCause(exceptionList.get(0));
 79    }
 80  20 add(exceptionList.get(i));
 81    }
 82    }
 83   
 84    /**
 85    * Add exception.
 86    *
 87    * @param e Exception to add.
 88    */
 89  16 public void add(final XmlFileException e) {
 90  16 exceptions.add(e);
 91    }
 92   
 93    /**
 94    * Add exception.
 95    *
 96    * @param e Exception to add.
 97    */
 98  20 public final void add(final SyntaxException e) {
 99  20 exceptions.add(new XmlFileException(e));
 100    }
 101   
 102    /**
 103    * Add exception.
 104    *
 105    * @param e Exception to add.
 106    */
 107  0 public final void add(final SAXException e) {
 108  0 exceptions.add(new XmlFileException(e));
 109    }
 110   
 111    /**
 112    * Add exception.
 113    *
 114    * @param e Exception to add.
 115    */
 116  0 public final void add(final IOException e) {
 117  0 exceptions.add(new XmlFileException(e));
 118    }
 119   
 120    /**
 121    * Add exception.
 122    *
 123    * @param e Exception to add.
 124    */
 125  0 public void add(final ParserConfigurationException e) {
 126  0 exceptions.add(new XmlFileException(e));
 127    }
 128   
 129    /**
 130    * Add exception.
 131    *
 132    * @param e Exception to add.
 133    */
 134  0 public void add(final RuntimeException e) {
 135  0 exceptions.add(new XmlFileException(e));
 136    }
 137   
 138    /**
 139    * Get number of collected exceptions.
 140    *
 141    * @return Number of collected exceptions.
 142    */
 143  159 public final int size() {
 144  159 return exceptions.size();
 145    }
 146   
 147    /**
 148    * Get <code>i</code>-th exception.
 149    *
 150    * @param i Starts with 0 and must be smaller than {@link #size()}.
 151    * @return Wanted exception.
 152    */
 153  179 public final XmlFileException get(final int i) {
 154  179 return (XmlFileException) exceptions.get(i);
 155    }
 156   
 157    /**
 158    * Get all exceptions.
 159    *
 160    * @return All exceptions.
 161    */
 162  0 public final XmlFileException[] toArray() {
 163  0 return (XmlFileException[]) exceptions.toArray(new XmlFileException[0]);
 164    }
 165   
 166  66 public String getMessage() {
 167  66 final StringBuffer buffer = new StringBuffer();
 168  66 for (int i = 0; i < size(); i++) {
 169  84 if (i != 0) {
 170  18 buffer.append("\n");
 171    }
 172  84 final XmlFileException e = get(i);
 173  84 buffer.append(i).append(": ");
 174  84 buffer.append(e.toString());
 175    }
 176  66 return buffer.toString();
 177    }
 178   
 179    }