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