Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Do Dez 29 2005 18:38:29 CET
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.8 2005/08/19 04:13:28 m31 Exp $
 2    *
 3    * This file is part of the project "Hilbert II" - http://www.qedeq.org
 4    *
 5    * Copyright 2000-2005, 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.8 $
 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  17 public ChapterHandler(final AbstractSimpleHandler handler) {
 52  17 super(handler, "CHAPTER");
 53  17 titleHandler = new LatexListHandler(this, "TITLE");
 54  17 introductionHandler = new LatexListHandler(this, "INTRODUCTION");
 55  17 sectionHandler = new SectionHandler(this);
 56    }
 57   
 58  38 public void init() {
 59  38 chapter = null;
 60    }
 61   
 62    /**
 63    * Get parsed chapter.
 64    *
 65    * @return Chapter.
 66    */
 67  38 public final Chapter getChapter() {
 68  38 return chapter;
 69    }
 70   
 71  151 public final void startElement(final String name, final SimpleAttributes attributes)
 72    throws SyntaxException {
 73  151 if (getStartTag().equals(name)) {
 74  38 chapter = new ChapterVo();
 75  38 chapter.setNoNumber(attributes.getBoolean("noNumber"));
 76  113 } else if (titleHandler.getStartTag().equals(name)) {
 77  38 changeHandler(titleHandler, name, attributes);
 78  75 } else if (introductionHandler.getStartTag().equals(name)) {
 79  38 changeHandler(introductionHandler, name, attributes);
 80  37 } else if (sectionHandler.getStartTag().equals(name)) {
 81  37 changeHandler(sectionHandler, name, attributes);
 82    } else {
 83  0 throw SyntaxException.createUnexpectedTagException(name);
 84    }
 85    }
 86   
 87  151 public final void endElement(final String name) throws SyntaxException {
 88  151 if (getStartTag().equals(name)) {
 89    // nothing to do
 90  113 } else if (titleHandler.getStartTag().equals(name)) {
 91  38 chapter.setTitle(titleHandler.getLatexList());
 92  75 } else if (introductionHandler.getStartTag().equals(name)) {
 93  38 chapter.setIntroduction(introductionHandler.getLatexList());
 94  37 } else if (sectionHandler.getStartTag().equals(name)) {
 95  37 chapter.addSection(sectionHandler.getSection());
 96    } else {
 97  0 throw SyntaxException.createUnexpectedTagException(name);
 98    }
 99    }
 100   
 101   
 102    }