Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../../img/srcFileCovDistChart0.png 96% of files have more coverage
27   110   15   4.5
18   58   0.56   6
6     2.5  
1    
 
  InitialFunctionDefinitionHandler       Line # 30 27 15 0% 0.0
 
No Tests
 
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.InitialFunctionDefinitionVo;
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 a function definition.
27    *
28    * @author Michael Meyling
29    */
 
30    public class InitialFunctionDefinitionHandler extends AbstractSimpleHandler {
31   
32    /** Handler for terms. */
33    private final ElementHandler elementHandler;
34   
35    /** Handler for rule description. */
36    private final LatexListHandler descriptionHandler;
37   
38    /** Definition value object. */
39    private InitialFunctionDefinitionVo definition;
40   
41    /** LaTeX pattern for the definition. */
42    private String latexPattern;
43   
44   
45    /**
46    * Deals with definitions.
47    *
48    * @param handler Parent handler.
49    */
 
50  0 toggle public InitialFunctionDefinitionHandler(final AbstractSimpleHandler handler) {
51  0 super(handler, "DEFINITION_FUNCTION");
52  0 elementHandler = new ElementHandler(this);
53  0 descriptionHandler = new LatexListHandler(this, "DESCRIPTION");
54    }
55   
 
56  0 toggle public final void init() {
57  0 definition = null;
58  0 latexPattern = null;
59    }
60   
61    /**
62    * Get definition.
63    *
64    * @return Definition.
65    */
 
66  0 toggle public final InitialFunctionDefinitionVo getDefinition() {
67  0 return definition;
68    }
69   
 
70  0 toggle public final void startElement(final String name, final SimpleAttributes attributes)
71    throws XmlSyntaxException {
72  0 if (getStartTag().equals(name)) {
73  0 definition = new InitialFunctionDefinitionVo();
74  0 definition.setArgumentNumber(attributes.getString("arguments"));
75  0 definition.setName(attributes.getString("name"));
76  0 } else if ("LATEXPATTERN".equals(name)) {
77    // nothing to do yet
78  0 } else if ("FUNCON".equals(name)) {
79  0 changeHandler(elementHandler, name, attributes);
80  0 } else if (descriptionHandler.getStartTag().equals(name)) {
81  0 changeHandler(descriptionHandler, name, attributes);
82    } else {
83  0 throw XmlSyntaxException.createUnexpectedTagException(name);
84    }
85    }
86   
 
87  0 toggle public final void endElement(final String name) throws XmlSyntaxException {
88  0 if (getStartTag().equals(name)) {
89    // nothing to do
90  0 } else if ("LATEXPATTERN".equals(name)) {
91  0 definition.setLatexPattern(latexPattern);
92  0 } else if ("FUNCON".equals(name)) {
93  0 definition.setFunCon(elementHandler.getElement());
94  0 } else if (descriptionHandler.getStartTag().equals(name)) {
95  0 definition.setDescription(descriptionHandler.getLatexList());
96    } else {
97  0 throw XmlSyntaxException.createUnexpectedTagException(name);
98    }
99    }
100   
 
101  0 toggle public final void characters(final String name, final String data) {
102  0 if ("LATEXPATTERN".equals(name)) {
103  0 latexPattern = data;
104    } else {
105  0 throw new RuntimeException("Unexpected character data in tag: " + name);
106    }
107    }
108   
109   
110    }