Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Sa Dez 22 2007 01:35:21 CET
file stats: LOC: 101   Methods: 5
NCLOC: 50   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ChapterHandler.java 87,5% 91,7% 100% 91,1%
coverage coverage
 1    /* $Id: ChapterHandler.java,v 1.14 2007/12/21 23:33:46 m31 Exp $
 2    *
 3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
 4    *
 5    * Copyright 2000-2007, 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.14 $
 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  490 public ChapterHandler(final AbstractSimpleHandler handler) {
 51  490 super(handler, "CHAPTER");
 52  490 titleHandler = new LatexListHandler(this, "TITLE");
 53  490 introductionHandler = new LatexListHandler(this, "INTRODUCTION");
 54  490 sectionHandler = new SectionHandler(this);
 55    }
 56   
 57  740 public void init() {
 58  740 chapter = null;
 59    }
 60   
 61    /**
 62    * Get parsed chapter.
 63    *
 64    * @return Chapter.
 65    */
 66  740 public final ChapterVo getChapter() {
 67  740 return chapter;
 68    }
 69   
 70  2491 public final void startElement(final String name, final SimpleAttributes attributes)
 71    throws XmlSyntaxException {
 72  2491 if (getStartTag().equals(name)) {
 73  740 chapter = new ChapterVo();
 74  740 chapter.setNoNumber(attributes.getBoolean("noNumber"));
 75  1751 } else if (titleHandler.getStartTag().equals(name)) {
 76  740 changeHandler(titleHandler, name, attributes);
 77  1011 } else if (introductionHandler.getStartTag().equals(name)) {
 78  377 changeHandler(introductionHandler, name, attributes);
 79  634 } else if (sectionHandler.getStartTag().equals(name)) {
 80  634 changeHandler(sectionHandler, name, attributes);
 81    } else {
 82  0 throw XmlSyntaxException.createUnexpectedTagException(name);
 83    }
 84    }
 85   
 86  2491 public final void endElement(final String name) throws XmlSyntaxException {
 87  2491 if (getStartTag().equals(name)) {
 88    // nothing to do
 89  1751 } else if (titleHandler.getStartTag().equals(name)) {
 90  740 chapter.setTitle(titleHandler.getLatexList());
 91  1011 } else if (introductionHandler.getStartTag().equals(name)) {
 92  377 chapter.setIntroduction(introductionHandler.getLatexList());
 93  634 } else if (sectionHandler.getStartTag().equals(name)) {
 94  634 chapter.addSection(sectionHandler.getSection());
 95    } else {
 96  0 throw XmlSyntaxException.createUnexpectedTagException(name);
 97    }
 98    }
 99   
 100   
 101    }