Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Sa Okt 21 2006 08:24:31 CEST
file stats: LOC: 102   Methods: 5
NCLOC: 51   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.base.module.Chapter;
 21    import org.qedeq.kernel.dto.module.ChapterVo;
 22    import org.qedeq.kernel.xml.parser.AbstractSimpleHandler;
 23    import org.qedeq.kernel.xml.parser.SyntaxException;
 24    import org.qedeq.kernel.xml.parser.SimpleAttributes;
 25   
 26    /**
 27    * Handles a chapter.
 28    *
 29    * @version $Revision: 1.9 $
 30    * @author Michael Meyling
 31    */
 32    public final class ChapterHandler extends AbstractSimpleHandler {
 33   
 34    /** Handles chapter title information. */
 35    private final LatexListHandler titleHandler;
 36   
 37    /** Handles chapter introduction. */
 38    private final LatexListHandler introductionHandler;
 39   
 40    /** Handles sections. */
 41    private final SectionHandler sectionHandler;
 42   
 43    /** Chapter value object. */
 44    private ChapterVo chapter;
 45   
 46    /**
 47    * Constructor.
 48    *
 49    * @param handler Parent handler.
 50    */
 51  25 public ChapterHandler(final AbstractSimpleHandler handler) {
 52  25 super(handler, "CHAPTER");
 53  25 titleHandler = new LatexListHandler(this, "TITLE");
 54  25 introductionHandler = new LatexListHandler(this, "INTRODUCTION");
 55  25 sectionHandler = new SectionHandler(this);
 56    }
 57   
 58  81 public void init() {
 59  81 chapter = null;
 60    }
 61   
 62    /**
 63    * Get parsed chapter.
 64    *
 65    * @return Chapter.
 66    */
 67  81 public final Chapter getChapter() {
 68  81 return chapter;
 69    }
 70   
 71  372 public final void startElement(final String name, final SimpleAttributes attributes)
 72    throws SyntaxException {
 73  372 if (getStartTag().equals(name)) {
 74  81 chapter = new ChapterVo();
 75  81 chapter.setNoNumber(attributes.getBoolean("noNumber"));
 76  291 } else if (titleHandler.getStartTag().equals(name)) {
 77  81 changeHandler(titleHandler, name, attributes);
 78  210 } else if (introductionHandler.getStartTag().equals(name)) {
 79  81 changeHandler(introductionHandler, name, attributes);
 80  129 } else if (sectionHandler.getStartTag().equals(name)) {
 81  129 changeHandler(sectionHandler, name, attributes);
 82    } else {
 83  0 throw SyntaxException.createUnexpectedTagException(name);
 84    }
 85    }
 86   
 87  372 public final void endElement(final String name) throws SyntaxException {
 88  372 if (getStartTag().equals(name)) {
 89    // nothing to do
 90  291 } else if (titleHandler.getStartTag().equals(name)) {
 91  81 chapter.setTitle(titleHandler.getLatexList());
 92  210 } else if (introductionHandler.getStartTag().equals(name)) {
 93  81 chapter.setIntroduction(introductionHandler.getLatexList());
 94  129 } else if (sectionHandler.getStartTag().equals(name)) {
 95  129 chapter.addSection(sectionHandler.getSection());
 96    } else {
 97  0 throw SyntaxException.createUnexpectedTagException(name);
 98    }
 99    }
 100   
 101   
 102    }