Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
24   98   13   4.8
16   50   0.54   5
5     2.6  
1    
 
  ChapterHandler       Line # 28 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.ChapterVo;
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    * Handles a chapter.
25    *
26    * @author Michael Meyling
27    */
 
28    public class ChapterHandler extends AbstractSimpleHandler {
29   
30    /** Handles chapter title information. */
31    private final LatexListHandler titleHandler;
32   
33    /** Handles chapter introduction. */
34    private final LatexListHandler introductionHandler;
35   
36    /** Handles sections. */
37    private final SectionHandler sectionHandler;
38   
39    /** Chapter value object. */
40    private ChapterVo chapter;
41   
42    /**
43    * Constructor.
44    *
45    * @param handler Parent handler.
46    */
 
47  614 toggle public ChapterHandler(final AbstractSimpleHandler handler) {
48  614 super(handler, "CHAPTER");
49  614 titleHandler = new LatexListHandler(this, "TITLE");
50  614 introductionHandler = new LatexListHandler(this, "INTRODUCTION");
51  614 sectionHandler = new SectionHandler(this);
52    }
53   
 
54  2337 toggle public void init() {
55  2337 chapter = null;
56    }
57   
58    /**
59    * Get parsed chapter.
60    *
61    * @return Chapter.
62    */
 
63  2337 toggle public final ChapterVo getChapter() {
64  2337 return chapter;
65    }
66   
 
67  11669 toggle public final void startElement(final String name, final SimpleAttributes attributes)
68    throws XmlSyntaxException {
69  11669 if (getStartTag().equals(name)) {
70  2337 chapter = new ChapterVo();
71  2337 chapter.setNoNumber(attributes.getBoolean("noNumber"));
72  9332 } else if (titleHandler.getStartTag().equals(name)) {
73  2337 changeHandler(titleHandler, name, attributes);
74  6995 } else if (introductionHandler.getStartTag().equals(name)) {
75  2199 changeHandler(introductionHandler, name, attributes);
76  4796 } else if (sectionHandler.getStartTag().equals(name)) {
77  4796 changeHandler(sectionHandler, name, attributes);
78    } else {
79  0 throw XmlSyntaxException.createUnexpectedTagException(name);
80    }
81    }
82   
 
83  11669 toggle public final void endElement(final String name) throws XmlSyntaxException {
84  11669 if (getStartTag().equals(name)) {
85    // nothing to do
86  9332 } else if (titleHandler.getStartTag().equals(name)) {
87  2337 chapter.setTitle(titleHandler.getLatexList());
88  6995 } else if (introductionHandler.getStartTag().equals(name)) {
89  2199 chapter.setIntroduction(introductionHandler.getLatexList());
90  4796 } else if (sectionHandler.getStartTag().equals(name)) {
91  4796 chapter.addSection(sectionHandler.getSection());
92    } else {
93  0 throw XmlSyntaxException.createUnexpectedTagException(name);
94    }
95    }
96   
97   
98    }