Clover Coverage Report
Coverage timestamp: Sat Sep 18 2010 04:09:52 UTC
../../../../../../img/srcFileCovDistChart9.png 34% of files have more coverage
12   81   9   2.4
8   36   0.75   5
5     1.8  
1    
 
  FormulaHandler       Line # 31 12 9 84% 0.84
 
  (55)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2010, Michael Meyling <mime@qedeq.org>.
4    *
5    * "Hilbert II" is free software; you can redistribute
6    * it and/or modify it under the terms of the GNU General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10    * This program is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13    * GNU General Public License for more details.
14    */
15   
16    package org.qedeq.kernel.xml.handler.module;
17   
18    import org.qedeq.kernel.dto.module.FormulaVo;
19    import org.qedeq.kernel.xml.common.XmlSyntaxException;
20    import org.qedeq.kernel.xml.handler.list.ElementHandler;
21    import org.qedeq.kernel.xml.parser.AbstractSimpleHandler;
22    import org.qedeq.kernel.xml.parser.SimpleAttributes;
23   
24   
25    /**
26    * Parse formula.
27    *
28    * @version $Revision: 1.1 $
29    * @author Michael Meyling
30    */
 
31    public class FormulaHandler extends AbstractSimpleHandler {
32   
33    /** Value object for formula. */
34    private FormulaVo formula;
35   
36    /** Handles {@link org.qedeq.kernel.base.list.Element}s. */
37    private final ElementHandler elementHandler;
38   
39   
40    /**
41    * Handles formulas.
42    *
43    * @param handler Parent handler.
44    */
 
45  531 toggle public FormulaHandler(final AbstractSimpleHandler handler) {
46  531 super(handler, "FORMULA");
47  531 elementHandler = new ElementHandler(this);
48    }
49   
 
50  976 toggle public final void init() {
51  976 formula = null;
52    }
53   
54    /**
55    * Get parsed result.
56    *
57    * @return FormulaOrTerm.
58    */
 
59  976 toggle public final FormulaVo getFormula() {
60  976 return formula;
61    }
62   
 
63  1952 toggle public final void startElement(final String name, final SimpleAttributes attributes)
64    throws XmlSyntaxException {
65  1952 if (getStartTag().equals(name)) {
66    // nothing to do
67  976 } else if (getLevel() > 1) {
68  976 changeHandler(elementHandler, name, attributes);
69    } else {
70  0 throw XmlSyntaxException.createUnexpectedTagException(name);
71    }
72    }
73   
 
74  1952 toggle public final void endElement(final String name) throws XmlSyntaxException {
75  1952 if (getStartTag().equals(name)) {
76  976 formula = new FormulaVo(elementHandler.getElement());
77  976 } else if (getLevel() <= 1) {
78  0 throw XmlSyntaxException.createUnexpectedTagException(name);
79    }
80    }
81    }