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