Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../../img/srcFileCovDistChart9.png 45% of files have more coverage
21   95   11   4.2
12   47   0.52   5
5     2.2  
1    
 
  SubsectionHandler       Line # 31 21 11 89.5% 0.8947368
 
  (101)
 
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.Subsection;
19    import org.qedeq.kernel.se.dto.module.SubsectionVo;
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   
24   
25    /**
26    * Parses subsection data.
27    *
28    * @version $Revision: 1.1 $
29    * @author Michael Meyling
30    */
 
31    public class SubsectionHandler extends AbstractSimpleHandler {
32   
33    /** Handler for subsection title. */
34    private final LatexListHandler titleHandler;
35   
36    /** Handler for subsection text. */
37    private final LatexListHandler latexHandler;
38   
39    /** Subsection. */
40    private SubsectionVo subsection;
41   
42   
43    /**
44    * Constructor.
45    *
46    * @param handler Parent handler.
47    */
 
48  614 toggle public SubsectionHandler(final AbstractSimpleHandler handler) {
49  614 super(handler, "SUBSECTION");
50  614 titleHandler = new LatexListHandler(this, "TITLE");
51  614 latexHandler = new LatexListHandler(this, "TEXT");
52  614 subsection = new SubsectionVo();
53    }
54   
 
55  1106 toggle public final void init() {
56  1106 subsection = null;
57    }
58   
59    /**
60    * Get subsection.
61    *
62    * @return Subsection.
63    */
 
64  1106 toggle public final Subsection getSubsection() {
65  1106 return subsection;
66    }
67   
 
68  2446 toggle public final void startElement(final String name, final SimpleAttributes attributes)
69    throws XmlSyntaxException {
70  2446 if (getStartTag().equals(name)) {
71  1106 subsection = new SubsectionVo();
72  1106 subsection.setId(attributes.getString("id"));
73  1106 subsection.setLevel(attributes.getString("level"));
74  1340 } else if (titleHandler.getStartTag().equals(name)) {
75  234 changeHandler(titleHandler, name, attributes);
76  1106 } else if (latexHandler.getStartTag().equals(name)) {
77  1106 changeHandler(latexHandler, name, attributes);
78    } else {
79  0 throw XmlSyntaxException.createUnexpectedTagException(name);
80    }
81    }
82   
 
83  2446 toggle public final void endElement(final String name) throws XmlSyntaxException {
84  2446 if (getStartTag().equals(name)) {
85    // thats why we handle it
86  1340 } else if (titleHandler.getStartTag().equals(name)) {
87  234 subsection.setTitle(titleHandler.getLatexList());
88  1106 } else if (latexHandler.getStartTag().equals(name)) {
89  1106 subsection.setLatex(latexHandler.getLatexList());
90    } else {
91  0 throw XmlSyntaxException.createUnexpectedTagException(name);
92    }
93    }
94   
95    }