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