Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Sa Okt 21 2006 08:24:31 CEST
file stats: LOC: 148   Methods: 13
NCLOC: 70   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
SectionBo.java 100% 100% 100% 100%
coverage
 1    /* $Id: SectionBo.java,v 1.4 2006/10/20 20:23:00 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.bo.module;
 19   
 20    import org.qedeq.kernel.base.module.LatexList;
 21    import org.qedeq.kernel.base.module.Section;
 22    import org.qedeq.kernel.base.module.SubsectionList;
 23    import org.qedeq.kernel.base.module.SubsectionType;
 24    import org.qedeq.kernel.utility.EqualsUtility;
 25   
 26   
 27    /**
 28    * Section of a qedeq file.
 29    *
 30    * @version $Revision: 1.4 $
 31    * @author Michael Meyling
 32    */
 33    public final class SectionBo implements Section {
 34   
 35    /** No section number. */
 36    private Boolean noNumber;
 37   
 38    /** Section title. */
 39    private LatexList title;
 40   
 41    /** Section introduction. */
 42    private LatexList introduction;
 43   
 44    /** All subsections of this section. */
 45    private SubsectionListBo subsectionList;
 46   
 47    /**
 48    * Constructs a new section.
 49    */
 50  212 public SectionBo() {
 51    // nothing to do
 52    }
 53   
 54    /**
 55    * Set automatic numbering for this section off.
 56    *
 57    * @param noNumber Automatic section number?
 58    */
 59  68 public final void setNoNumber(final Boolean noNumber) {
 60  68 this.noNumber = noNumber;
 61    }
 62   
 63  531 public final Boolean getNoNumber() {
 64  531 return noNumber;
 65    }
 66   
 67    /**
 68    * Set title of this section.
 69    *
 70    * @param title Section title.
 71    */
 72  187 public final void setTitle(final LatexList title) {
 73  187 this.title = title;
 74    }
 75   
 76  700 public final LatexList getTitle() {
 77  700 return title;
 78    }
 79   
 80    /**
 81    * Set introduction text for this section.
 82    *
 83    * @param introduction Introduction text.
 84    */
 85  187 public final void setIntroduction(final LatexList introduction) {
 86  187 this.introduction = introduction;
 87    }
 88   
 89  684 public final LatexList getIntroduction() {
 90  684 return introduction;
 91    }
 92   
 93    /**
 94    * Set list of subsections.
 95    *
 96    * @param subsections Subsection list.
 97    */
 98  122 public final void setSubsectionList(final SubsectionListBo subsections) {
 99  122 this.subsectionList = subsections;
 100    }
 101   
 102  669 public final SubsectionList getSubsectionList() {
 103  669 return subsectionList;
 104    }
 105   
 106    /**
 107    * Add subsection to this list.
 108    *
 109    * @param subsection Subsection to add.
 110    */
 111  7 public final void addSubsection(final SubsectionType subsection) {
 112  7 if (subsectionList == null) {
 113  2 subsectionList = new SubsectionListBo(); // TODO mime 20050316: additional dependency.
 114    // Others work with inferfaces only
 115    }
 116  7 subsectionList.add(subsection);
 117    }
 118   
 119  152 public boolean equals(final Object obj) {
 120  152 if (!(obj instanceof SectionBo)) {
 121  9 return false;
 122    }
 123  143 final SectionBo other = (SectionBo) obj;
 124  143 return EqualsUtility.equals(getNoNumber(), other.getNoNumber())
 125    && EqualsUtility.equals(getTitle(), other.getTitle())
 126    && EqualsUtility.equals(getIntroduction(), other.getIntroduction())
 127    && EqualsUtility.equals(getSubsectionList(), other.getSubsectionList());
 128    }
 129   
 130  133 public int hashCode() {
 131  133 return (getNoNumber() != null ? getNoNumber().hashCode() : 0)
 132  133 ^ (getTitle() != null ? 1 ^ getTitle().hashCode() : 0)
 133  133 ^ (getIntroduction() != null ? 2 ^ getIntroduction().hashCode() : 0)
 134  133 ^ (getSubsectionList() != null ? 3 ^ getSubsectionList().hashCode() : 0);
 135    }
 136   
 137  109 public String toString() {
 138  109 final StringBuffer buffer = new StringBuffer();
 139  109 buffer.append("Section noNumbering: " + noNumber + "\n");
 140  109 buffer.append("Section Title: \n");
 141  109 buffer.append(getTitle() + "\n\n");
 142  109 buffer.append("Introduction: ");
 143  109 buffer.append(getIntroduction() + "\n\n");
 144  109 buffer.append(getSubsectionList() + "\n");
 145  109 return buffer.toString();
 146    }
 147   
 148    }