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