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