Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Do Mai 10 2007 03:16:40 CEST
file stats: LOC: 107   Methods: 5
NCLOC: 56   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
RuleHandler.java 60% 69,2% 100% 68,6%
coverage coverage
 1    /* $Id: RuleHandler.java,v 1.7 2007/05/10 00:37:50 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.handler.module;
 19   
 20    import org.qedeq.kernel.base.module.Rule;
 21    import org.qedeq.kernel.common.SyntaxException;
 22    import org.qedeq.kernel.dto.module.RuleVo;
 23    import org.qedeq.kernel.xml.parser.AbstractSimpleHandler;
 24    import org.qedeq.kernel.xml.parser.SimpleAttributes;
 25   
 26   
 27    /**
 28    * Parse a rule.
 29    *
 30    * @version $Revision: 1.7 $
 31    * @author Michael Meyling
 32    */
 33    public class RuleHandler extends AbstractSimpleHandler {
 34   
 35    /** Handler for rule description. */
 36    private final LatexListHandler descriptionHandler;
 37   
 38    /** Handle proofs. */
 39    private final ProofHandler proofHandler;
 40   
 41    /** Rule value object. */
 42    private RuleVo rule;
 43   
 44    /**
 45    * Deals with definitions.
 46    *
 47    * @param handler Parent handler.
 48    */
 49  46 public RuleHandler(final AbstractSimpleHandler handler) {
 50  46 super(handler, "RULE");
 51  46 descriptionHandler = new LatexListHandler(this, "DESCRIPTION");
 52  46 proofHandler = new ProofHandler(this);
 53    }
 54   
 55  28 public final void init() {
 56  28 rule = null;
 57    }
 58   
 59    /**
 60    * Get Rule.
 61    *
 62    * @return Rule.
 63    */
 64  28 public final Rule getRule() {
 65  28 return rule;
 66    }
 67   
 68  63 public final void startElement(final String name, final SimpleAttributes attributes)
 69    throws SyntaxException {
 70  63 if (getStartTag().equals(name)) {
 71  28 rule = new RuleVo();
 72  28 if (null != attributes.getString("name")) {
 73  28 rule.setName(attributes.getString("name"));
 74    } else {
 75  0 throw SyntaxException.createMissingAttributeException(name, "name");
 76    }
 77  35 } else if ("LINK".equals(name)) {
 78  7 if (null != attributes.getString("id")) {
 79  7 rule.addLink(attributes.getString("id"));
 80    } else {
 81  0 throw SyntaxException.createMissingAttributeException(name, "id");
 82    }
 83  28 } else if (descriptionHandler.getStartTag().equals(name)) {
 84  28 changeHandler(descriptionHandler, name, attributes);
 85  0 } else if (proofHandler.getStartTag().equals(name)) {
 86  0 changeHandler(proofHandler, name, attributes);
 87    } else {
 88  0 throw SyntaxException.createUnexpectedTagException(name);
 89    }
 90    }
 91   
 92  63 public final void endElement(final String name) throws SyntaxException {
 93  63 if (getStartTag().equals(name)) {
 94    // nothing to do
 95  35 } else if ("LINK".equals(name)) {
 96    // nothing to do
 97  28 } else if (descriptionHandler.getStartTag().equals(name)) {
 98  28 rule.setDescription(descriptionHandler.getLatexList());
 99  0 } else if (proofHandler.getStartTag().equals(name)) {
 100  0 rule.addProof(proofHandler.getProof());
 101    } else {
 102  0 throw SyntaxException.createUnexpectedTagException(name);
 103    }
 104    }
 105   
 106   
 107    }