Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Do Jan 11 2007 09:03:50 CET
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.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.dto.module.FunctionDefinitionVo;
 21    import org.qedeq.kernel.xml.parser.AbstractSimpleHandler;
 22    import org.qedeq.kernel.xml.parser.SimpleAttributes;
 23    import org.qedeq.kernel.xml.parser.SyntaxException;
 24   
 25   
 26    /**
 27    * Parse a function definition.
 28    *
 29    * @version $Revision: 1.1 $
 30    * @author Michael Meyling
 31    */
 32    public final 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  27 public FunctionDefinitionHandler(final AbstractSimpleHandler handler) {
 56  27 super(handler, "DEFINITION_FUNCTION");
 57  27 variableListHandler = new VariableListHandler(this);
 58  27 termHandler = new TermHandler(this);
 59  27 descriptionHandler = new LatexListHandler(this, "DESCRIPTION");
 60    }
 61   
 62  48 public final void init() {
 63  48 definition = null;
 64  48 latexPattern = null;
 65    }
 66   
 67    /**
 68    * Get definition.
 69    *
 70    * @return Definition.
 71    */
 72  48 public final FunctionDefinitionVo getDefinition() {
 73  48 return definition;
 74    }
 75   
 76  183 public final void startElement(final String name, final SimpleAttributes attributes)
 77    throws SyntaxException {
 78  183 if (getStartTag().equals(name)) {
 79  48 definition = new FunctionDefinitionVo();
 80  48 definition.setArgumentNumber(attributes.getString("arguments"));
 81  48 definition.setName(attributes.getString("name"));
 82  135 } else if ("LATEXPATTERN".equals(name)) {
 83    // nothing to do yet
 84  87 } else if (variableListHandler.getStartTag().equals(name)) {
 85  39 changeHandler(variableListHandler, name, attributes);
 86  48 } else if (termHandler.getStartTag().equals(name)) {
 87  48 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  183 public final void endElement(final String name) throws SyntaxException {
 96  183 if (getStartTag().equals(name)) {
 97    // nothing to do
 98  135 } else if ("LATEXPATTERN".equals(name)) {
 99  48 definition.setLatexPattern(latexPattern);
 100  87 } else if (variableListHandler.getStartTag().equals(name)) {
 101  39 definition.setVariableList(variableListHandler.getVariables());
 102  48 } else if (termHandler.getStartTag().equals(name)) {
 103  48 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  48 public final void characters(final String name, final String data) {
 112  48 if ("LATEXPATTERN".equals(name)) {
 113  48 latexPattern = data;
 114    } else {
 115  0 throw new RuntimeException("Unexpected character data in tag: " + name);
 116    }
 117    }
 118   
 119   
 120    }