Clover Coverage Report
Coverage timestamp: Sa Aug 2 2008 13:56:27 CEST
../../../../../../img/srcFileCovDistChart8.png 47% of files have more coverage
32   121   17   5,33
22   64   0,53   6
6     2,83  
1    
 
  PredicateDefinitionHandler       Line # 33 32 17 76,7% 0.76666665
 
  (41)
 
1    /* $Id: PredicateDefinitionHandler.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.base.module.PredicateDefinition;
21    import org.qedeq.kernel.dto.module.PredicateDefinitionVo;
22    import org.qedeq.kernel.xml.common.XmlSyntaxException;
23    import org.qedeq.kernel.xml.parser.AbstractSimpleHandler;
24    import org.qedeq.kernel.xml.parser.SimpleAttributes;
25   
26   
27    /**
28    * Parse a predicate definition.
29    *
30    * @version $Revision: 1.1 $
31    * @author Michael Meyling
32    */
 
33    public class PredicateDefinitionHandler extends AbstractSimpleHandler {
34   
35    /** Handler for a variable list. */
36    private final VariableListHandler variableListHandler;
37   
38    /** Handler for formulas or terms. */
39    private final FormulaHandler formulaHandler;
40   
41    /** Handler for rule description. */
42    private final LatexListHandler descriptionHandler;
43   
44    /** Definition value object. */
45    private PredicateDefinitionVo definition;
46   
47    /** LaTeX pattern for the definition. */
48    private String latexPattern;
49   
50   
51    /**
52    * Deals with definitions.
53    *
54    * @param handler Parent handler.
55    */
 
56  140 toggle public PredicateDefinitionHandler(final AbstractSimpleHandler handler) {
57  140 super(handler, "DEFINITION_PREDICATE");
58  140 variableListHandler = new VariableListHandler(this);
59  140 formulaHandler = new FormulaHandler(this);
60  140 descriptionHandler = new LatexListHandler(this, "DESCRIPTION");
61    }
62   
 
63  214 toggle public final void init() {
64  214 definition = null;
65  214 latexPattern = null;
66    }
67   
68    /**
69    * Get definition.
70    *
71    * @return Definition.
72    */
 
73  214 toggle public final PredicateDefinition getDefinition() {
74  214 return definition;
75    }
76   
 
77  783 toggle public final void startElement(final String name, final SimpleAttributes attributes)
78    throws XmlSyntaxException {
79  783 if (getStartTag().equals(name)) {
80  214 definition = new PredicateDefinitionVo();
81  214 definition.setArgumentNumber(attributes.getString("arguments"));
82  214 definition.setName(attributes.getString("name"));
83  569 } else if ("LATEXPATTERN".equals(name)) {
84    // nothing to do yet
85  355 } else if (variableListHandler.getStartTag().equals(name)) {
86  196 changeHandler(variableListHandler, name, attributes);
87  159 } else if (formulaHandler.getStartTag().equals(name)) {
88  159 changeHandler(formulaHandler, name, attributes);
89  0 } else if (descriptionHandler.getStartTag().equals(name)) {
90  0 changeHandler(descriptionHandler, name, attributes);
91    } else {
92  0 throw XmlSyntaxException.createUnexpectedTagException(name);
93    }
94    }
95   
 
96  783 toggle public final void endElement(final String name) throws XmlSyntaxException {
97  783 if (getStartTag().equals(name)) {
98    // nothing to do
99  569 } else if ("LATEXPATTERN".equals(name)) {
100  214 definition.setLatexPattern(latexPattern);
101  355 } else if (variableListHandler.getStartTag().equals(name)) {
102  196 definition.setVariableList(variableListHandler.getVariables());
103  159 } else if (formulaHandler.getStartTag().equals(name)) {
104  159 definition.setFormula(formulaHandler.getFormula());
105  0 } else if (descriptionHandler.getStartTag().equals(name)) {
106  0 definition.setDescription(descriptionHandler.getLatexList());
107    } else {
108  0 throw XmlSyntaxException.createUnexpectedTagException(name);
109    }
110    }
111   
 
112  214 toggle public final void characters(final String name, final String data) {
113  214 if ("LATEXPATTERN".equals(name)) {
114  214 latexPattern = data;
115    } else {
116  0 throw new RuntimeException("Unexpected character data in tag: " + name);
117    }
118    }
119   
120   
121    }