Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../../img/srcFileCovDistChart9.png 45% of files have more coverage
22   105   12   4.4
14   54   0.55   5
5     2.4  
1    
 
  SubstFuncvarHandler       Line # 32 22 12 90.2% 0.902439
 
  (101)
 
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.base.list.Element;
19    import org.qedeq.kernel.se.base.module.Term;
20    import org.qedeq.kernel.se.dto.module.SubstFuncVo;
21    import org.qedeq.kernel.xml.common.XmlSyntaxException;
22    import org.qedeq.kernel.xml.handler.common.AbstractSimpleHandler;
23    import org.qedeq.kernel.xml.handler.common.SimpleAttributes;
24    import org.qedeq.kernel.xml.handler.list.ElementHandler;
25   
26   
27    /**
28    * Parse a Substitute Function Variable Rule usage.
29    *
30    * @author Michael Meyling
31    */
 
32    public class SubstFuncvarHandler extends AbstractSimpleHandler {
33   
34    /** Rule value object. */
35    private SubstFuncVo substFunc;
36   
37    /** Reference to previously proved formula. */
38    private String ref;
39   
40    /** Function variable we want to substitute. */
41    private Element functionVariable;
42   
43    /** Replacement term. */
44    private Term substituteTerm;
45   
46    /** Handle terms. */
47    private final TermHandler termHandler;
48   
49    /** Handle elements. */
50    private final ElementHandler elementHandler;
51   
52    /**
53    * Deals with definitions.
54    *
55    * @param handler Parent handler.
56    */
 
57  1064 toggle public SubstFuncvarHandler(final AbstractSimpleHandler handler) {
58  1064 super(handler, "SUBST_FUNVAR");
59  1064 termHandler = new TermHandler(this);
60  1064 elementHandler = new ElementHandler(this);
61    }
62   
 
63  55 toggle public final void init() {
64  55 substFunc = null;
65  55 substituteTerm = null;
66  55 functionVariable = null;
67  55 ref = null;
68    }
69   
70    /**
71    * Get Substitute Function Variable Rule usage.
72    *
73    * @return Substitute Free Variable usage.
74    */
 
75  55 toggle public final SubstFuncVo getSubstFuncVo() {
76  55 return substFunc;
77    }
78   
 
79  132 toggle public final void startElement(final String name, final SimpleAttributes attributes)
80    throws XmlSyntaxException {
81  132 if (getStartTag().equals(name)) {
82  55 ref = attributes.getString("ref");
83  77 } else if ("FUNVAR".equals(name)) {
84  33 changeHandler(elementHandler, name, attributes);
85  44 } else if (termHandler.getStartTag().equals(name)) {
86  44 changeHandler(termHandler, name, attributes);
87    } else {
88  0 throw XmlSyntaxException.createUnexpectedTagException(name);
89    }
90    }
91   
 
92  132 toggle public final void endElement(final String name) throws XmlSyntaxException {
93  132 if (getStartTag().equals(name)) {
94  55 substFunc = new SubstFuncVo(ref, functionVariable,
95  55 (substituteTerm != null ? substituteTerm.getElement() : null));
96  77 } else if ("FUNVAR".equals(name)) {
97  33 functionVariable = elementHandler.getElement();
98  44 } else if (termHandler.getStartTag().equals(name)) {
99  44 substituteTerm = termHandler.getTerm();
100    } else {
101  0 throw XmlSyntaxException.createUnexpectedTagException(name);
102    }
103    }
104   
105    }