Clover Coverage Report
Coverage timestamp: Sa Aug 2 2008 13:56:27 CEST
../../../../../../img/srcFileCovDistChart8.png 47% of files have more coverage
32   120   17   5,33
22   63   0,53   6
6     2,83  
1    
 
  FunctionDefinitionHandler       Line # 32 32 17 76,7% 0.76666665
 
  (40)
 
1    /* $Id: FunctionDefinitionHandler.java,v 1.1 2008/07/26 08:00:51 m31 Exp $
2    *
3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
4    *
5    * Copyright 2000-2008, 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.common.XmlSyntaxException;
22    import org.qedeq.kernel.xml.parser.AbstractSimpleHandler;
23    import org.qedeq.kernel.xml.parser.SimpleAttributes;
24   
25   
26    /**
27    * Parse a function definition.
28    *
29    * @version $Revision: 1.1 $
30    * @author Michael Meyling
31    */
 
32    public 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  140 toggle public FunctionDefinitionHandler(final AbstractSimpleHandler handler) {
56  140 super(handler, "DEFINITION_FUNCTION");
57  140 variableListHandler = new VariableListHandler(this);
58  140 termHandler = new TermHandler(this);
59  140 descriptionHandler = new LatexListHandler(this, "DESCRIPTION");
60    }
61   
 
62  128 toggle public final void init() {
63  128 definition = null;
64  128 latexPattern = null;
65    }
66   
67    /**
68    * Get definition.
69    *
70    * @return Definition.
71    */
 
72  128 toggle public final FunctionDefinitionVo getDefinition() {
73  128 return definition;
74    }
75   
 
76  488 toggle public final void startElement(final String name, final SimpleAttributes attributes)
77    throws XmlSyntaxException {
78  488 if (getStartTag().equals(name)) {
79  128 definition = new FunctionDefinitionVo();
80  128 definition.setArgumentNumber(attributes.getString("arguments"));
81  128 definition.setName(attributes.getString("name"));
82  360 } else if ("LATEXPATTERN".equals(name)) {
83    // nothing to do yet
84  232 } else if (variableListHandler.getStartTag().equals(name)) {
85  104 changeHandler(variableListHandler, name, attributes);
86  128 } else if (termHandler.getStartTag().equals(name)) {
87  128 changeHandler(termHandler, name, attributes);
88  0 } else if (descriptionHandler.getStartTag().equals(name)) {
89  0 changeHandler(descriptionHandler, name, attributes);
90    } else {
91  0 throw XmlSyntaxException.createUnexpectedTagException(name);
92    }
93    }
94   
 
95  488 toggle public final void endElement(final String name) throws XmlSyntaxException {
96  488 if (getStartTag().equals(name)) {
97    // nothing to do
98  360 } else if ("LATEXPATTERN".equals(name)) {
99  128 definition.setLatexPattern(latexPattern);
100  232 } else if (variableListHandler.getStartTag().equals(name)) {
101  104 definition.setVariableList(variableListHandler.getVariables());
102  128 } else if (termHandler.getStartTag().equals(name)) {
103  128 definition.setTerm(termHandler.getTerm());
104  0 } else if (descriptionHandler.getStartTag().equals(name)) {
105  0 definition.setDescription(descriptionHandler.getLatexList());
106    } else {
107  0 throw XmlSyntaxException.createUnexpectedTagException(name);
108    }
109    }
110   
 
111  128 toggle public final void characters(final String name, final String data) {
112  128 if ("LATEXPATTERN".equals(name)) {
113  128 latexPattern = data;
114    } else {
115  0 throw new RuntimeException("Unexpected character data in tag: " + name);
116    }
117    }
118   
119   
120    }