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