Clover Coverage Report
Coverage timestamp: Fri Feb 14 2014 01:49:02 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
 
  (4)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2014, 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  147 toggle public ChapterHandler(final AbstractSimpleHandler handler) {
48  147 super(handler, "CHAPTER");
49  147 titleHandler = new LatexListHandler(this, "TITLE");
50  147 introductionHandler = new LatexListHandler(this, "INTRODUCTION");
51  147 sectionHandler = new SectionHandler(this);
52    }
53   
 
54  177 toggle public void init() {
55  177 chapter = null;
56    }
57   
58    /**
59    * Get parsed chapter.
60    *
61    * @return Chapter.
62    */
 
63  177 toggle public final ChapterVo getChapter() {
64  177 return chapter;
65    }
66   
 
67  627 toggle public final void startElement(final String name, final SimpleAttributes attributes)
68    throws XmlSyntaxException {
69  627 if (getStartTag().equals(name)) {
70  177 chapter = new ChapterVo();
71  177 chapter.setNoNumber(attributes.getBoolean("noNumber"));
72  450 } else if (titleHandler.getStartTag().equals(name)) {
73  177 changeHandler(titleHandler, name, attributes);
74  273 } else if (introductionHandler.getStartTag().equals(name)) {
75  106 changeHandler(introductionHandler, name, attributes);
76  167 } else if (sectionHandler.getStartTag().equals(name)) {
77  167 changeHandler(sectionHandler, name, attributes);
78    } else {
79  0 throw XmlSyntaxException.createUnexpectedTagException(name);
80    }
81    }
82   
 
83  627 toggle public final void endElement(final String name) throws XmlSyntaxException {
84  627 if (getStartTag().equals(name)) {
85    // nothing to do
86  450 } else if (titleHandler.getStartTag().equals(name)) {
87  177 chapter.setTitle(titleHandler.getLatexList());
88  273 } else if (introductionHandler.getStartTag().equals(name)) {
89  106 chapter.setIntroduction(introductionHandler.getLatexList());
90  167 } else if (sectionHandler.getStartTag().equals(name)) {
91  167 chapter.addSection(sectionHandler.getSection());
92    } else {
93  0 throw XmlSyntaxException.createUnexpectedTagException(name);
94    }
95    }
96   
97   
98    }