Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
24   111   13   4.8
16   53   0.54   5
5     2.6  
1    
 
  SectionHandler       Line # 30 24 13 91.1% 0.9111111
 
  (102)
 
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.dto.module.SectionVo;
19    import org.qedeq.kernel.xml.common.XmlSyntaxException;
20    import org.qedeq.kernel.xml.handler.common.AbstractSimpleHandler;
21    import org.qedeq.kernel.xml.handler.common.SimpleAttributes;
22   
23   
24    /**
25    * Handle sections.
26    *
27    * @version $Revision: 1.1 $
28    * @author Michael Meyling
29    */
 
30    public class SectionHandler extends AbstractSimpleHandler {
31   
32    /** Tag for introduction part. */
33    public static final String INTRODUCTION_TAG = "INTRODUCTION";
34   
35    /** Tag for section part. */
36    public static final String SECTION_TAG = "SECTION";
37   
38    /** Tag for title part. */
39    public static final String TITLE_TAG = "TITLE";
40   
41    /** Handle section title. */
42    private final LatexListHandler titleHandler;
43   
44    /** Handle section introduction. */
45    private final LatexListHandler introductionHandler;
46   
47    /** Handle single subsection. */
48    private final SubsectionListHandler subsectionListHandler;
49   
50    /** Section value object. */
51    private SectionVo section;
52   
53   
54    /**
55    * Constructor.
56    *
57    * @param handler
58    * Parent handler.
59    */
 
60  614 toggle public SectionHandler(final AbstractSimpleHandler handler) {
61  614 super(handler, SECTION_TAG);
62  614 titleHandler = new LatexListHandler(this, TITLE_TAG);
63  614 introductionHandler = new LatexListHandler(this, INTRODUCTION_TAG);
64  614 subsectionListHandler = new SubsectionListHandler(this);
65    }
66   
 
67  4796 toggle public final void init() {
68  4796 section = null;
69    }
70   
71    /**
72    * Get section.
73    *
74    * @return Section.
75    */
 
76  4796 toggle public final SectionVo getSection() {
77  4796 return section;
78    }
79   
 
80  17527 toggle public final void startElement(final String name, final SimpleAttributes attributes)
81    throws XmlSyntaxException {
82  17527 if (getStartTag().equals(name)) {
83  4796 section = new SectionVo();
84  4796 section.setNoNumber(attributes.getBoolean("noNumber"));
85  12731 } else if (TITLE_TAG.equals(name)) {
86  4796 changeHandler(titleHandler, name, attributes);
87  7935 } else if (INTRODUCTION_TAG.equals(name)) {
88  4785 changeHandler(introductionHandler, name, attributes);
89  3150 } else if ("SUBSECTIONS".equals(name)) {
90  3150 changeHandler(subsectionListHandler, name, attributes);
91    } else {
92  0 throw XmlSyntaxException.createUnexpectedTagException(name);
93    }
94    }
95   
 
96  17527 toggle public final void endElement(final String name) throws XmlSyntaxException {
97  17527 if (getStartTag().equals(name)) {
98    // nothing to do
99  12731 } else if (TITLE_TAG.equals(name)) {
100  4796 section.setTitle(titleHandler.getLatexList());
101  7935 } else if (INTRODUCTION_TAG.equals(name)) {
102  4785 section.setIntroduction(introductionHandler.getLatexList());
103  3150 } else if ("SUBSECTIONS".equals(name)) {
104  3150 section.setSubsectionList(subsectionListHandler.getSubsectionList());
105    } else {
106  0 throw XmlSyntaxException.createUnexpectedTagException(name);
107    }
108    }
109   
110   
111    }