Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Sa Okt 21 2006 08:24:31 CEST
file stats: LOC: 121   Methods: 6
NCLOC: 64   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
FunctionDefinitionHandler.java 68,2% 78,1% 100% 76,7%
coverage coverage
 1    /* $Id: FunctionDefinitionHandler.java,v 1.1 2006/10/20 20:23:02 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.FunctionDefinition;
 21    import org.qedeq.kernel.dto.module.FunctionDefinitionVo;
 22    import org.qedeq.kernel.xml.parser.AbstractSimpleHandler;
 23    import org.qedeq.kernel.xml.parser.SyntaxException;
 24    import org.qedeq.kernel.xml.parser.SimpleAttributes;
 25   
 26   
 27    /**
 28    * Parse a function definition.
 29    *
 30    * @version $Revision: 1.1 $
 31    * @author Michael Meyling
 32    */
 33    public final class FunctionDefinitionHandler extends AbstractSimpleHandler {
 34   
 35    /** Handler for a variable list. */
 36    private final VariableListHandler variableListHandler;
 37   
 38    /** Handler for terms. */
 39    private final FormulaOrTermHandler termHandler;
 40   
 41    /** Handler for rule description. */
 42    private final LatexListHandler descriptionHandler;
 43   
 44    /** Definition value object. */
 45    private FunctionDefinitionVo definition;
 46   
 47    /** LaTeX pattern for the definition. */
 48    private String latexPattern;
 49   
 50   
 51    /**
 52    * Deals with definitions.
 53    *
 54    * @param handler Parent handler.
 55    */
 56  25 public FunctionDefinitionHandler(final AbstractSimpleHandler handler) {
 57  25 super(handler, "DEFINITION_FUNCTION");
 58  25 variableListHandler = new VariableListHandler(this);
 59  25 termHandler = new FormulaOrTermHandler(this, "TERM");
 60  25 descriptionHandler = new LatexListHandler(this, "DESCRIPTION");
 61    }
 62   
 63  48 public final void init() {
 64  48 definition = null;
 65  48 latexPattern = null;
 66    }
 67   
 68    /**
 69    * Get definition.
 70    *
 71    * @return Definition.
 72    */
 73  48 public final FunctionDefinition getDefinition() {
 74  48 return definition;
 75    }
 76   
 77  183 public final void startElement(final String name, final SimpleAttributes attributes)
 78    throws SyntaxException {
 79  183 if (getStartTag().equals(name)) {
 80  48 definition = new FunctionDefinitionVo();
 81  48 definition.setArgumentNumber(attributes.getString("arguments"));
 82  48 definition.setName(attributes.getString("name"));
 83  135 } else if ("LATEXPATTERN".equals(name)) {
 84    // nothing to do yet
 85  87 } else if (variableListHandler.getStartTag().equals(name)) {
 86  39 changeHandler(variableListHandler, name, attributes);
 87  48 } else if (termHandler.getStartTag().equals(name)) {
 88  48 changeHandler(termHandler, name, attributes);
 89  0 } else if (descriptionHandler.getStartTag().equals(name)) {
 90  0 changeHandler(descriptionHandler, name, attributes);
 91    } else {
 92  0 throw SyntaxException.createUnexpectedTagException(name);
 93    }
 94    }
 95   
 96  183 public final void endElement(final String name) throws SyntaxException {
 97  183 if (getStartTag().equals(name)) {
 98    // nothing to do
 99  135 } else if ("LATEXPATTERN".equals(name)) {
 100  48 definition.setLatexPattern(latexPattern);
 101  87 } else if (variableListHandler.getStartTag().equals(name)) {
 102  39 definition.setVariableList(variableListHandler.getVariables());
 103  48 } else if (termHandler.getStartTag().equals(name)) {
 104  48 definition.setTerm(termHandler.getFormulaOrTerm());
 105  0 } else if (descriptionHandler.getStartTag().equals(name)) {
 106  0 definition.setDescription(descriptionHandler.getLatexList());
 107    } else {
 108  0 throw SyntaxException.createUnexpectedTagException(name);
 109    }
 110    }
 111   
 112  48 public final void characters(final String name, final String data) {
 113  48 if ("LATEXPATTERN".equals(name)) {
 114  48 latexPattern = data;
 115    } else {
 116  0 throw new RuntimeException("Unexpected character data in tag: " + name);
 117    }
 118    }
 119   
 120   
 121    }