Clover Coverage Report
Coverage timestamp: Sat Sep 18 2010 04:09:52 UTC
../../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
24   99   13   4.8
16   50   0.54   5
5     2.6  
1    
 
  ChapterHandler       Line # 29 24 13 91.1% 0.9111111
 
  (55)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2010, 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.dto.module.ChapterVo;
19    import org.qedeq.kernel.xml.common.XmlSyntaxException;
20    import org.qedeq.kernel.xml.parser.AbstractSimpleHandler;
21    import org.qedeq.kernel.xml.parser.SimpleAttributes;
22   
23    /**
24    * Handles a chapter.
25    *
26    * @version $Revision: 1.1 $
27    * @author Michael Meyling
28    */
 
29    public class ChapterHandler extends AbstractSimpleHandler {
30   
31    /** Handles chapter title information. */
32    private final LatexListHandler titleHandler;
33   
34    /** Handles chapter introduction. */
35    private final LatexListHandler introductionHandler;
36   
37    /** Handles sections. */
38    private final SectionHandler sectionHandler;
39   
40    /** Chapter value object. */
41    private ChapterVo chapter;
42   
43    /**
44    * Constructor.
45    *
46    * @param handler Parent handler.
47    */
 
48  177 toggle public ChapterHandler(final AbstractSimpleHandler handler) {
49  177 super(handler, "CHAPTER");
50  177 titleHandler = new LatexListHandler(this, "TITLE");
51  177 introductionHandler = new LatexListHandler(this, "INTRODUCTION");
52  177 sectionHandler = new SectionHandler(this);
53    }
54   
 
55  340 toggle public void init() {
56  340 chapter = null;
57    }
58   
59    /**
60    * Get parsed chapter.
61    *
62    * @return Chapter.
63    */
 
64  340 toggle public final ChapterVo getChapter() {
65  340 return chapter;
66    }
67   
 
68  1381 toggle public final void startElement(final String name, final SimpleAttributes attributes)
69    throws XmlSyntaxException {
70  1381 if (getStartTag().equals(name)) {
71  340 chapter = new ChapterVo();
72  340 chapter.setNoNumber(attributes.getBoolean("noNumber"));
73  1041 } else if (titleHandler.getStartTag().equals(name)) {
74  340 changeHandler(titleHandler, name, attributes);
75  701 } else if (introductionHandler.getStartTag().equals(name)) {
76  273 changeHandler(introductionHandler, name, attributes);
77  428 } else if (sectionHandler.getStartTag().equals(name)) {
78  428 changeHandler(sectionHandler, name, attributes);
79    } else {
80  0 throw XmlSyntaxException.createUnexpectedTagException(name);
81    }
82    }
83   
 
84  1381 toggle public final void endElement(final String name) throws XmlSyntaxException {
85  1381 if (getStartTag().equals(name)) {
86    // nothing to do
87  1041 } else if (titleHandler.getStartTag().equals(name)) {
88  340 chapter.setTitle(titleHandler.getLatexList());
89  701 } else if (introductionHandler.getStartTag().equals(name)) {
90  273 chapter.setIntroduction(introductionHandler.getLatexList());
91  428 } else if (sectionHandler.getStartTag().equals(name)) {
92  428 chapter.addSection(sectionHandler.getSection());
93    } else {
94  0 throw XmlSyntaxException.createUnexpectedTagException(name);
95    }
96    }
97   
98   
99    }