Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Do Jan 11 2007 09:03:50 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.9 2006/10/20 20:23:02 m31 Exp $
 2    *
 3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
 4    *
 5    * Copyright 2000-2006, 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.parser.AbstractSimpleHandler;
 22    import org.qedeq.kernel.xml.parser.SimpleAttributes;
 23    import org.qedeq.kernel.xml.parser.SyntaxException;
 24   
 25    /**
 26    * Handles a chapter.
 27    *
 28    * @version $Revision: 1.9 $
 29    * @author Michael Meyling
 30    */
 31    public final 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  27 public ChapterHandler(final AbstractSimpleHandler handler) {
 51  27 super(handler, "CHAPTER");
 52  27 titleHandler = new LatexListHandler(this, "TITLE");
 53  27 introductionHandler = new LatexListHandler(this, "INTRODUCTION");
 54  27 sectionHandler = new SectionHandler(this);
 55    }
 56   
 57  85 public void init() {
 58  85 chapter = null;
 59    }
 60   
 61    /**
 62    * Get parsed chapter.
 63    *
 64    * @return Chapter.
 65    */
 66  85 public final ChapterVo getChapter() {
 67  85 return chapter;
 68    }
 69   
 70  390 public final void startElement(final String name, final SimpleAttributes attributes)
 71    throws SyntaxException {
 72  390 if (getStartTag().equals(name)) {
 73  85 chapter = new ChapterVo();
 74  85 chapter.setNoNumber(attributes.getBoolean("noNumber"));
 75  305 } else if (titleHandler.getStartTag().equals(name)) {
 76  85 changeHandler(titleHandler, name, attributes);
 77  220 } else if (introductionHandler.getStartTag().equals(name)) {
 78  85 changeHandler(introductionHandler, name, attributes);
 79  135 } else if (sectionHandler.getStartTag().equals(name)) {
 80  135 changeHandler(sectionHandler, name, attributes);
 81    } else {
 82  0 throw SyntaxException.createUnexpectedTagException(name);
 83    }
 84    }
 85   
 86  390 public final void endElement(final String name) throws SyntaxException {
 87  390 if (getStartTag().equals(name)) {
 88    // nothing to do
 89  305 } else if (titleHandler.getStartTag().equals(name)) {
 90  85 chapter.setTitle(titleHandler.getLatexList());
 91  220 } else if (introductionHandler.getStartTag().equals(name)) {
 92  85 chapter.setIntroduction(introductionHandler.getLatexList());
 93  135 } else if (sectionHandler.getStartTag().equals(name)) {
 94  135 chapter.addSection(sectionHandler.getSection());
 95    } else {
 96  0 throw SyntaxException.createUnexpectedTagException(name);
 97    }
 98    }
 99   
 100   
 101    }