Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Mo Jun 11 2007 14:25:28 CEST
file stats: LOC: 98   Methods: 2
NCLOC: 57   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
SaxEntityResolver.java 70% 88% 100% 83,8%
coverage coverage
 1    /* $Id: SaxEntityResolver.java,v 1.20 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.FileNotFoundException;
 21    import java.io.InputStream;
 22   
 23    import org.qedeq.kernel.context.KernelContext;
 24    import org.qedeq.kernel.trace.Trace;
 25    import org.xml.sax.EntityResolver;
 26    import org.xml.sax.InputSource;
 27    import org.xml.sax.SAXException;
 28    import org.xml.sax.SAXParseException;
 29   
 30   
 31    /**
 32    * Resolve QEDEQ module XML schema.
 33    *
 34    * @version $Revision: 1.20 $
 35    * @author Michael Meyling
 36    */
 37    public class SaxEntityResolver implements EntityResolver {
 38   
 39    /** Handler that parses the document. */
 40    private final SaxDefaultHandler handler;
 41   
 42    /**
 43    * Constructor.
 44    *
 45    * @param handler This one does the parsing.
 46    */
 47  132 public SaxEntityResolver(final SaxDefaultHandler handler) {
 48  132 this.handler = handler;
 49    }
 50   
 51    /* (non-Javadoc)
 52    * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String)
 53    */
 54  254 public InputSource resolveEntity(final String publicId, final String systemId)
 55    throws FileNotFoundException, SAXException {
 56  254 final String method = "resolveEntity";
 57  254 Trace.param(this, method, "systemId", systemId);
 58  254 Trace.param(this, method, "publicId", publicId);
 59  254 if ((systemId == null)) {
 60  0 return null;
 61    }
 62  254 if (systemId.equals("http://www.qedeq.org/" + KernelContext.getInstance()
 63    .getKernelVersionDirectory() + "/xml/qedeq.xsd")) {
 64  91 InputStream in = SaxEntityResolver.class.getResourceAsStream(
 65    "/org/qedeq/kernel/xml/schema/qedeq.xsd");
 66  91 if (in == null) {
 67  0 throw new FileNotFoundException("/org/qedeq/kernel/xml/schema/qedeq.xsd");
 68    }
 69  91 InputSource inputSource = new InputSource(in);
 70  91 inputSource.setPublicId(publicId);
 71  91 inputSource.setSystemId(systemId);
 72  91 return inputSource;
 73  163 } else if (systemId.equals("http://www.qedeq.org/"
 74    + KernelContext.getInstance().getKernelVersionDirectory()
 75    + "/xml/parser.xsd")) {
 76  162 InputStream in = SaxEntityResolver.class.getResourceAsStream(
 77    "/org/qedeq/kernel/xml/schema/parser.xsd");
 78  162 if (in == null) {
 79  0 throw new FileNotFoundException("/org/qedeq/kernel/xml/schema/parser.xsd");
 80    }
 81  162 InputSource inputSource = new InputSource(in);
 82  162 inputSource.setPublicId(publicId);
 83  162 inputSource.setSystemId(systemId);
 84  162 return inputSource;
 85    }
 86  1 Trace.trace(this, method, "unknown entity");
 87  1 SAXParseException sax = handler.createSAXParseException(
 88    "this kernel supports only the following XSDs:\n"
 89    + "http://www.qedeq.org/" + KernelContext.getInstance()
 90    .getKernelVersionDirectory() + "/xml/qedeq.xsd" + "\n"
 91    + "http://www.qedeq.org/"
 92    + KernelContext.getInstance().getKernelVersionDirectory()
 93    + "/xml/parser.xsd");
 94  1 throw sax;
 95    // TODO mime 20070604: this error should have correct location information,
 96    // but is hasn't! this problem should be solved later...
 97    }
 98    }