Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../../img/srcFileCovDistChart9.png 45% of files have more coverage
12   81   9   2.4
8   36   0.75   5
5     1.8  
1    
 
  FormulaHandler       Line # 30 12 9 84% 0.84
 
  (102)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2013, 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.se.dto.module.FormulaVo;
19    import org.qedeq.kernel.xml.common.XmlSyntaxException;
20    import org.qedeq.kernel.xml.handler.common.AbstractSimpleHandler;
21    import org.qedeq.kernel.xml.handler.common.SimpleAttributes;
22    import org.qedeq.kernel.xml.handler.list.ElementHandler;
23   
24   
25    /**
26    * Parse formula.
27    *
28    * @author Michael Meyling
29    */
 
30    public class FormulaHandler extends AbstractSimpleHandler {
31   
32    /** Value object for formula. */
33    private FormulaVo formula;
34   
35    /** Handles {@link org.qedeq.kernel.se.base.list.Element}s. */
36    private final ElementHandler elementHandler;
37   
38   
39    /**
40    * Handles formulas.
41    *
42    * @param handler Parent handler.
43    */
 
44  5484 toggle public FormulaHandler(final AbstractSimpleHandler handler) {
45  5484 super(handler, "FORMULA");
46  5484 elementHandler = new ElementHandler(this);
47    }
48   
 
49  25397 toggle public final void init() {
50  25397 formula = null;
51    }
52   
53    /**
54    * Get parsed result.
55    *
56    * @return FormulaOrTerm.
57    */
 
58  25397 toggle public final FormulaVo getFormula() {
59  25397 return formula;
60    }
61   
 
62  50794 toggle public final void startElement(final String name, final SimpleAttributes attributes)
63    throws XmlSyntaxException {
64  50794 if (getStartTag().equals(name)) {
65    // nothing to do
66  25397 } else if (getLevel() > 1) {
67  25397 changeHandler(elementHandler, name, attributes);
68    } else {
69  0 throw XmlSyntaxException.createUnexpectedTagException(name);
70    }
71    }
72   
 
73  50794 toggle public final void endElement(final String name) throws XmlSyntaxException {
74  50794 if (getStartTag().equals(name)) {
75  25397 formula = new FormulaVo(elementHandler.getElement());
76  25397 } else if (getLevel() <= 1) {
77  0 throw XmlSyntaxException.createUnexpectedTagException(name);
78    }
79    }
80   
81    }