Clover coverage report - QedeqKernelSe Coverage Report
Coverage timestamp: Do Dez 29 2005 18:38:29 CET
file stats: LOC: 148   Methods: 13
NCLOC: 70   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ChapterBo.java 100% 100% 100% 100%
coverage
 1    /* $Id: ChapterBo.java,v 1.3 2005/06/15 16:11:46 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.bo.module;
 19   
 20    import org.qedeq.kernel.base.module.Chapter;
 21    import org.qedeq.kernel.base.module.LatexList;
 22    import org.qedeq.kernel.base.module.Section;
 23    import org.qedeq.kernel.base.module.SectionList;
 24    import org.qedeq.kernel.utility.EqualsUtility;
 25   
 26   
 27    /**
 28    * Chapter.
 29    *
 30    * @version $Revision: 1.3 $
 31    * @author Michael Meyling
 32    */
 33    public final class ChapterBo implements Chapter {
 34   
 35    /** Chapter title. */
 36    private LatexList title;
 37   
 38    /** No chapter number. */
 39    private Boolean noNumber;
 40   
 41    /** Chapter introduction. */
 42    private LatexList introduction;
 43   
 44    /** List of chapter sections. */
 45    private SectionListBo sectionList;
 46   
 47    /**
 48    * Constructs a new chapter.
 49    */
 50  96 public ChapterBo() {
 51    // nothing to do
 52    }
 53   
 54    /**
 55    * Set if this chapter has no number.
 56    *
 57    * @param noNumber Has this chapter no number?
 58    */
 59  51 public final void setNoNumber(final Boolean noNumber) {
 60  51 this.noNumber = noNumber;
 61    }
 62   
 63  483 public final Boolean getNoNumber() {
 64  483 return noNumber;
 65    }
 66   
 67    /**
 68    * Set chapter title.
 69    *
 70    * @param title Chapter title.
 71    */
 72  71 public final void setTitle(final LatexList title) {
 73  71 this.title = title;
 74    }
 75   
 76  457 public final LatexList getTitle() {
 77  457 return title;
 78    }
 79   
 80    /**
 81    * Set introduction text for this chapter.
 82    *
 83    * @param introduction Chapter introduction text.
 84    */
 85  71 public final void setIntroduction(final LatexList introduction) {
 86  71 this.introduction = introduction;
 87    }
 88   
 89  433 public final LatexList getIntroduction() {
 90  433 return introduction;
 91    }
 92   
 93    /**
 94    * Set section list of this chapter.
 95    *
 96    * @param sections Chapter sections.
 97    */
 98  53 public final void setSectionList(final SectionListBo sections) {
 99  53 this.sectionList = sections;
 100    }
 101   
 102  398 public final SectionList getSectionList() {
 103  398 return sectionList;
 104    }
 105   
 106    /**
 107    * Add section to list.
 108    *
 109    * @param section Add this section.
 110    */
 111  7 public final void addSection(final Section section) {
 112  7 if (sectionList == null) { // TODO mime 20050316: creates additional dependency.
 113    // At other locations only an interface is referenced!
 114  2 sectionList = new SectionListBo();
 115    }
 116  7 sectionList.add(section);
 117    }
 118   
 119  103 public boolean equals(final Object obj) {
 120  103 if (!(obj instanceof ChapterBo)) {
 121  9 return false;
 122    }
 123  94 final ChapterBo other = (ChapterBo) obj;
 124  94 return EqualsUtility.equals(getNoNumber(), other.getNoNumber())
 125    && EqualsUtility.equals(getTitle(), other.getTitle())
 126    && EqualsUtility.equals(getIntroduction(), other.getIntroduction())
 127    && EqualsUtility.equals(getSectionList(), other.getSectionList());
 128    }
 129   
 130  93 public int hashCode() {
 131  93 return (getNoNumber() != null ? getNoNumber().hashCode() : 0)
 132  93 ^ (getTitle() != null ? getTitle().hashCode() : 0)
 133  93 ^ (getIntroduction() != null ? 1 ^ getIntroduction().hashCode() : 0)
 134  93 ^ (getSectionList() != null ? 2 ^ getSectionList().hashCode() : 0);
 135    }
 136   
 137  72 public String toString() {
 138  72 final StringBuffer buffer = new StringBuffer();
 139  72 buffer.append("Chapter noNumber: " + getNoNumber() + "\n");
 140  72 buffer.append("Chapter Title:\n");
 141  72 buffer.append(getTitle() + "\n\n");
 142  72 buffer.append("Introduction:\n");
 143  72 buffer.append(getIntroduction() + "\n\n");
 144  72 buffer.append(getSectionList() + "\n");
 145  72 return buffer.toString();
 146    }
 147   
 148    }