Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Do Jan 11 2007 09:03:50 CET
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.4 2006/10/20 20:23:03 m31 Exp $
 2    *
 3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
 4    *
 5    * Copyright 2000-2006, 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.dto.module.RuleVo;
 22    import org.qedeq.kernel.xml.parser.AbstractSimpleHandler;
 23    import org.qedeq.kernel.xml.parser.SimpleAttributes;
 24    import org.qedeq.kernel.xml.parser.SyntaxException;
 25   
 26   
 27    /**
 28    * Parse a rule.
 29    *
 30    * @version $Revision: 1.4 $
 31    * @author Michael Meyling
 32    */
 33    public final 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  27 public RuleHandler(final AbstractSimpleHandler handler) {
 50  27 super(handler, "RULE");
 51  27 descriptionHandler = new LatexListHandler(this, "DESCRIPTION");
 52  27 proofHandler = new ProofHandler(this);
 53    }
 54   
 55  6 public final void init() {
 56  6 rule = null;
 57    }
 58   
 59    /**
 60    * Get Rule.
 61    *
 62    * @return Rule.
 63    */
 64  6 public final Rule getRule() {
 65  6 return rule;
 66    }
 67   
 68  15 public final void startElement(final String name, final SimpleAttributes attributes)
 69    throws SyntaxException {
 70  15 if (getStartTag().equals(name)) {
 71  6 rule = new RuleVo();
 72  6 if (null != attributes.getString("name")) {
 73  6 rule.setName(attributes.getString("name"));
 74    } else {
 75  0 throw SyntaxException.createMissingAttributeException(name, "name");
 76    }
 77  9 } else if ("LINK".equals(name)) {
 78  3 if (null != attributes.getString("id")) {
 79  3 rule.addLink(attributes.getString("id"));
 80    } else {
 81  0 throw SyntaxException.createMissingAttributeException(name, "id");
 82    }
 83  6 } else if (descriptionHandler.getStartTag().equals(name)) {
 84  6 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  15 public final void endElement(final String name) throws SyntaxException {
 93  15 if (getStartTag().equals(name)) {
 94    // nothing to do
 95  9 } else if ("LINK".equals(name)) {
 96    // nothing to do
 97  6 } else if (descriptionHandler.getStartTag().equals(name)) {
 98  6 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    }