Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Sa Okt 21 2006 08:24:31 CEST
file stats: LOC: 114   Methods: 5
NCLOC: 54   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
SectionHandler.java 87,5% 91,7% 100% 91,1%
coverage coverage
 1    /* $Id: SectionHandler.java,v 1.11 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.Section;
 21    import org.qedeq.kernel.dto.module.SectionVo;
 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    /**
 28    * Handle sections.
 29    *
 30    * @version $Revision: 1.11 $
 31    * @author Michael Meyling
 32    */
 33    public final class SectionHandler extends AbstractSimpleHandler {
 34   
 35    /** Tag for introduction part. */
 36    public static final String INTRODUCTION_TAG = "INTRODUCTION";
 37   
 38    /** Tag for section part. */
 39    public static final String SECTION_TAG = "SECTION";
 40   
 41    /** Tag for title part. */
 42    public static final String TITLE_TAG = "TITLE";
 43   
 44    /** Handle section title. */
 45    private final LatexListHandler titleHandler;
 46   
 47    /** Handle section introduction. */
 48    private final LatexListHandler introductionHandler;
 49   
 50    /** Handle single subsection. */
 51    private final SubsectionListHandler subsectionListHandler;
 52   
 53    /** Section value object. */
 54    private SectionVo section;
 55   
 56   
 57    /**
 58    * Constructor.
 59    *
 60    * @param handler
 61    * Parent handler.
 62    */
 63  25 public SectionHandler(final AbstractSimpleHandler handler) {
 64  25 super(handler, SECTION_TAG);
 65  25 titleHandler = new LatexListHandler(this, TITLE_TAG);
 66  25 introductionHandler = new LatexListHandler(this, INTRODUCTION_TAG);
 67  25 subsectionListHandler = new SubsectionListHandler(this);
 68    }
 69   
 70  129 public final void init() {
 71  129 section = null;
 72    }
 73   
 74    /**
 75    * Get section.
 76    *
 77    * @return Section.
 78    */
 79  129 public final Section getSection() {
 80  129 return section;
 81    }
 82   
 83  452 public final void startElement(final String name, final SimpleAttributes attributes)
 84    throws SyntaxException {
 85  452 if (getStartTag().equals(name)) {
 86  129 section = new SectionVo();
 87  129 section.setNoNumber(attributes.getBoolean("noNumber"));
 88  323 } else if (TITLE_TAG.equals(name)) {
 89  129 changeHandler(titleHandler, name, attributes);
 90  194 } else if (INTRODUCTION_TAG.equals(name)) {
 91  128 changeHandler(introductionHandler, name, attributes);
 92  66 } else if ("SUBSECTIONS".equals(name)) {
 93  66 changeHandler(subsectionListHandler, name, attributes);
 94    } else {
 95  0 throw SyntaxException.createUnexpectedTagException(name);
 96    }
 97    }
 98   
 99  452 public final void endElement(final String name) throws SyntaxException {
 100  452 if (getStartTag().equals(name)) {
 101    // nothing to do
 102  323 } else if (TITLE_TAG.equals(name)) {
 103  129 section.setTitle(titleHandler.getLatexList());
 104  194 } else if (INTRODUCTION_TAG.equals(name)) {
 105  128 section.setIntroduction(introductionHandler.getLatexList());
 106  66 } else if ("SUBSECTIONS".equals(name)) {
 107  66 section.setSubsectionList(subsectionListHandler.getSubsectionList());
 108    } else {
 109  0 throw SyntaxException.createUnexpectedTagException(name);
 110    }
 111    }
 112   
 113   
 114    }