Clover Coverage Report
Coverage timestamp: Sa Aug 2 2008 13:56:27 CEST
../../../../../../img/srcFileCovDistChart7.png 62% of files have more coverage
26   107   15   5,2
20   56   0,58   5
5     3  
1    
 
  RuleHandler       Line # 33 26 15 68,6% 0.6862745
 
  (40)
 
1    /* $Id: RuleHandler.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.Rule;
21    import org.qedeq.kernel.dto.module.RuleVo;
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 rule.
29    *
30    * @version $Revision: 1.1 $
31    * @author Michael Meyling
32    */
 
33    public class RuleHandler extends AbstractSimpleHandler {
34   
35    /** Handler for rule description. */
36    private final LatexListHandler descriptionHandler;
37   
38    /** Handle proofs. */
39    private final ProofHandler proofHandler;
40   
41    /** Rule value object. */
42    private RuleVo rule;
43   
44    /**
45    * Deals with definitions.
46    *
47    * @param handler Parent handler.
48    */
 
49  140 toggle public RuleHandler(final AbstractSimpleHandler handler) {
50  140 super(handler, "RULE");
51  140 descriptionHandler = new LatexListHandler(this, "DESCRIPTION");
52  140 proofHandler = new ProofHandler(this);
53    }
54   
 
55  116 toggle public final void init() {
56  116 rule = null;
57    }
58   
59    /**
60    * Get Rule.
61    *
62    * @return Rule.
63    */
 
64  116 toggle public final Rule getRule() {
65  116 return rule;
66    }
67   
 
68  240 toggle public final void startElement(final String name, final SimpleAttributes attributes)
69    throws XmlSyntaxException {
70  240 if (getStartTag().equals(name)) {
71  116 rule = new RuleVo();
72  116 if (null != attributes.getString("name")) {
73  116 rule.setName(attributes.getString("name"));
74    } else {
75  0 throw XmlSyntaxException.createMissingAttributeException(name, "name");
76    }
77  124 } else if ("LINK".equals(name)) {
78  8 if (null != attributes.getString("id")) {
79  8 rule.addLink(attributes.getString("id"));
80    } else {
81  0 throw XmlSyntaxException.createMissingAttributeException(name, "id");
82    }
83  116 } else if (descriptionHandler.getStartTag().equals(name)) {
84  116 changeHandler(descriptionHandler, name, attributes);
85  0 } else if (proofHandler.getStartTag().equals(name)) {
86  0 changeHandler(proofHandler, name, attributes);
87    } else {
88  0 throw XmlSyntaxException.createUnexpectedTagException(name);
89    }
90    }
91   
 
92  240 toggle public final void endElement(final String name) throws XmlSyntaxException {
93  240 if (getStartTag().equals(name)) {
94    // nothing to do
95  124 } else if ("LINK".equals(name)) {
96    // nothing to do
97  116 } else if (descriptionHandler.getStartTag().equals(name)) {
98  116 rule.setDescription(descriptionHandler.getLatexList());
99  0 } else if (proofHandler.getStartTag().equals(name)) {
100  0 rule.addProof(proofHandler.getProof());
101    } else {
102  0 throw XmlSyntaxException.createUnexpectedTagException(name);
103    }
104    }
105   
106   
107    }